Skip to content

16 fix config file behavior#19

Open
yonatank93 wants to merge 17 commits into
mainfrom
16_fix_config_file_behavior
Open

16 fix config file behavior#19
yonatank93 wants to merge 17 commits into
mainfrom
16_fix_config_file_behavior

Conversation

@yonatank93

Copy link
Copy Markdown
Collaborator

Summary

Fix the behavior of the factory (both reading from a YAML file and instantiating classes from a dictionary)

  • For both cases, the keys and values now are treated as keywords to instantiate the environment and agent classes. We no longer assign any default values from default configurations. Thus, the behavior for instantiating classes manually or using factory should be the same.
  • Default configurations are moved for better organization of the code. Other parts of the code are also modified to reflect the change.

Related issue

Link the issue that this pull request addresses.

Type of change

Please check all that apply:

  • Bug fix
  • New feature
  • Documentation update
  • Tutorial or example update
  • Refactor or code cleanup
  • Test update
  • Performance improvement
  • Change to data preparation or EIS preprocessing
  • Change to ECM/circuit representation or generation
  • Change to RL environment, actions, rewards, or training loop
  • Change to YAML configuration or factory utilities
  • Change to runtime/environment setup
  • Other:

Motivation and context

We want the same behavior whether we instantiate the classes manually or using factory for consistency.

Additional dependencies introduced, if any

Not applied

TODO, if any

Not applied

Checklist

Before this pull request is merged, please check the following:

  • Code is properly formatted.
  • Imports are organized.
  • Linting passes.
  • Tests pass locally.
  • New functionality or bug fixes include tests when appropriate.
  • Public functions/classes include docstrings.
  • Type annotations were added where helpful.
  • Changes to EIS preprocessing, ECM generation, rewards, actions, or evaluation metrics are documented.
  • Changes to training or evaluation workflows include reproducibility information.
  • Changes to default behavior are reflected in the README, tutorials, or configuration files.
  • No unnecessary dependencies were added.
  • Existing examples or tutorials still run, or affected examples were updated.
  • Runtime-sensitive changes were checked with the AutoREC runtime setup when relevant.

Additional comments

Not applied

…ult values

In this version, the keys and values in the configuration file are treated as keyword
arguments to instantiate classes. This makes the behavior of running with configuration
file/factory the same as if we instantiate the classes manually.

For the environment class, the dataset argument is replaced with dataset_path, so that one
can pass in file without needing to load the file first.

Special treatment is for the configurations inside AutoREC/default_configs, where the
dataset_path there is treated as path relative to the configuration file instead of to the
current directory. This is because those default configurations are used for
example/testing.
…efault_configs

I also created a new default configs for the docker run demo. Instead on adding more
function in factory to also handle this case, I think it is just easier to just have an
additional config file. It is not big anyway.
Copilot AI review requested due to automatic review settings June 9, 2026 13:15
@yonatank93 yonatank93 requested review from ajaberi1 and removed request for Copilot June 9, 2026 13:15
@yonatank93 yonatank93 added the bug Something isn't working label Jun 9, 2026
@yonatank93 yonatank93 requested a review from Copilot June 9, 2026 13:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the configuration/factory workflow so YAML/dict configs are treated purely as constructor keyword arguments (no merging with packaged defaults), and makes dataset_path required to align factory behavior with manual instantiation.

Changes:

  • Remove default-config fallback/merging behavior; require dataset_path and load datasets explicitly in the factory.
  • Add special-case path handling so example/default_configs/* resolve dataset_path relative to the config file (and /app/default_configs inside Docker).
  • Reorganize/move example configs and update docs + Docker build inputs accordingly.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/autorec/factory.py Removes default merging, requires dataset_path, adds _config_reader for example-config path resolution.
src/autorec/cli.py Switches config loading to _config_reader for the new example-config path behavior.
README.md Updates configuration documentation and example command paths to example/default_configs.
Dockerfile Copies example/default_configs into the container at /app/default_configs.
pyproject.toml Removes packaging of src/autorec/default_configs/*.yaml.
example/main_factory.py Adds CLI args and adjusts output-dir handling to use agent.save_dir.
example/hyperparameter_tuning/main_factory.py Updates default config path.
example/default_configs/*.yaml Updates dataset paths and moves agent config into examples.
src/autorec/default_configs/agent_config.yaml Deleted (defaults no longer loaded/packaged).
default_configs/environment_config.yaml Deleted (example configs relocated).
Comments suppressed due to low confidence (1)

src/autorec/factory.py:101

  • When args is a dict, this function assigns config = args and then mutates nested structures (e.g., agent_config) by inserting environments. This leaks side effects to callers (including the CLI) and makes it harder to reuse the config dict after calling the builder.
    if isinstance(args, (str, Path)):
        config = _config_reader(args)
    elif isinstance(args, dict):
        config = args
    else:
        raise TypeError("The 'args' parameter must be a str, Path, or dict.")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/autorec/factory.py
Comment thread src/autorec/factory.py
Comment thread example/main_factory.py Outdated
Comment thread example/hyperparameter_tuning/main_factory.py
Comment thread example/main_factory.py
Comment thread src/autorec/cli.py Outdated
Update the error message

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 9, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Comment thread src/autorec/factory.py
Comment thread src/autorec/factory.py
Comment thread example/main_factory.py Outdated
Comment thread README.md Outdated
yonatank93 and others added 3 commits June 9, 2026 09:36
Copilot suggestion for potential bug related to setting the save_dir in the agent configuration yaml file.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 9, 2026 13:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.

Comment thread src/autorec/cli.py Outdated
Comment thread src/autorec/factory.py
Update printed message.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 9, 2026 13:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.

Comment thread src/autorec/cli.py Outdated
Comment thread src/autorec/factory.py
Since there are already some data included, like pretrained model, dataset, etc., I think
doing this reorganization makes it more consistent structure wise with the others.
@yonatank93

Copy link
Copy Markdown
Collaborator Author

@ajaberi1 I think this is ready for you review. After this is merged, then I will work on unit tests.

@yonatank93 yonatank93 mentioned this pull request Jun 10, 2026
29 tasks
Copilot AI review requested due to automatic review settings June 10, 2026 15:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 16 changed files in this pull request and generated 2 comments.

Comment thread src/autorec/factory.py
Comment thread src/autorec/cli.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants