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

[Config] Use one global config #63

Merged
merged 1 commit into from
Oct 9, 2024
Merged
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
11 changes: 10 additions & 1 deletion src/o2tuner/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class WorkDir:

CONFIG_STAGES_KEYS = [CONFIG_STAGES_USER_KEY, CONFIG_STAGES_OPTIMISATION_KEY]

CONFIG_STATIC_CONFIG_KEY = "config"


def get_work_dir():
"""
Expand Down Expand Up @@ -127,6 +129,10 @@ def setup(self):
print(f" - {CONFIG_STAGES_USER_KEY}\n - {CONFIG_STAGES_OPTIMISATION_KEY}")
sys.exit(1)

global_config = config.get(CONFIG_STATIC_CONFIG_KEY, {})
if not global_config:
LOG.info('No global configuration passed')

self.all_stages = []
# set working directories
all_deps = []
Expand All @@ -142,7 +148,10 @@ def setup(self):
config[csk][name] = deepcopy(config[csk][name])
value = config[csk][name]
value["cwd"] = value.get("cwd", name)
value["config"] = value.get("config", {})
local_config = value.get(CONFIG_STATIC_CONFIG_KEY, {})
# merge global and local config, local config takes precedence
value_config = global_config | local_config
value[CONFIG_STATIC_CONFIG_KEY] = value_config
all_deps.extend(value.get("deps", []))

if csk == CONFIG_STAGES_OPTIMISATION_KEY:
Expand Down