pdstools.explanations.ContextOperations¶
Context-related operations for querying the unique contexts in an aggregates set.
Classes¶
Context-related operations for querying unique contexts. |
Module Contents¶
- class ContextOperations(explanations: pdstools.explanations.Explanations.Explanations)¶
Bases:
pdstools.utils.namespaces.LazyNamespaceContext-related operations for querying unique contexts.
- Parameters:
explanations (Explanations) – Parent instance providing the contextual data.
- dependency_group = 'explanations'¶
- explanations¶
- file_batch_limit¶
- property context_keys: list[str]¶
Context key column names, for example
["pyChannel", "pyDirection"].
- get_df(context_infos: list[dict[str, str]] | None = None, with_partition_col: bool = False) polars.DataFrame¶
Return unique contexts as a DataFrame, optionally filtered.
- Parameters:
- Returns:
Unique contexts with one row per context.
- Return type:
pl.DataFrame
- get_list(context_infos: list[dict[str, str]] | None = None, with_partition_col: bool = False) list[dict[str, str]]¶
Return unique contexts as dictionaries, optionally filtered.
- Parameters:
- Returns:
Unique contexts represented as dictionaries.
- Return type:
- write_batches(target_dir: str | pathlib.Path) None¶
Write the per-batch parquet files and the context-to-batch mapping.
The report renders one page per batch, so contexts are chunked into groups of
file_batch_limit. Both artifacts come out of the same assignment and cannot disagree:unique_contexts.jsontells the report subprocess which contexts belong on which page, and eachbatches/BATCH_<n>.parquetholds exactly that page’s rows.Nothing is cached — the files are rewritten on every call, so a change of dataset or of
PDSTOOLS_FILE_BATCH_LIMITtakes effect.- Parameters:
target_dir (str | Path) – Directory to write
unique_contexts.jsonandbatches/into.- Return type:
None