tableserializer package
Subpackages
- tableserializer.serializer module
- Submodules
- tableserializer.serializer.metadata module
- tableserializer.serializer.schema module
- tableserializer.serializer.serializer module
- tableserializer.serializer.table module
- Module contents
- tableserializer.table module
Submodules
tableserializer.recipe module
- class tableserializer.recipe.SerializationRecipe(recipe: str, identifier: str = None)[source]
Bases:
objectA SerializationRecipe details the structure of the table serialization.
- Parameters:
recipe (str) – String representation of the overall structure of the serialization with placeholders that are dynamically filled in on a per-table basis.
identifier (Optional[str]) – Optional identifier for the table.
- cook_recipe(schema_contents: str = None, metadata_contents: str = None, table_contents: str = None) str[source]
Fill-in the values for the placeholder values.
- Parameters:
schema_contents (str) – Schema contents to fill in.
metadata_contents (str) – Metadata contents to fill in.
table_contents (str) – Table contents to fill in.
- Returns:
Table serialization according to the schema.
- Return type:
str
tableserializer.kitchen module
- class tableserializer.kitchen.ExperimentalSerializerKitchen[source]
Bases:
objectCentral class for managing serialization components and custom extensions for experiments.
- register_schema_serializer_class(schema_serializer_class: Type[SchemaSerializer]) None[source]
Register a custom schema serializer class to the kitchen.
- Parameters:
schema_serializer_class (Type[SchemaSerializer]) – Schema serializer class to register.
- Return type:
None
- register_raw_table_serializer_class(table_serializer_class: Type[RawTableSerializer]) None[source]
Register a custom raw table serializer class to the kitchen.
- Parameters:
table_serializer_class (Type[RawTableSerializer]) – Raw table serializer class to register.
- Return type:
None
- register_metadata_serializer_class(metadata_serializer_class: Type[MetadataSerializer]) None[source]
Register a custom metadata serializer class to the kitchen.
- Parameters:
metadata_serializer_class – Metadata serializer class to register.
- Return type:
None
- register_row_sampler_class(row_sampler_class: Type[RowSampler]) None[source]
Register a custom row sampler class to the kitchen.
- Parameters:
row_sampler_class – Row sampler class to register.
- Return type:
None
- register_table_preprocessor_class(table_preprocessor_class: Type[TablePreprocessor]) None[source]
Register a custom table preprocessor class to the kitchen.
- Parameters:
table_preprocessor_class – Table preprocessor class to register.
- Return type:
None
- create_schema_serializer(schema_serializer_name: str, **kwargs: Any) SchemaSerializer[source]
Create a SchemaSerializer for the given schema serializer name. This assumes that a SchemaSerializer with the supplied name is registered.
- Parameters:
schema_serializer_name (str) – Name of the registered schema serializer class that should be instantiated.
kwargs (Any) – Constructor arguments for instantiating the SchemaSerializer class.
- Returns:
SchemaSerializer instance.
- Return type:
- create_table_serializer(raw_table_serializer_name: str, **kwargs: Any) RawTableSerializer[source]
Create a RawTableSerializer for the given table serializer name. This assumes that a RawTableSerializer with the supplied name is registered.
- Parameters:
raw_table_serializer_name (str) – Name of the registered RawTableSerializer class that should be instantiated.
kwargs (Any) – Constructor arguments for instantiating the RawTableSerializer class.
- Returns:
RawTableSerializer instance.
- Return type:
- create_metadata_serializer(metadata_serializer_name: str, **kwargs: Any) MetadataSerializer[source]
Create a MetadataSerializer for the given metadata serializer name. This assumes that a MetadataSerializer with the supplied name is registered.
- Parameters:
metadata_serializer_name (str) – Name of the registered MetadataSerializer class that should be instantiated.
kwargs (Any) – Constructor arguments for instantiating the MetadataSerializer class.
- Returns:
MetadataSerializer instance.
- Return type:
- create_row_sampler(row_sampler_name: str, rows_to_sample: int = 10, **kwargs: Any) RowSampler[source]
Create a RowSampler for the given row sampler name. This assumes that a RowSampler with the supplied name is registered.
- Parameters:
row_sampler_name (str) – Name of the registered RowSampler class that should be instantiated.
rows_to_sample (int) – Number of rows to sample.
kwargs (Any) – Constructor arguments for instantiating the RowSampler class.
- Returns:
RowSampler instance.
- Return type:
- create_table_preprocessor(table_preprocessor_name: str, **kwargs: Any) TablePreprocessor[source]
Create a TablePreprocessor for the given table preprocessor name. This assumes that a TablePreprocessor with the supplied name is registered.
- Parameters:
table_preprocessor_name (str) – Name of the registered TablePreprocessor class that should be instantiated.
kwargs (Any) – Constructor arguments for instantiating the TablePreprocessor class.
- Returns:
TablePreprocessor instance.
- Return type:
- static jar_up_as_json(serializer: Serializer) str[source]
Create a JSON representation of the given serializer. This representation captures the full configuration of the serializer, allowing instantiating an equal serializer.
- Parameters:
serializer (Serializer) – Serializer to jar up as JSON.
- Returns:
JSON representation of the given serializer.
- Return type:
str
- unjar_from_json(serializer_json: str) Serializer[source]
Create a serializer instance from a JSON representation of a serializer.
- Parameters:
serializer_json (str) – JSON representation of a serializer.
- Returns:
Serializer instance.
- Return type:
- create_serializers(recipes: List[SerializationRecipe], metadata_serializers: List[MetadataSerializer], schema_serializers: List[SchemaSerializer], table_serializers: List[RawTableSerializer], row_samplers: List[RowSampler], table_preprocessor_constellations: List[List[TablePreprocessor]]) List[Serializer][source]
Create serializers with different parameter configurations.
- Parameters:
recipes (List[SerializationRecipe]) – List of recipes for which to create serializer instances.
metadata_serializers (List[MetadataSerializer]) – List of metadata serializers for which to create serializer instances.
schema_serializers (List[SchemaSerializer]) – List of schema serializers for which to create serializer instances.
table_serializers (List[RawTableSerializer]) – List of raw table serializers for which to create serializer instances.
row_samplers (List[RowSampler]) – List of row samplers for which to create serializer instances.
table_preprocessor_constellations (List[List[TablePreprocessor]]) – List of table preprocessor constellations for which to create serializer instances.
- Returns:
A list of serializers for all possible combinations of components.
- Return type:
List[Serializer]
- save_serializer_experiment_configurations(serializers: List[Serializer], base_folder: str) None[source]
Create a folder structure within a base folder and save configurations of the provided serializers into this structure.
- Parameters:
serializers (List[Serializer]) – Serializers that are saved.
base_folder (str) – Base folder that configuration files will be saved into.
- Returns:
None
- Return type:
None
- get_serializers_from_dir(base_folder: str) List[Tuple[str, Serializer]][source]
Get a list of serializers that have been saved in a base folder.
- Parameters:
base_folder – Base folder where
- Returns:
A tuple (experiment_folder, )
- run_experiments_with_serializers(base_folder: str, experiment_callback: Callable) None[source]
Provide a callback function and run experiments over all serializers saved in the base folder.
- Parameters:
base_folder (str) – Base folder that serializer configuration files reside in.
experiment_callback (Callable) – Callback function that is invoked with a tuple (experiment_folder, serializer) (Tuple[str, Serializer]) for each experiment. The callback function is provided the experiment folder as string value and the associated Serializer.
- Returns:
None
- Return type:
None