Skip to content

Commit

Permalink
refactor(pymilvus/settings.py): Switch to load_dotenv.
Browse files Browse the repository at this point in the history
Signed-off-by: -LAN- <laipz8200@outlook.com>
  • Loading branch information
laipz8200 committed Aug 17, 2024
1 parent 61bd7ce commit d12b6e5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pymilvus/settings.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import logging.config
import os

from dotenv import dotenv_values
from dotenv import load_dotenv

env_dict = dotenv_values(".env")
load_dotenv()


class Config:
# legacy env MILVUS_DEFAULT_CONNECTION, not recommended
LEGACY_URI = str(env_dict.get("MILVUS_DEFAULT_CONNECTION", ""))
MILVUS_URI = str(env_dict.get("MILVUS_URI", LEGACY_URI))
LEGACY_URI = str(os.getenv("MILVUS_DEFAULT_CONNECTION", ""))
MILVUS_URI = str(os.getenv("MILVUS_URI", LEGACY_URI))

MILVUS_CONN_ALIAS = str(env_dict.get("MILVUS_CONN_ALIAS", "default"))
MILVUS_CONN_TIMEOUT = float(env_dict.get("MILVUS_CONN_TIMEOUT", 10.0))
MILVUS_CONN_ALIAS = str(os.getenv("MILVUS_CONN_ALIAS", "default"))
MILVUS_CONN_TIMEOUT = float(os.getenv("MILVUS_CONN_TIMEOUT", "10.0"))

# legacy configs:
DEFAULT_USING = MILVUS_CONN_ALIAS
Expand Down

0 comments on commit d12b6e5

Please sign in to comment.