ds_provider_mock_py_lib.dataset.engines.read¶
File: read.py
Region: ds_provider_mock_py_lib/dataset/engines
Read engine for paginated mock execution.
This engine is intentionally stateful:
- output accumulates collected rows page-by-page
- checkpoint tracks incremental watermark and pagination resume state
- metadata records batch, page, and op counts
Example
>>> from ds_provider_mock_py_lib.dataset.engines.read import ReadEngine
>>> from ds_provider_mock_py_lib.dataset.settings import MockDatasetSettings
>>> from ds_provider_mock_py_lib.linked_service import MockBackend, MockLinkedServiceSettings
>>> engine = ReadEngine(
... connection=MockBackend(MockLinkedServiceSettings()),
... settings=MockDatasetSettings(row_count=2),
... dataset_name="mock-ds",
... provider_type="ds.resource.dataset.mock",
... )
>>> engine.execute(checkpoint={})
>>> len(engine.output.index)
2
Attributes¶
Classes¶
Execute mock reads including pagination, resume, and failure injection. |
Module Contents¶
- ds_provider_mock_py_lib.dataset.engines.read.logger¶
- class ds_provider_mock_py_lib.dataset.engines.read.ReadEngine[source]¶
Execute mock reads including pagination, resume, and failure injection.
- dataset_name: str¶
- provider_type: str¶
- output: pandas.DataFrame¶
- metadata: dict[str, Any]¶
- _emitted_ops: list[str] = []¶
- execute(checkpoint: dict[str, Any] | None = None) None[source]¶
Execute read flow and update
output/checkpointstate.- Parameters:
checkpoint – Existing checkpoint state to continue from.
- Raises:
ReadError – If settings are invalid or a wrapped backend failure occurs.
ConnectionError – If dataset-level injection is configured as a connection error.
MockBackendError – If the mock backend raises and the caller must wrap it.
- _resolve_start() tuple[int, int, bool][source]¶
Resolve batch, first page, and whether this call is a resume.
- Returns:
(batch, first_page, resumed).- Raises:
ReadError – If a stored pagination cursor cannot be decoded.
- _save_pagination(*, batch: int, page: int) None[source]¶
Persist pagination resume state without advancing the watermark.
- _assign_output(pages: list[pandas.DataFrame]) None[source]¶
Assign concatenated pages to
output, including rows already read on failure.- Parameters:
pages – Pages collected so far in this read.
- _finish_complete(*, batch: int, pages: list[pandas.DataFrame], total_pages: int, resumed: bool) None[source]¶
Complete a successful read of the configured scope.
- Parameters:
batch – Completed batch number written to the incremental watermark.
pages – Pages collected during this read.
total_pages – Page count for the current batch.
resumed – Whether this call continued from a pagination cursor.