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

Update table_name parameter handling #205

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ output/
# codecarbon
.codecarbon.config
emissions.csv
powermetrics_log.txt

# development folder
development/

6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
=========
Changelog
=========
v1.4.3 (**.**.2025)
===================

Fix
===

- Fix bug, where the logtable_name was not overwritten by `table_name` updates in the `PyExperimenter` class.

v1.4.2 (12.06.2024)
===================
Expand Down
558 changes: 272 additions & 286 deletions docs/source/examples/example_logtables.ipynb

Large diffs are not rendered by default.

483 changes: 329 additions & 154 deletions poetry.lock

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions py_experimenter/config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import logging
from abc import ABC, abstractclassmethod
from logging import Logger
from typing import Any, Dict, List, Tuple, Union
from typing import Any, Dict, List, Optional, Tuple, Union

import numpy as np
import omegaconf
from attr import dataclass
from omegaconf import DictConfig, ListConfig, OmegaConf

from py_experimenter import utils
from py_experimenter.exceptions import InvalidColumnError, InvalidConfigError, InvalidLogtableError
from py_experimenter.exceptions import (
InvalidColumnError,
InvalidLogtableError,
)


class Cfg(ABC):
Expand Down Expand Up @@ -362,8 +365,10 @@ def __init__(
self.codecarbon_configuration = codecarbon_configuration

@staticmethod
def extract_config(config_path: str, logger: logging.Logger) -> "PyExperimenterCfg":
def extract_config(config_path: str, logger: logging.Logger, overwritten_table_name: Optional[str] = None) -> "PyExperimenterCfg":
config = omegaconf.OmegaConf.load(config_path)
if overwritten_table_name is not None:
config["PY_EXPERIMENTER"]["Database"]["table"]["name"] = overwritten_table_name

if "n_jobs" not in config["PY_EXPERIMENTER"]:
config["PY_EXPERIMENTER"]["n_jobs"] = 1
Expand Down
4 changes: 1 addition & 3 deletions py_experimenter/experimenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __init__(
handler.setFormatter(formatter)
self.logger.addHandler(handler)

self.config = PyExperimenterCfg.extract_config(experiment_configuration_file_path, logger=self.logger)
self.config = PyExperimenterCfg.extract_config(experiment_configuration_file_path, logger=self.logger, overwritten_table_name=table_name)

self.use_codecarbon = use_codecarbon

Expand All @@ -109,8 +109,6 @@ def __init__(
if use_ssh_tunnel is not None:
self.config.database_configuration.use_ssh_tunnel = use_ssh_tunnel

if table_name is not None:
self.config.database_configuration.table_name = table_name
if database_name is not None:
self.config.database_configuration.database_name = database_name
self.name = name
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ codecarbon = ">=2.2.1"
pymysql = "^1.0.3"
omegaconf = "^2.3.0"
sshtunnel = "^0.4.0"
setuptools = "^69.5.1"

[tool.poetry.group.dev.dependencies]
pytest = ">=7.0"
Expand Down