MemoryHWMStore¶
- class etl_entities.hwm_store.memory_hwm_store.MemoryHWMStore¶
Simple in-memory (RAM) HWM Store.
Alias:
memoryNote
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() >>> retrieved_hwm = hwm_store.get_hwm("long_unique_name") >>> hwm_store.get_hwm("long_unique_name") # not found >>> hwm = ColumnIntHWM(name="long_unique_name", value=10) >>> hwm_store.set_hwm(hwm) >>> got_hwm = hwm_store.get_hwm("long_unique_name") # found >>> got_hwm == hwm True >>> hwm_store.clear() >>> hwm_store.get_hwm("long_unique_name") # not found again
- __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: ... print(HWMStoreStackManager.get_current()) SomeHWMStore(...) >>> HWMStoreStackManager.get_current() DefaultHWMStore()
- 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:
HWMHWM 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:
- hwm
HWM HWM object
- hwm
- 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)