Skip to content

Commit

Permalink
Merge pull request #571 from mit-ll-responsible-ai/passthrough
Browse files Browse the repository at this point in the history
Make ZenStore.update noop for identical stores
  • Loading branch information
rsokl authored Nov 8, 2023
2 parents 9720ac4 + d9189bd commit 43948b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/hydra_zen/wrapper/_implementations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,9 @@ def update(self, __other: "ZenStore") -> None:
s3
{None: ['g']}
"""
if __other == self:
return

self._internal_repo.update(deepcopy(__other._internal_repo))
self._queue.update(__other._queue)
if not self._deferred_store:
Expand Down
5 changes: 4 additions & 1 deletion tests/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,8 @@ def test_update():

s3 = s1(group="BB")
assert s3 == s1
s1 |= s2

s1 |= s2
assert len(s1) == 3
assert s1._queue == {(None, "a"), (None, "b"), ("G", "c")}
assert s1._internal_repo[None, "b"] is not s2._internal_repo[None, "b"]
Expand All @@ -951,6 +951,9 @@ def test_update():
s3({}, name="foo")
assert ("BB", "foo") in s1

s1 |= s3
assert s3 == s1


@pytest.mark.usefixtures("clean_store")
def test_update_respects_add_to_hydra_store():
Expand Down

0 comments on commit 43948b1

Please sign in to comment.