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 when deep copying full config with missing parent #3009

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

jesszzzz
Copy link
Contributor

@jesszzzz jesszzzz commented Jan 15, 2025

Motivation

Previously the implementation assumed that OmegaConf.select(subconfig._get_root(), subconfig._get_full_key(None) == subconfig but this isn't actually the case because sometimes subconfig's parent is set to None without modifying the full key.

This PR fixes it by

  1. Removing any subconfig._get_root() eg. if
    None is parent of B (full key A.B) is parent of C (full key A.B.C) is parent of D (full key A.B.C.D)
    then the root of D is B
    The key we should use is C.D which is D's full key with B's full key removed from the prefix

  2. If for whatever reason even with this logic, we still can't retrieve the subconfig from the root config correctly, give up on trying to do the full copy and revert to previous behavior

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

New tests pass

(How should this PR be tested? Do you require special setup to run the test or repro the fixed bug?)

Related Issues and PRs

(Is this PR part of a group of changes? Link the other relevant PRs and Issues here. Use https://help.github.com/en/articles/closing-issues-using-keywords for help on GitHub syntax)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 15, 2025
@jesszzzz jesszzzz force-pushed the fix_deepcopy_full_config_bug branch from e457f66 to 8318064 Compare January 15, 2025 17:26
Copy link

@tonykao8080 tonykao8080 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. thanks for adding the test to validate the scenario

@jesszzzz jesszzzz merged commit 7c8fa4a into main Jan 16, 2025
24 checks passed
@jesszzzz jesszzzz deleted the fix_deepcopy_full_config_bug branch January 16, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants