ds_provider_unimicro_py_lib.utils¶
File: __init__.py
Region: ds_provider_unimicro_py_lib/utils
Shared utilities for the Unimicro provider.
Submodules¶
Attributes¶
Functions¶
|
Restrict the output to |
|
Build a checkpoint dictionary to track the last successfully read page. |
|
Build the provider-specific incremental filter. |
|
Determine the greatest incremental value (last modified date) from the fetched records. |
|
Build the cartesian product of the |
|
Normalize an int, |
Package Contents¶
- ds_provider_unimicro_py_lib.utils.project_fields(output: pandas.DataFrame, fields: list[str] | None) pandas.DataFrame[source]¶
Restrict the output to
fields(ignoring names that are not present), if configured.- Parameters:
output – The normalized output dataframe.
fields – Column names to keep, in the requested order.
Noneor empty keeps everything.
- Returns:
The projected dataframe, or the input unchanged when
fieldsis not set. If none of the requested fields exist, an empty frame with the same index is returned.- Return type:
pd.DataFrame
- ds_provider_unimicro_py_lib.utils.build_checkpoint(last_loaded_records: int | None, last_modified_date: str | None) dict[str, Any][source]¶
Build a checkpoint dictionary to track the last successfully read page.
- Parameters:
last_loaded_records (int | None) – The number of records that were successfully read (records to skip).
last_modified_date (str | None) – The last modified date to include in the checkpoint.
- Returns:
A checkpoint dictionary containing the incremental and pagination values.
- Return type:
dict[str, Any]
- ds_provider_unimicro_py_lib.utils.build_incremental_filter(last_modified_date: str) str[source]¶
Build the provider-specific incremental filter.
- Parameters:
last_modified_date – Watermark; only records created or updated after it are selected.
- Returns:
Filter clause matching records with
CreatedAtorUpdatedAtafter the watermark.- Return type:
str
- ds_provider_unimicro_py_lib.utils.greatest_incremental_value(records: pandas.DataFrame) str | None[source]¶
Determine the greatest incremental value (last modified date) from the fetched records.
- Parameters:
records (pd.DataFrame) – The dataframe of all fetched records.
- Returns:
The greatest ISO-8601 timestamp found in
CreatedAt/UpdatedAt, or None if there are no valid timestamps.- Return type:
str | None
- ds_provider_unimicro_py_lib.utils.RESERVED_PARAMS¶
- ds_provider_unimicro_py_lib.utils.expand_combinations(expand: dict[str, list[int] | int | str] | None) list[dict[str, int]][source]¶
Build the cartesian product of the
expandvalues.- Parameters:
expand – Mapping of parameter name to an int, list of ints, or
start-endrange string.- Returns:
One parameter mapping per request.
[{}]whenexpandis empty orNone, so callers always make at least one request.- Return type:
list[dict[str, int]]