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

Struct assign #587

Merged
merged 9 commits into from
Mar 10, 2021
Merged

Struct assign #587

merged 9 commits into from
Mar 10, 2021

Conversation

omry
Copy link
Owner

@omry omry commented Mar 9, 2021

Fixes #586

@omry omry requested review from odelalleau and Jasha10 March 9, 2021 20:00
omegaconf/omegaconf.py Outdated Show resolved Hide resolved
omegaconf/omegaconf.py Outdated Show resolved Hide resolved
@omry omry requested a review from odelalleau March 10, 2021 00:40
@omry
Copy link
Owner Author

omry commented Mar 10, 2021

@odelalleau , take a second look.
Re-implemented as you suggested (see how easy that was? just give me a minimal repro :) ).
I also added some handling for ListConfig. I don't feel 100% confident I got everything covered but I think it's good for now unless you can spot an issue.

@Jasha10
Copy link
Collaborator

Jasha10 commented Mar 10, 2021

Earlier in Dictconfig._set_value_impl there is a code path that handles the case of is_structured_config(value):

            if is_structured_config(value):
                self._metadata.object_type = None
                data = get_structured_config_data(
                    value,
                    allow_objects=self._get_flag("allow_objects"),
                )
                for k, v in data.items():
                    self.__setitem__(k, v)
                self._metadata.object_type = get_type_of(value)

Do we need to worry about using flag_override for this code path?

@odelalleau
Copy link
Collaborator

Do we need to worry about using flag_override for this code path?

That's a good point, maybe the with flag_override() should come before the if block

@omry
Copy link
Owner Author

omry commented Mar 10, 2021

Do we need to worry about using flag_override for this code path?

Took a look. Indeed it was also needed to be in that code path.

That's a good point, maybe the with flag_override() should come before the if block

It's breaking a bunch of tests and I don't feel like digging.

Copy link
Collaborator

@odelalleau odelalleau left a comment

Choose a reason for hiding this comment

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

Good for me!

Regarding:

It's breaking a bunch of tests and I don't feel like digging.

It may be related to the manipulation of flags in the DictConfig code path

Copy link
Collaborator

@Jasha10 Jasha10 left a comment

Choose a reason for hiding this comment

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

Looks good to me too!

@omry omry merged commit 6661470 into master Mar 10, 2021
@omry omry deleted the struct_assign branch March 10, 2021 03:31
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.

Assignment of a dict to to an existing node in Struct mode is raising a validation error.
3 participants