Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

[cli] added --index-name option to canopy start #122

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 14 additions & 1 deletion src/canopy_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,10 @@ def chat(chat_service_url, baseline, debug, stream):
@click.option("--config", "-c", default=None,
help="Path to a canopy config file. Optional, otherwise configuration "
"defaults will be used.")
def start(host: str, port: str, reload: bool, config: Optional[str]):
@click.option("--index-name", default=None,
help="Index name, if not provided already in as an environment variable")
def start(host: str, port: str, reload: bool,
config: Optional[str], index_name: Optional[str]):
note_msg = (
"🚨 Note 🚨\n"
"For debugging only. To run the Canopy service in production, run the command:"
Expand All @@ -487,6 +490,16 @@ def start(host: str, port: str, reload: bool, config: Optional[str]):
time.sleep(0.01)
click.echo()

if index_name:
env_index_name = os.getenv("INDEX_NAME")
if env_index_name and index_name != env_index_name:
raise CLIError(
f"Index name provided via --index-name '{index_name}' does not match "
f"the index name provided via the INDEX_NAME environment variable "
f"'{env_index_name}'"
)
os.environ["INDEX_NAME"] = index_name

click.echo(f"Starting Canopy service on {host}:{port}")
start_service(host, port=port, reload=reload, config_file=config)

Expand Down