ds_protocol_graphql_py_lib.dataset.incremental.strategies

File: __init__.py Region: ds_protocol_graphql_py_lib/dataset/incremental/strategies

Importing this package registers all built-in incremental rulesets.

Submodules

Classes

NoIncrementalRules

Used by Paginate when read.incremental is unset: prepare, observe and commit do nothing.

WatermarkRules

Resume on a caller-persisted high-watermark.

Package Contents

class ds_protocol_graphql_py_lib.dataset.incremental.strategies.NoIncrementalRules[source]

Bases: ds_protocol_graphql_py_lib.dataset.incremental.rules.IncrementalRules

Used by Paginate when read.incremental is unset: prepare, observe and commit do nothing.

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 prepare sends; 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.

class ds_protocol_graphql_py_lib.dataset.incremental.strategies.WatermarkRules[source]

Bases: ds_protocol_graphql_py_lib.dataset.incremental.rules.IncrementalRules

Resume on a caller-persisted high-watermark.

Reads checkpoint["incremental"]["watermark"] on prepare. Tracks the max value seen so far in checkpoint["incremental"]["pending"] per page, and on commit advances the watermark to the max of the previous watermark, pending and 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 prepare sends; 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.

static _slice(checkpoint: dict[str, Any]) → dict[str, Any][source]
static _stored(slice_: dict[str, Any], key: str) → list[Any][source]
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.

static _to_stored(value: Any) → Any[source]

pd.Timestamp → ISO string so the checkpoint stays JSON-serialisable.

static _is_missing_scalar(value: Any) → bool[source]

True for None and pandas-missing scalars (NaN, NaT, NA).