diff --git a/arch/tools/README.md b/arch/tools/README.md index f566caac..8a74dc37 100644 --- a/arch/tools/README.md +++ b/arch/tools/README.md @@ -48,7 +48,7 @@ source venv/bin/activate ### Step 3: Run the build script ```bash -sh build-cli.sh +sh build_cli.sh ``` ### Step 4: build Arch @@ -56,6 +56,10 @@ sh build-cli.sh archgw build ``` +## Step 5: start model server in the background +``` +archgw up --services model_server +``` ## Uninstall Instructions: archgw CLI ```bash diff --git a/arch/tools/build-cli.sh b/arch/tools/build-cli.sh deleted file mode 100644 index aae3b616..00000000 --- a/arch/tools/build-cli.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# Define paths -source_schema="../arch_config_schema.yaml" -source_compose="../docker-compose.yaml" -source_stage_env="../stage.env" -destination_dir="config" - -# Ensure the destination directory exists only if it doesn't already -if [ ! -d "$destination_dir" ]; then - mkdir -p "$destination_dir" - echo "Directory $destination_dir created." -fi - -# Copy the files -cp "$source_schema" "$destination_dir/arch_config_schema.yaml" -cp "$source_compose" "$destination_dir/docker-compose.yaml" -cp "$source_stage_env" "$destination_dir/stage.env" - -# Print success message -echo "Files copied successfully!" - -echo "Building the cli" -poetry install diff --git a/arch/tools/cli/main.py b/arch/tools/cli/main.py index 22bc5cee..95c056e6 100644 --- a/arch/tools/cli/main.py +++ b/arch/tools/cli/main.py @@ -38,66 +38,89 @@ MODEL_SERVER_BUILD_FILE = "./model_server/pyproject.toml" @click.command() -def build(): +@click.option( + "--services", + default="all", + help="Services to build. Options are all, model_server, archgw. Default is all", +) +def build(services): """Build Arch from source. Must be in root of cloned repo.""" - # Check if /arch/Dockerfile exists - if os.path.exists(ARCHGW_DOCKERFILE): - click.echo("Building archgw image...") - try: - subprocess.run( - [ - "docker", - "build", - "-f", - ARCHGW_DOCKERFILE, - "-t", - "archgw:latest", - ".", - ], - check=True, - ) - click.echo("archgw image built successfully.") - except subprocess.CalledProcessError as e: - click.echo(f"Error building archgw image: {e}") - sys.exit(1) - else: - click.echo("Error: Dockerfile not found in /arch") + if services not in ["all", "model_server", "archgw"]: + print(f"Error: Invalid service {services}. Exiting") sys.exit(1) + # Check if /arch/Dockerfile exists + if services == "archgw" or services == "all": + if os.path.exists(ARCHGW_DOCKERFILE): + click.echo("Building archgw image...") + try: + subprocess.run( + [ + "docker", + "build", + "-f", + ARCHGW_DOCKERFILE, + "-t", + "archgw:latest", + ".", + ], + check=True, + ) + click.echo("archgw image built successfully.") + except subprocess.CalledProcessError as e: + click.echo(f"Error building archgw image: {e}") + sys.exit(1) + else: + click.echo("Error: Dockerfile not found in /arch") + sys.exit(1) - click.echo("All images built successfully.") + click.echo("archgw image built successfully.") """Install the model server dependencies using Poetry.""" - # Check if pyproject.toml exists - if os.path.exists(MODEL_SERVER_BUILD_FILE): - click.echo("Installing model server dependencies with Poetry...") - try: - subprocess.run( - ["poetry", "install", "--no-cache"], - cwd=os.path.dirname(MODEL_SERVER_BUILD_FILE), - check=True, - ) - click.echo("Model server dependencies installed successfully.") - except subprocess.CalledProcessError as e: - click.echo(f"Error installing model server dependencies: {e}") + if services == "model_server" or services == "all": + # Check if pyproject.toml exists + if os.path.exists(MODEL_SERVER_BUILD_FILE): + click.echo("Installing model server dependencies with Poetry...") + try: + subprocess.run( + ["poetry", "install", "--no-cache"], + cwd=os.path.dirname(MODEL_SERVER_BUILD_FILE), + check=True, + ) + click.echo("Model server dependencies installed successfully.") + except subprocess.CalledProcessError as e: + click.echo(f"Error installing model server dependencies: {e}") + sys.exit(1) + else: + click.echo(f"Error: pyproject.toml not found in {MODEL_SERVER_BUILD_FILE}") sys.exit(1) - else: - click.echo(f"Error: pyproject.toml not found in {MODEL_SERVER_BUILD_FILE}") - sys.exit(1) @click.command() @click.argument("file", required=False) # Optional file argument @click.option( - "--path", default=".", help="Path to the directory containing arch_config.yml" + "--path", default=".", help="Path to the directory containing arch_config.yaml" ) -def up(file, path): +@click.option( + "--services", + default="all", + help="Services to start. Options are all, model_server, archgw. Default is all", +) +def up(file, path, services): """Starts Arch.""" + if services not in ["all", "model_server", "archgw"]: + print(f"Error: Invalid service {services}. Exiting") + sys.exit(1) + + if services == "model_server": + start_arch_modelserver() + return + if file: # If a file is provided, process that file arch_config_file = os.path.abspath(file) else: - # If no file is provided, use the path and look for arch_config.yml - arch_config_file = os.path.abspath(os.path.join(path, "arch_config.yml")) + # If no file is provided, use the path and look for arch_config.yaml + arch_config_file = os.path.abspath(os.path.join(path, "arch_config.yaml")) # Check if the file exists if not os.path.exists(arch_config_file): @@ -160,15 +183,32 @@ def up(file, path): env.update(env_stage) env["ARCH_CONFIG_FILE"] = arch_config_file - start_arch_modelserver() - start_arch(arch_config_file, env) + if services == "archgw": + start_arch(arch_config_file, env) + else: + start_arch_modelserver() + start_arch(arch_config_file, env) @click.command() -def down(): +@click.option( + "--services", + default="all", + help="Services to down. Options are all, model_server, archgw. Default is all", +) +def down(services): """Stops Arch.""" - stop_arch_modelserver() - stop_arch() + + if services not in ["all", "model_server", "archgw"]: + print(f"Error: Invalid service {services}. Exiting") + sys.exit(1) + if services == "model_server": + stop_arch_modelserver() + elif services == "archgw": + stop_arch() + else: + stop_arch_modelserver() + stop_arch() @click.command() diff --git a/docs/source/get_started/quickstart.rst b/docs/source/get_started/quickstart.rst index ad23be80..23a76379 100644 --- a/docs/source/get_started/quickstart.rst +++ b/docs/source/get_started/quickstart.rst @@ -70,6 +70,7 @@ Step 3: Start Arch Gateway $ archgw up [path_to_config] +For detailed usage please refer to the `Support ` Next Steps