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

disambiguate get_override_key treatment of global #1791

Merged
merged 7 commits into from
Sep 1, 2021

Conversation

Jasha10
Copy link
Collaborator

@Jasha10 Jasha10 commented Aug 25, 2021

This PR closes #1784 by modifying the InputDefaults.get_override_key method.

Changes Introduced

Previously, get_override_key had this behavior:

  • Group "foo" and package "foo" -> override key == "foo"
  • Group "foo" and package "bar" -> override key == "foo@bar"
  • Group "foo" and package "" -> override key == "foo"
    With this PR, get_override_key has this behavior:
  • Group "foo" and package "foo" -> override key == "foo"
  • Group "foo" and package "bar" -> override key == "foo@bar"
  • Group "foo" and package "" -> override key == "foo@_global_"

Updates to Pre-Existing Tests

This PR introduces some new tests, and it also updates two old tests that were relying on the old key-collision behavior.
These two tests had to be updated:

test_defaults_list.py::test_include_nested_group_global[option_override:include_nested_config_item_global]
test_defaults_tree.py::test_experiment_overriding_global_group[include_absolute_config:override_with_global_default]

In the first updated tests, the command-line override "group1/group2=file2" was being used, while "group1/group2@_global_=file2" should have been used instead.
In the second updated test, the default element override /group1@_global_: file2 was being used to override group "group1" at package "group1", while the element override /group1@_global_.group1: file2 should have been used instead.

@Jasha10 Jasha10 requested review from omry and jieru-hu August 25, 2021 14:07
@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 Aug 25, 2021
@Jasha10 Jasha10 marked this pull request as ready for review August 25, 2021 14:23
@@ -1,2 +1,2 @@
defaults:
- override /group1@_global_: file2
- override /group1@_global_.group1: file2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of this, can you add a global header to the file?
Experiment configs have it but this does not.

A package override in the defaults list is relative to the package of a config.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in f12150b.

tests/defaults_list/test_defaults_tree.py Show resolved Hide resolved
Comment on lines +1328 to +1329
You must specify 'db@_global_', e.g, db@_global_=<OPTION>
Available options:"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rebased to incorporate changes from PR #1783 so that this test would pass.

Copy link
Collaborator

@omry omry left a comment

Choose a reason for hiding this comment

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

A few nits. Overall I am okay with this change.
I believe it will also address the issue you opened about _here_.

Don't forget news fragment.

Comment on lines 715 to 735
param(
"two_group_defaults_different_pkgs_global",
[],
[
ResultDefault(
config_path="group1/file1",
parent="two_group_defaults_different_pkgs_global",
package="group1",
),
ResultDefault(
config_path="group1/file2",
parent="two_group_defaults_different_pkgs_global",
package="",
),
ResultDefault(
config_path="two_group_defaults_different_pkgs_global",
package="",
is_self=True,
),
],
),
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing id for this test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added in 806eb0b.

parent="group_default_at_global",
),
],
id="include_absolute_config:override_with_global_default2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

copy paste id? include_absolute_config does not make sense to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Updated in 806eb0b.

@Jasha10 Jasha10 merged commit 2ceb903 into facebookresearch:main Sep 1, 2021
@Jasha10 Jasha10 deleted the closes1784_2 branch September 1, 2021 17:06
@Jasha10
Copy link
Collaborator Author

Jasha10 commented Sep 2, 2021

This PR also closed #1803

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.

[Bug] key collision when using option@_global_ in defaults list
3 participants