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

Update broken OmegaConfigLoader test #3696

Merged
merged 23 commits into from
Mar 15, 2024
Merged

Conversation

AhdraMeraliQB
Copy link
Contributor

@AhdraMeraliQB AhdraMeraliQB commented Mar 12, 2024

Description

In #3587 it was pointed out that the test test_overlapping_patterns contained an assert statement that was passing trivially. Correcting this assert showed that the logic being tested was redundant, a remnant from the previous ConfigLoader setup that was not carried over to the OmegaConfigLoader. As a result, this assert statement has been removed.

Development notes

The test coverage is unaffected by this removal.

Developer Certificate of Origin

We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a Signed-off-by line in the commit message. See our wiki for guidance.

If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.

Checklist

  • Read the contributing guidelines
  • Signed off each commit with a Developer Certificate of Origin (DCO)
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes
  • Checked if this change will affect Kedro-Viz, and if so, communicated that with the Viz team

astrojuanlu and others added 15 commits February 12, 2024 08:41
Close #3287.

Signed-off-by: Juan Luis Cano Rodríguez <juan_luis_cano@mckinsey.com>
Signed-off-by: Juan Luis Cano Rodríguez <juan_luis_cano@mckinsey.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <90615669+AhdraMeraliQB@users.noreply.github.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <90615669+AhdraMeraliQB@users.noreply.github.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
@AhdraMeraliQB AhdraMeraliQB marked this pull request as ready for review March 12, 2024 11:44
@AhdraMeraliQB AhdraMeraliQB removed the request for review from yetudada March 12, 2024 11:45
Copy link
Member

@astrojuanlu astrojuanlu left a comment

Choose a reason for hiding this comment

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

Not qualified to comment on this one 😅

Signed-off-by: Ahdra Merali <90615669+AhdraMeraliQB@users.noreply.github.com>
@astrojuanlu astrojuanlu removed their request for review March 12, 2024 16:10
Comment on lines 442 to 445
# Assert any specific config file was only loaded once
expected_path = (tmp_path / "dev" / "user1" / "catalog2.yml").resolve()
load_spy.assert_called_once_with(expected_path)

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this removed?

Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Ahdra Merali and others added 2 commits March 14, 2024 09:56
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Comment on lines 440 to 470
def test_overlapping_patterns_in_same_env(self, tmp_path, mocker):
"""Check that configuration files that match several patterns are only loaded once in each env."""
_write_yaml(
tmp_path / _BASE_ENV / "catalog0.yml",
{"env": "base", "common": "common"},
)
_write_yaml(tmp_path / _BASE_ENV / "user1" / "catalog2.yml", {"user1_c2": True})

catalog_patterns = {
"catalog": [
"catalog*",
"user1/catalog*",
"*/catalog2*",
]
}

load_spy = mocker.spy(OmegaConf, "load")
catalog = OmegaConfigLoader(
conf_source=str(tmp_path),
base_env=_BASE_ENV,
config_patterns=catalog_patterns,
)["catalog"]
expected_catalog = {
"env": "base",
"common": "common",
"user1_c2": True,
}
assert catalog == expected_catalog

# Assert load is only called once for each file
assert load_spy.call_count == 2
Copy link
Contributor

Choose a reason for hiding this comment

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

I tested it and it works fine. I think one improvement we can make is simply remove anything about catalog0.yml, since the test is focusing on the deduplication, only catalog 2 is being scan twice but read once. It also make the test simpler.

Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
@AhdraMeraliQB AhdraMeraliQB merged commit 0b6e1a9 into main Mar 15, 2024
34 checks passed
@AhdraMeraliQB AhdraMeraliQB deleted the fix/failing-overlap-logic branch March 15, 2024 11:11
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.

4 participants