mirror of
https://github.com/imartinez/privateGPT.git
synced 2026-07-17 11:29:56 +00:00
chore: don't allow to run worker without celery (#2243)
(cherry picked from commit 162b9087b4cf3fb66ae0c8ae465bd90e8dacc0f2)
This commit is contained in:
@@ -5,7 +5,15 @@ import typer
|
||||
|
||||
from private_gpt.cli.commands.run import run_command
|
||||
from private_gpt.cli.commands.serve import serve_command
|
||||
from private_gpt.cli.commands.worker import worker_command
|
||||
|
||||
try:
|
||||
import celery as _celery # noqa: F401
|
||||
|
||||
from private_gpt.cli.commands.worker import worker_command
|
||||
|
||||
_CELERY_AVAILABLE = True
|
||||
except ImportError:
|
||||
_CELERY_AVAILABLE = False
|
||||
|
||||
app = typer.Typer(
|
||||
name="private-gpt",
|
||||
@@ -16,7 +24,8 @@ app = typer.Typer(
|
||||
)
|
||||
|
||||
app.command("serve")(serve_command)
|
||||
app.command("worker")(worker_command)
|
||||
if _CELERY_AVAILABLE:
|
||||
app.command("worker")(worker_command)
|
||||
app.command(
|
||||
"run",
|
||||
context_settings={"allow_extra_args": True, "ignore_unknown_options": True},
|
||||
@@ -38,7 +47,9 @@ def help_command(
|
||||
raise SystemExit(0)
|
||||
|
||||
|
||||
_KNOWN_COMMANDS = ["serve", "worker", "run", "help"]
|
||||
_KNOWN_COMMANDS = ["serve", "run", "help"]
|
||||
if _CELERY_AVAILABLE:
|
||||
_KNOWN_COMMANDS.append("worker")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
Reference in New Issue
Block a user