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

add opik.config unit tests #270

Merged
merged 12 commits into from
Sep 24, 2024
18 changes: 12 additions & 6 deletions sdks/python/src/opik/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ def config_file_fullpath(self) -> pathlib.Path:
def save_to_file(self) -> None:
"""
Save configuration to a file

Raises:
OSError: If there is an issue writing to the file.
"""
config_file_content = configparser.ConfigParser()

Expand All @@ -158,12 +161,15 @@ def save_to_file(self) -> None:
if self.api_key is not None:
config_file_content["opik"]["api_key"] = self.api_key

with open(
self.config_file_fullpath, mode="w+", encoding="utf-8"
) as config_file:
config_file_content.write(config_file)

LOGGER.info(f"Saved configuration to a file: {self.config_file_fullpath}")
try:
with open(
self.config_file_fullpath, mode="w+", encoding="utf-8"
) as config_file:
config_file_content.write(config_file)
LOGGER.info(f"Configuration saved to file: {self.config_file_fullpath}")
except OSError as e:
LOGGER.error(f"Failed to save configuration: {e}")
raise


def update_session_config(key: str, value: Any) -> None:
Expand Down
Loading
Loading