Skip to content

Commit

Permalink
removed comment; extracted variable PERSISTENT_IMPLEMENTATIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
zilto authored and zilto committed Oct 28, 2024
1 parent 29dbe1c commit 13a0ec3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
2 changes: 0 additions & 2 deletions hamilton/caching/stores/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,4 @@ def load_from(
result = result_store.get(data_version)
in_memory_result_store.set(data_version, result)

# TODO could be beneficial to delete the `result_store` after loading from it,
# but we don't know if it's used for other purposes
return in_memory_result_store
15 changes: 5 additions & 10 deletions tests/caching/metadata_store/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
# a pytest fixture automatically provided to tests
from .test_base import _mock_cache_key, metadata_store # noqa: F401

# implementations that in-memory metadata store can `.persist_to()` and `.load_from()`
PERSISTENT_IMPLEMENTATIONS = [SQLiteMetadataStore]

@pytest.mark.parametrize(
"metadata_store",
[SQLiteMetadataStore],
indirect=True,
)

@pytest.mark.parametrize("metadata_store", PERSISTENT_IMPLEMENTATIONS, indirect=True)
def test_persist_to(metadata_store): # noqa: F811
cache_key = _mock_cache_key()
data_version = "foo-a"
Expand All @@ -38,11 +37,7 @@ def test_persist_to(metadata_store): # noqa: F811
assert in_memory_metadata_store.get_run_ids() == metadata_store.get_run_ids()


@pytest.mark.parametrize(
"metadata_store",
[SQLiteMetadataStore],
indirect=True,
)
@pytest.mark.parametrize("metadata_store", PERSISTENT_IMPLEMENTATIONS, indirect=True)
def test_load_from(metadata_store): # noqa: F811
cache_key = _mock_cache_key()
data_version = "foo-a"
Expand Down
15 changes: 5 additions & 10 deletions tests/caching/result_store/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# a pytest fixture automatically provided to tests
from .test_base import result_store # noqa: F401

# implementations that in-memory result store can `.persist_to()` and `.load_from()`
PERSISTENT_IMPLEMENTATIONS = [FileResultStore]


def _store_size(memory_store: InMemoryResultStore) -> int:
return len(memory_store._results)
Expand Down Expand Up @@ -88,11 +91,7 @@ def test_delete_all(memory_store):
assert _store_size(memory_store) == 0


@pytest.mark.parametrize(
"result_store",
[FileResultStore],
indirect=True,
)
@pytest.mark.parametrize("result_store", PERSISTENT_IMPLEMENTATIONS, indirect=True)
def test_persist_to(result_store, memory_store): # noqa: F811
data_version = "foo"
result = "bar"
Expand All @@ -109,11 +108,7 @@ def test_persist_to(result_store, memory_store): # noqa: F811
assert memory_store.get(data_version) == result_store.get(data_version)


@pytest.mark.parametrize(
"result_store",
[FileResultStore],
indirect=True,
)
@pytest.mark.parametrize("result_store", PERSISTENT_IMPLEMENTATIONS, indirect=True)
def test_load_from(result_store): # noqa: F811
data_version = "foo"
result = "bar"
Expand Down

0 comments on commit 13a0ec3

Please sign in to comment.