Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions python_cli/liquidai_cli/commands/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
def launch(
upgrade_stack: bool = typer.Option(False, "--upgrade-stack", help="Upgrade stack version"),
upgrade_model: bool = typer.Option(False, "--upgrade-model", help="Upgrade model version"),
compose_file: Path = typer.Option("docker-compose.yaml", "--compose-file", "-f", help="Path to docker-compose file"),
):
"""Launch the on-prem stack."""
config = load_config()
Expand Down Expand Up @@ -56,23 +57,34 @@ def launch(
docker_helper.ensure_volume("postgres_data")

# Launch stack
docker_helper.run_compose(Path("docker-compose.yaml"))
try:
docker_helper.run_compose(compose_file)
except FileNotFoundError as e:
typer.echo(f"Error: {str(e)}", err=True)
raise typer.Exit(code=1)

typer.echo("The on-prem stack is now running.")
typer.echo(f"\nModel '{model_name}' is accessible at http://localhost:8000")
typer.echo("Please wait 1-2 minutes for the model to load before making API calls")


@app.command()
def shutdown():
def shutdown(
compose_file: Path = typer.Option("docker-compose.yaml", "--compose-file", "-f", help="Path to docker-compose file"),
):
"""Shutdown the on-prem stack."""
docker_helper.run_compose(Path("docker-compose.yaml"), action="down")
try:
docker_helper.run_compose(compose_file, action="down")
except FileNotFoundError as e:
typer.echo(f"Error: {str(e)}", err=True)
raise typer.Exit(code=1)
typer.echo("Stack has been shut down.")


@app.command()
def purge(
force: bool = typer.Option(False, "--force", "-f", help="Skip confirmation prompt"),
compose_file: Path = typer.Option("docker-compose.yaml", "--compose-file", "--compose", help="Path to docker-compose file"),
):
"""Remove all Liquid Labs components."""
message = (
Expand All @@ -88,7 +100,11 @@ def purge(
return

# Shutdown containers
docker_helper.run_compose(Path("docker-compose.yaml"), action="down")
try:
docker_helper.run_compose(compose_file, action="down")
except FileNotFoundError as e:
typer.echo(f"Error: {str(e)}", err=True)
raise typer.Exit(code=1)

# Remove volume and network
docker_helper.remove_volume("postgres_data")
Expand Down
6 changes: 5 additions & 1 deletion python_cli/liquidai_cli/utils/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def __init__(self, env_file: Path = Path(".env")):

def run_compose(self, compose_file: Path, action: str = "up") -> None:
"""Run docker-compose command."""
# Check if the compose file exists
if not compose_file.exists():
raise FileNotFoundError(f"Docker compose file '{compose_file}' not found. Please ensure the file exists before proceeding.")

cmd = ["docker", "compose", "--env-file", str(self.env_file)]

if action == "up":
Expand Down Expand Up @@ -102,4 +106,4 @@ def remove_env_file(self) -> None:
try:
self.env_file.unlink()
except FileNotFoundError:
pass
pass