chore: 添加虚拟环境到仓库
- 添加 backend_service/venv 虚拟环境 - 包含所有Python依赖包 - 注意:虚拟环境约393MB,包含12655个文件
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
import chromadb_rust_bindings
|
||||
import requests
|
||||
from packaging.version import parse
|
||||
|
||||
import chromadb
|
||||
|
||||
|
||||
def build_cli_args(**kwargs):
|
||||
args = []
|
||||
for key, value in kwargs.items():
|
||||
if isinstance(value, bool):
|
||||
if value:
|
||||
args.append(f"--{key}")
|
||||
elif value is not None:
|
||||
args.extend([f"--{key}", str(value)])
|
||||
return args
|
||||
|
||||
|
||||
def update():
|
||||
try:
|
||||
url = f"https://api.github.com/repos/chroma-core/chroma/releases"
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
releases = response.json()
|
||||
|
||||
version_pattern = re.compile(r'^\d+\.\d+\.\d+$')
|
||||
numeric_releases = [r["tag_name"] for r in releases if version_pattern.fullmatch(r["tag_name"])]
|
||||
|
||||
if not numeric_releases:
|
||||
print("Couldn't fetch the latest Chroma version")
|
||||
return
|
||||
|
||||
latest = max(numeric_releases, key=parse)
|
||||
if latest == chromadb.__version__:
|
||||
print("Your Chroma version is up-to-date")
|
||||
return
|
||||
|
||||
print(
|
||||
f"A new version of Chroma is available!\nIf you're using pip, run 'pip install --upgrade chromadb' to upgrade to version {latest}")
|
||||
|
||||
except Exception as e:
|
||||
print("Couldn't fetch the latest Chroma version")
|
||||
|
||||
|
||||
def app():
|
||||
args = sys.argv
|
||||
if ["chroma", "update"] in args:
|
||||
update()
|
||||
return
|
||||
try:
|
||||
chromadb_rust_bindings.cli(args)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
@@ -0,0 +1,40 @@
|
||||
from typing import Any, Dict
|
||||
|
||||
import os
|
||||
import yaml
|
||||
|
||||
|
||||
def set_log_file_path(
|
||||
log_config_path: str, new_filename: str = "chroma.log"
|
||||
) -> Dict[str, Any]:
|
||||
"""This works with the standard log_config.yml file.
|
||||
It will not work with custom log configs that may use different handlers"""
|
||||
with open(f"{log_config_path}", "r") as file:
|
||||
log_config = yaml.safe_load(file)
|
||||
for handler in log_config["handlers"].values():
|
||||
if handler.get("class") == "logging.handlers.RotatingFileHandler":
|
||||
handler["filename"] = new_filename
|
||||
|
||||
return log_config
|
||||
|
||||
|
||||
def get_directory_size(directory: str) -> int:
|
||||
"""Get the size of a directory in bytes"""
|
||||
total = 0
|
||||
with os.scandir(directory) as it:
|
||||
for entry in it:
|
||||
if entry.is_file():
|
||||
total += entry.stat().st_size
|
||||
elif entry.is_dir():
|
||||
total += get_directory_size(entry.path)
|
||||
return total
|
||||
|
||||
|
||||
# https://stackoverflow.com/a/1094933
|
||||
def sizeof_fmt(num: int, suffix: str = "B") -> str:
|
||||
n: float = float(num)
|
||||
for unit in ("", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi"):
|
||||
if abs(n) < 1024.0:
|
||||
return f"{n:3.1f}{unit}{suffix}"
|
||||
n /= 1024.0
|
||||
return f"{n:.1f}Yi{suffix}"
|
||||
Reference in New Issue
Block a user