ds_protocol_graphql_py_lib.dataset.incremental.strategies.watermark¶
File: watermark.py
Region: ds_protocol_graphql_py_lib/dataset/incremental/strategies/watermark
High-watermark incremental ruleset.
- Prepare
If
checkpoint["incremental"]["watermark"]is set, inject it into the GraphQL variablesettings.variable. Otherwise send the request unchanged (first run / full load).pendingis never sent.- Observe (every fetched page)
Set
checkpoint["incremental"]["pending"]to the max of its current value and the page’s values atwatermark_path, so it only ever goes up. The committed watermark does not move. A drain that fails after some pages leavespendingbehind, so the resumed drain, which starts after the saved cursor and never sees those pages, still commits their max.- Commit (full success only)
Set the watermark to the max of the previous watermark,
pendingand the values in this call’s output, and droppending. The watermark never moves backwards, and an empty resumed tail still promotespending.
Attributes¶
Classes¶
Resume on a caller-persisted high-watermark. |
Functions¶
|
Sort key: ISO date strings become |
Module Contents¶
- ds_protocol_graphql_py_lib.dataset.incremental.strategies.watermark._CHECKPOINT_KEY = 'incremental'¶
- ds_protocol_graphql_py_lib.dataset.incremental.strategies.watermark._WATERMARK_KEY = 'watermark'¶
- ds_protocol_graphql_py_lib.dataset.incremental.strategies.watermark._PENDING_KEY = 'pending'¶
- ds_protocol_graphql_py_lib.dataset.incremental.strategies.watermark._ISO_DATE¶
- ds_protocol_graphql_py_lib.dataset.incremental.strategies.watermark._comparable(value: Any) Any[source]¶
Sort key: ISO date strings become
pd.Timestamp; anything else is compared as is.
- class ds_protocol_graphql_py_lib.dataset.incremental.strategies.watermark.WatermarkRules[source]¶
Bases:
ds_protocol_graphql_py_lib.dataset.incremental.rules.IncrementalRulesResume on a caller-persisted high-watermark.
Reads
checkpoint["incremental"]["watermark"]on prepare. Tracks the max value seen so far incheckpoint["incremental"]["pending"]per page, and on commit advances the watermark to the max of the previous watermark,pendingand the output rows. Pandas-missing scalars (NaN,NaT,NA) are ignored. Does not clear pagination state — Paginate owns that.- prepare(request: ds_protocol_graphql_py_lib.dataset.request.GraphqlRequestSnapshot, checkpoint: dict[str, Any], settings: ds_protocol_graphql_py_lib.dataset.incremental.settings.IncrementalSettings | None) ds_protocol_graphql_py_lib.dataset.request.GraphqlRequestSnapshot[source]¶
Apply persisted state (the stored watermark) to the base request.
- observe(checkpoint: dict[str, Any], page: pandas.DataFrame, settings: ds_protocol_graphql_py_lib.dataset.incremental.settings.IncrementalSettings | None) None[source]¶
Record state from each fetched page for a later
commit.Never write the watermark
preparesends; use a separate checkpoint key (e.g.pending), so a resumed drain keeps the same lower bound.
- commit(checkpoint: dict[str, Any], output: pandas.DataFrame, settings: ds_protocol_graphql_py_lib.dataset.incremental.settings.IncrementalSettings | None) None[source]¶
Advance persisted state after a fully successful drain.
Does not clear
checkpoint["pagination"]— that is owned by Paginate.
- classmethod _values(frame: pandas.DataFrame, settings: ds_protocol_graphql_py_lib.dataset.incremental.settings.IncrementalSettings) list[Any][source]¶
- static _max(values: list[Any], settings: ds_protocol_graphql_py_lib.dataset.incremental.settings.IncrementalSettings) Any[source]¶
Max of
values, comparing ISO date strings as instants.