Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "veadk-python"
version = "0.2.15"
version = "0.2.16"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if updating dotenv dependency as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have dotenv deps in previous version.

description = "Volcengine agent development kit, integrations with Volcengine cloud services."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
13 changes: 12 additions & 1 deletion veadk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os
from typing import Any

from dotenv import find_dotenv
from dotenv import find_dotenv, load_dotenv
from pydantic import BaseModel, Field

from veadk.configs.database_configs import (
Expand All @@ -33,8 +33,16 @@
PrometheusConfig,
TLSConfig,
)
from veadk.utils.logger import get_logger
from veadk.utils.misc import set_envs

logger = get_logger(__name__)

if load_dotenv(find_dotenv(usecwd=True)):
logger.info(f"Find `.env` file in {find_dotenv(usecwd=True)}, load envs.")
else:
logger.info("No env file found.")


class VeADKConfig(BaseModel):
model: ModelConfig = Field(default_factory=ModelConfig)
Expand Down Expand Up @@ -89,7 +97,10 @@ def getenv(
veadk_environments = {}

if config_yaml_path:
logger.info(f"Find `config.yaml` file in {config_yaml_path}")
config_dict, _veadk_environments = set_envs(config_yaml_path=config_yaml_path)
veadk_environments.update(_veadk_environments)
else:
logger.warning("No `config.yaml` file found.")

settings = VeADKConfig()
7 changes: 7 additions & 0 deletions veadk/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def getenv(


def set_envs(config_yaml_path: str) -> tuple[dict, dict]:
from veadk.utils.logger import get_logger

logger = get_logger(__name__)

with open(config_yaml_path, "r", encoding="utf-8") as yaml_file:
config_dict = safe_load(yaml_file)

Expand All @@ -138,6 +142,9 @@ def set_envs(config_yaml_path: str) -> tuple[dict, dict]:
k = k.upper()

if k in os.environ:
logger.info(
f"Environment variable {k} has been set, value in `config.yaml` will be ignored."
)
veadk_environments[k] = os.environ[k]
continue
veadk_environments[k] = str(v)
Expand Down
2 changes: 1 addition & 1 deletion veadk/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION = "0.2.15"
VERSION = "0.2.16"