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

Fix bug with config_path when using save(config, save_dc_types=True) #284

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

lebrice
Copy link
Owner

@lebrice lebrice commented Aug 3, 2023

Fixes #276

  • Raises a warning whenever the config default is a dict that isn't one of the options in the subgroup values
  • Tries to use the closest matching subgroup in that case.

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Result of Benchmark Tests

Benchmark Min Max Mean Mean on Repo HEAD
test/test_performance.py::test_import_performance 0.02 0.02 0.02 +- 0.00 0.02 +- 0.00
test/test_performance.py::test_parse_performance 0.01 0.01 0.01 +- 0.00 0.02 +- 0.00
test/test_performance.py::test_serialization_performance[.yaml] 0.01 0.01 0.01 +- 0.00 0.02 +- 0.00
test/test_performance.py::test_serialization_performance[.json] 0.00 0.00 0.00 +- 0.00 0.00 +- 0.00
test/test_performance.py::test_serialization_performance[.pkl] 0.00 0.00 0.00 +- 0.00 0.00 +- 0.00

@anivegesana
Copy link
Contributor

Hey @lebrice, is there a status update on this change? It would be nice for me to be able to use the official release of simple_parsing again instead of using this branch.

@lebrice
Copy link
Owner Author

lebrice commented Oct 23, 2023

Hey @lebrice, is there a status update on this change? It would be nice for me to be able to use the official release of simple_parsing again instead of using this branch.

Hey there! Apologies, no updates on this atm. I'll try to get some work done soon. In the meantime, feel free to make your own PR based on this if you want to help speed up the process :)

@anivegesana
Copy link
Contributor

No problem. It certainly is not urgent. I just want to make sure that it will eventually get in. I can help separate out parts related to this feature into its own PR, although I took most of it from here.

@lebrice lebrice marked this pull request as ready for review October 27, 2023 19:50
@lebrice lebrice force-pushed the lebrice/config_type_key_bug branch 2 times, most recently from 4b2a774 to 4b8f1a3 Compare October 27, 2023 20:11
@lebrice lebrice changed the title WIP: Fix bug with config_path when using save(config, save_dc_types=True) Fix bug with config_path when using save(config, save_dc_types=True) Oct 27, 2023
@lebrice
Copy link
Owner Author

lebrice commented Oct 27, 2023

No problem. It certainly is not urgent. I just want to make sure that it will eventually get in. I can help separate out parts related to this feature into its own PR, although I took most of it from here.

Hey @anivegesana, I just updated the PR, would you mind testing this with your code and letting me know if anything doesn't work?
Thanks!

@anivegesana
Copy link
Contributor

Hey @lebrice,

Great work putting this together so quickly! I ran our internal unit tests using this PR and found just one thing that used to work on our branch that no longer does with this PR:

from_dict(ConfigType, to_dict(config)) no longer seems to roundtrip. Instead, I get the error AssertionError: FIXME: assuming that the _type_ is in the config dict. if a subgroups is present in ConfigType. This is because to_dict doesn't save the _type_ to the subgroup dicts automatically so from_dict is unable to recover the type. I don't know if there was a setting I needed to pass to do this on this PR, but on the branch that I have been testing on, I overloaded the definition of save_dc_types so that False means only save _type_s for subgroups fields instead of never saving _type_, but feel free to choose another solution and I will use whichever one you choose.
anivegesana@aa0e1a2#diff-e2a4574cba7d6626ce9914c133c3fd13ae7ae8feeb579d1f01dbd7a8a026db38R723-R726
anivegesana@aa0e1a2#diff-eda7f0cd48dfe1a9962aea453aa22fd049f9dd6d1795622fe9fa985ca1b77d56R116-R123

Besides this one wrinkle, everything seems to work perfectly. Excellent work!

@anivegesana
Copy link
Contributor

Hey @lebrice,
Any further progress on this PR and any plans to merge it any time soon?
Thanks!

@lebrice
Copy link
Owner Author

lebrice commented Dec 16, 2023

Hi @anivegesana , sorry I'm currently at NeurIPS.

I'll try to work on this as soon as I can. Thanks for the reminder and sorry for the delay!

@anivegesana
Copy link
Contributor

No problem. Just wanted to bump it again since there wasn't any update in the last couple of months. Take your time and have fun at NeurIPS!

@lebrice
Copy link
Owner Author

lebrice commented Dec 21, 2023

Hey @anivegesana does this work?

Comment on lines 667 to 669
assert (
argument_options["default"] is subgroup_field.subgroup_default
), argument_options["default"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @lebrice, thanks for your quick turn around time and hope you enjoyed NeurIPS!

For some reason, our internal tests are failing on this assertion. When I comment it out, nothing bad seems to happen and the test cases pass. This is because there are some places in our config YAMLs that we wrote:

a: KEY

instead of

a:
    _type_: ValueType

Is this intended? If so, I can update the configs on our side to work with this PR, but bringing it up in case you want to support the former way to specify subgroups that do not need any additional fields.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @lebrice, happy new year! Any updates on this?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah I'm working on it. This subgroups feature is in need of some proper refactoring. I'd be tempted to add your fixes and make a quick patch, but there are some underlying issues with the implementation that seem to warrant a broader refactor of that feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @lebrice, any updates on the feature refactor?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hey @anivegesana, thansk for the reminder. Sorry, no updates as of yet on my end. I'll let you know when I get to this (hopefully in the coming weeks).

lebrice and others added 4 commits January 31, 2024 14:52
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using subgroups with config_path leads to a TypeError
2 participants