Skip to content

Commit

Permalink
Merge branch 'main' into fix/imporve-modular-pipeline-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AhdraMeraliQB authored Mar 15, 2024
2 parents c55c535 + 0b6e1a9 commit 1f32415
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions tests/config/test_omegaconf_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,8 @@ def test_empty_catalog_file(self, tmp_path):
)["catalog"]
assert catalog == {}

@pytest.mark.xfail(reason="Logic failing")
def test_overlapping_patterns(self, tmp_path, mocker):
"""Check that same configuration file is not loaded more than once."""
def test_overlapping_patterns(self, tmp_path):
"""Check that configuration is loaded correctly from overlapping patterns."""
_write_yaml(
tmp_path / _BASE_ENV / "catalog0.yml",
{"env": _BASE_ENV, "common": "common"},
Expand All @@ -424,7 +423,6 @@ def test_overlapping_patterns(self, tmp_path, mocker):
]
}

load_spy = mocker.spy(OmegaConf, "load")
catalog = OmegaConfigLoader(
conf_source=str(tmp_path),
base_env=_BASE_ENV,
Expand All @@ -439,9 +437,31 @@ def test_overlapping_patterns(self, tmp_path, mocker):
}
assert catalog == expected_catalog

# 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)
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 / "user1" / "catalog.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 = {
"user1_c2": True,
}
assert catalog == expected_catalog

# Assert load is only called once
load_spy.assert_called_once()

def test_yaml_parser_error(self, tmp_path):
conf_path = tmp_path / _BASE_ENV
Expand Down

0 comments on commit 1f32415

Please sign in to comment.