Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pymilvus/settings.py): Load configuration without altering the environment #2192

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 6 additions & 10 deletions pymilvus/settings.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import contextlib
import logging.config

import environs
from dotenv import dotenv_values

env = environs.Env()

with contextlib.suppress(Exception):
env.read_env(".env")
env_dict = dotenv_values(".env")
laipz8200 marked this conversation as resolved.
Show resolved Hide resolved


class Config:
# legacy env MILVUS_DEFAULT_CONNECTION, not recommended
LEGACY_URI = env.str("MILVUS_DEFAULT_CONNECTION", "")
MILVUS_URI = env.str("MILVUS_URI", LEGACY_URI)
LEGACY_URI = str(env_dict.get("MILVUS_DEFAULT_CONNECTION", ""))
laipz8200 marked this conversation as resolved.
Show resolved Hide resolved
MILVUS_URI = str(env_dict.get("MILVUS_URI", LEGACY_URI))

MILVUS_CONN_ALIAS = env.str("MILVUS_CONN_ALIAS", "default")
MILVUS_CONN_TIMEOUT = env.float("MILVUS_CONN_TIMEOUT", 10)
MILVUS_CONN_ALIAS = str(env_dict.get("MILVUS_CONN_ALIAS", "default"))
MILVUS_CONN_TIMEOUT = float(env_dict.get("MILVUS_CONN_TIMEOUT", 10.0))

# legacy configs:
DEFAULT_USING = MILVUS_CONN_ALIAS
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build==0.4.0
certifi==2024.7.4
chardet==4.0.0
environs==9.5.0
python-dotenv==1.0.1
grpcio==1.62.2
grpcio-testing==1.62.2
grpcio-tools==1.62.2
Expand Down