MemoryHWMStore#

class etl_entities.hwm_store.memory_hwm_store.MemoryHWMStore#

Simple in-memory (RAM) HWM Store.

Alias: memory

Note

All values stored in MemoryHWMStore are gone after the Python interpreter is exited. This class should be used in tests only!

Examples

from etl_entities.hwm_store import MemoryHWMStore
from etl_entities.hwm import ColumnIntHWM

hwm_store = MemoryHWMStore()

# not found
retrieved_hwm = hwm_store.get_hwm("long_unique_name")
assert hwm_store.get_hwm("long_unique_name") is None

hwm = ColumnIntHWM(name="long_unique_name", value=10)
hwm_store.set_hwm(hwm_value)

# found
retrieved_hwm = hwm_store.get_hwm("long_unique_name")
assert retrieved_hwm == hwm

hwm_store.clear()
# not found again
assert hwm_store.get_hwm("long_unique_name") is None
__enter__()#

HWM store context manager.

Enter this context to use this HWM store instance as current one (instead default).

Examples

from etl_entities.hwm_store import HWMStoreStackManager

with SomeHWMStore(...) as hwm_store:
    assert HWMStoreStackManager.get_current() == hwm_store

assert HWMStoreStackManager.get_current() == default_hwm_store
clear() None#

Clears all stored HWM values.

get_hwm(name: str) HWM | None#

Get HWM by name from HWM store.

Parameters:
namestr

HWM unique name

Returns:
HWM

HWM object, if it exists in HWM store, or None

Examples

hwm = hwm_store.get_hwm(hwm_unique_name)
set_hwm(hwm: HWM) None#

Save HWM object to HWM Store.

Parameters:
hwmHWM

HWM object

Returns:
Any

HWM location, like URL of file path. Result type is implementation-specific.

Examples

from etl_entities.hwm import ColumnIntHWM

hwm = ColumnIntHWM(name=..., value=...)
hwm_location = hwm_store.set_hwm(hwm)