Home
Overview
Fundamentals
Glossary
Cheatsheet
API Reference
Quick Recipes
Deep Dive
Common Pitfalls and Gotchas
Persistent Storage
The definition of data slice paths and utilities for working with them.
A data slice path is a sequence of actions to perform on a DataSlice to obtain
a subslice. The set of allowed actions is small and simple:
* Getting the keys of a dict.
* Getting the values of a dict.
* Exploding a list.
* Getting an attribute of an entity.
The utility of a data slice path is that it specifies how to obtain a subslice
without doing it immediately. Thus, we have the possibility to gather more
information about the context of the subslice, for example, the schemas of its
ancestor data slices.
Not every data slice path is valid for every DataSlice. For example, we cannot
execute an action of exploding a list if we have a DICT DataSlice.
A Koda schema induces a set of data slice paths, namely those that are valid for
any DataSlice with that schema.
| Subcategory | Description |
|---|---|
| ActionParsingError | Raised when a data slice path cannot be parsed into an action + remainder. |
| DataSliceAction | An action to perform on a data slice. All instances are immutable. |
| DataSlicePath | A data slice path. |
| DictGetKeys | Action to get the keys of a Koda DICT data slice. |
| DictGetValues | Action to get the values of a Koda DICT data slice. |
| GetAttr | Action to get an attribute of a Koda entity data slice. |
| IncompatibleSchemaError | Raised when a data slice action is not compatible with a schema. |
| ListExplode | Action to explode a Koda LIST data slice. |
kd_ext.storage.data_slice_path.ActionParsingError(...)Raised when a data slice path cannot be parsed into an action + remainder.
kd_ext.storage.data_slice_path.DataSliceAction()An action to perform on a data slice. All instances are immutable.
kd_ext.storage.data_slice_path.DataSlicePath(actions: tuple[DataSliceAction, ...])Aliases:
A data slice path.
kd_ext.storage.data_slice_path.DictGetKeys()Action to get the keys of a Koda DICT data slice.
kd_ext.storage.data_slice_path.DictGetValues()Action to get the values of a Koda DICT data slice.
kd_ext.storage.data_slice_path.GetAttr(attr_name: str)Action to get an attribute of a Koda entity data slice.
kd_ext.storage.data_slice_path.IncompatibleSchemaError(...)Raised when a data slice action is not compatible with a schema.
kd_ext.storage.data_slice_path.ListExplode()Action to explode a Koda LIST data slice.
kd_ext.storage.data_slice_path.base64_encoded_attr_name(attr_name: str) -> strReturns the base64-encoded version of the given attr_name.
kd_ext.storage.data_slice_path.can_be_used_with_dot_syntax_in_data_slice_path_string(attr_name: str) -> boolReturns True iff attr_name is a valid Python identifier.
kd_ext.storage.data_slice_path.decode_base64_encoded_attr_name(b64_encoded_attr_name: str) -> strReturns the decoded version of the given base64-encoded attr_name.
kd_ext.storage.data_slice_path.generate_data_slice_paths_for_arbitrary_data_slice_with_schema(schema: kd.types.DataItem, max_depth: int) -> Generator[DataSlicePath, None, None]Yields all data slice paths for the given schema up to a maximum depth.
This function answers the following question:
For an arbitrary DataSlice ds with schema `schema`, what are the valid data
slice paths with at most `max_depth` actions?
This is a generator because the number of data slice paths can be very large,
or even infinite in the case of recursive schemas. The maximum depth value is
used to limit the data slice paths that are generated; alternatively, the
caller can decide when to stop the generation with custom logic.
Args:
schema: the Koda schema that induces the data slice paths.
max_depth: the maximum depth of the data slice paths to generate. Pass -1 to
generate all data slice paths.