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

Commit

Permalink
Merge pull request #114 from pinecone-io/start_index_name
Browse files Browse the repository at this point in the history
[cli] added --index-name option to `canopy start`
  • Loading branch information
igiloh-pinecone authored Oct 29, 2023
2 parents bf2db84 + 96baadd commit c83da5e
Showing 1 changed file with 14 additions and 1 deletion.
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, rag, 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

0 comments on commit c83da5e

Please sign in to comment.