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

[feature] Enable default settings for TrainerSettings #4448

Merged
merged 7 commits into from
Sep 3, 2020

Conversation

ervteng
Copy link
Contributor

@ervteng ervteng commented Sep 2, 2020

Proposed change(s)

Based on feedback from CarryCastle. Enables specifying a default TrainerSettings for all behaviors. The default is specified using the same structure as the others under a new header default_settings. These are now used as the default values for all behaviors, including those not found in the settings YAML.

default_settings:
    trainer_type: ppo
    ... etc.
behaviors:
    CrawlerStatic:

For behavior names that are defined in the YAML, any missing fields will be filled first from the default_settings, then those defined in the TrainerSettings class insettings.py.

WIP: Tests, documentation

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

# Check if a default_settings was specified. If so, used those as the default
# rather than an empty dict.
if TrainerSettings.default_override is not None:
d_copy.update(cattr.unstructure(TrainerSettings.default_override))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this will do what you want for nested dictionaries. For example if you had

{"foo": {"x": 1}}.update({"foo", {"y": 2}})

you'd end up with {"foo", {"y": 2}}, but I think you really want {"foo", {"x": 1, "y": 2}} (i.e. recursively merge dictionary values)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed using a recursive dict update

@ervteng ervteng marked this pull request as ready for review September 2, 2020 23:12
# < Same as above >
```

Behaviors found in the environment that aren't secified in the YAML will now use the `default_settings`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Behaviors found in the environment that aren't secified in the YAML will now use the `default_settings`,
Behaviors found in the environment that aren't specified in the YAML will now use the `default_settings`,

@ervteng ervteng merged commit 376168b into master Sep 3, 2020
@delete-merged-branch delete-merged-branch bot deleted the develop-default-settings branch September 3, 2020 22:56
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants