Skip to content

Commit

Permalink
[ENH]: Support for host option in CLI run command (default: `localhos…
Browse files Browse the repository at this point in the history
…t`) (#1262)

## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
- Added `--host <hostname/ip>` option to `run` command with default
`localhost` (which works for the user's local preferred IP stack)
- Made the CLI start on localhost by default (this is a more secure
option than 0.0.0.0)
- `chroma run --host 0.0.0.0` will now also print the correct hostname
at startup - `Connect to chroma at: http://0.0.0.0:8000`
	 - Removed unused chroma_data dir (committed by mistake)

## Test plan
*How are these changes tested?*

- [ ] Tests pass locally with `pytest` for python

## Documentation Changes

@jeffchuber, should we have a dedicated page for the CLI (granted, it
will grow in functionality)?
  • Loading branch information
tazarov authored Oct 23, 2023
1 parent 5a5e158 commit 04fa509
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Binary file removed chroma_data/chroma.sqlite3
Binary file not shown.
11 changes: 8 additions & 3 deletions chromadb/cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Optional
from typing_extensions import Annotated
import typer
import uvicorn
import os
Expand Down Expand Up @@ -26,8 +28,11 @@ def run(
path: str = typer.Option(
"./chroma_data", help="The path to the file or directory."
),
host: Annotated[Optional[str], typer.Option(
help="The host to listen to. Default: localhost")] = "localhost",
port: int = typer.Option(8000, help="The port to run the server on."),
test: bool = typer.Option(False, help="Test mode.", show_envvar=False, hidden=True),
test: bool = typer.Option(False, help="Test mode.",
show_envvar=False, hidden=True),
) -> None:
"""Run a chroma server"""

Expand All @@ -39,7 +44,7 @@ def run(

typer.echo(f"\033[1mSaving data to\033[0m: \033[32m{path}\033[0m")
typer.echo(
f"\033[1mConnect to chroma at\033[0m: \033[32mhttp://localhost:{port}\033[0m"
f"\033[1mConnect to chroma at\033[0m: \033[32mhttp://{host}:{port}\033[0m"
)
typer.echo(
"\033[1mGetting started guide\033[0m: https://docs.trychroma.com/getting-started\n\n"
Expand All @@ -57,7 +62,7 @@ def run(

config = {
"app": "chromadb.app:app",
"host": "0.0.0.0",
"host": host,
"port": port,
"workers": 1,
"log_config": f"{chromadb_path}/log_config.yml",
Expand Down

0 comments on commit 04fa509

Please sign in to comment.