1
1
from typing import Optional
2
2
3
+ import chromadb_rust_bindings
3
4
from rich .console import Console
4
5
from rich .progress import Progress , SpinnerColumn , TextColumn
5
6
import typer .rich_utils
20
21
utils_app = typer .Typer (short_help = "Use maintenance utilities" )
21
22
app .add_typer (utils_app , name = "utils" )
22
23
23
- _logo = """
24
- \033 [38;5;069m((((((((( \033 [38;5;203m(((((\033 [38;5;220m####
25
- \033 [38;5;069m(((((((((((((\033 [38;5;203m(((((((((\033 [38;5;220m#########
26
- \033 [38;5;069m(((((((((((((\033 [38;5;203m(((((((((((\033 [38;5;220m###########
27
- \033 [38;5;069m((((((((((((((\033 [38;5;203m((((((((((((\033 [38;5;220m############
28
- \033 [38;5;069m(((((((((((((\033 [38;5;203m((((((((((((((\033 [38;5;220m#############
29
- \033 [38;5;069m(((((((((((((\033 [38;5;203m((((((((((((((\033 [38;5;220m#############
30
- \033 [38;5;069m((((((((((((\033 [38;5;203m(((((((((((((\033 [38;5;220m##############
31
- \033 [38;5;069m((((((((((((\033 [38;5;203m((((((((((((\033 [38;5;220m##############
32
- \033 [38;5;069m((((((((((\033 [38;5;203m(((((((((((\033 [38;5;220m#############
33
- \033 [38;5;069m((((((((\033 [38;5;203m((((((((\033 [38;5;220m##############
34
- \033 [38;5;069m(((((\033 [38;5;203m(((( \033 [38;5;220m#########\033 [0m
35
24
36
- """
25
+ def build_cli_args (** kwargs ):
26
+ args = []
27
+ for key , value in kwargs .items ():
28
+ if isinstance (value , bool ):
29
+ if value :
30
+ args .append (f"--{ key } " )
31
+ elif value is not None :
32
+ args .extend ([f"--{ key } " , str (value )])
33
+ return args
37
34
38
35
39
36
@app .command () # type: ignore
@@ -44,54 +41,16 @@ def run(
44
41
host : Annotated [
45
42
Optional [str ], typer .Option (help = "The host to listen to. Default: localhost" )
46
43
] = "localhost" ,
47
- log_path : Annotated [
48
- Optional [str ], typer .Option (help = "The path to the log file." )
49
- ] = "chroma.log" ,
50
44
port : int = typer .Option (8000 , help = "The port to run the server on." ),
51
- test : bool = typer .Option (False , help = "Test mode." , show_envvar = False , hidden = True ),
52
45
) -> None :
53
46
"""Run a chroma server"""
54
- console = Console ()
55
-
56
- print ("\033 [1m" ) # Bold logo
57
- print (_logo )
58
- print ("\033 [1m" ) # Bold
59
- print ("Running Chroma" )
60
- print ("\033 [0m" ) # Reset
61
-
62
- console .print (f"[bold]Saving data to:[/bold] [green]{ path } [/green]" )
63
- console .print (
64
- f"[bold]Connect to chroma at:[/bold] [green]http://{ host } :{ port } [/green]"
65
- )
66
- console .print (
67
- "[bold]Getting started guide[/bold]: [blue]https://docs.trychroma.com/getting-started[/blue]\n \n "
68
- )
69
-
70
- # set ENV variable for PERSIST_DIRECTORY to path
71
- os .environ ["IS_PERSISTENT" ] = "True"
72
- os .environ ["PERSIST_DIRECTORY" ] = path
73
- os .environ ["CHROMA_SERVER_NOFILE" ] = "65535"
74
- os .environ ["CHROMA_CLI" ] = "True"
75
-
76
- # get the path where chromadb is installed
77
- chromadb_path = os .path .dirname (os .path .realpath (__file__ ))
78
-
79
- # this is the path of the CLI, we want to move up one directory
80
- chromadb_path = os .path .dirname (chromadb_path )
81
- log_config = set_log_file_path (f"{ chromadb_path } /log_config.yml" , f"{ log_path } " )
82
- config = {
83
- "app" : "chromadb.app:app" ,
84
- "host" : host ,
85
- "port" : port ,
86
- "workers" : 1 ,
87
- "log_config" : log_config , # Pass the modified log_config dictionary
88
- "timeout_keep_alive" : 30 ,
89
- }
90
-
91
- if test :
92
- return
93
-
94
- uvicorn .run (** config )
47
+ cli_args = ["chroma" , "run" ]
48
+ cli_args .extend (build_cli_args (
49
+ path = path ,
50
+ host = host ,
51
+ port = port ,
52
+ ))
53
+ chromadb_rust_bindings .cli (cli_args )
95
54
96
55
97
56
@utils_app .command () # type: ignore
0 commit comments