datamodel.py¶
This module contains helper functions to serialize blast data into a flat science payload to be delivered by the blast web API.
- class api.datamodel.DataModelComponent(prefix: str, query: dict, model: Model, serializer: Serializer)[source]¶
A dataclass to store all information on how to serialise a blast model into the blast science payload.
- prefix¶
What will be appended to the column name in the blast science payload
- Type:
str
- query¶
A django query that will uniquely identify the data for the blast science payload
- Type:
dict
- model¶
The blast model that the query will be passed to
- Type:
django.db.models.Model
- serializer¶
associated with the model
- Type:
rest_framework.serializers.Serializer
- api.datamodel.serialize_blast_science_data(datamodel: List[DataModelComponent]) dict [source]¶
Serializes all data associated with a transient into a flat structure.
- Parameters:
datamodel – (List[DataModelComponent]): datamodel to be serialized.
- Returns:
- Flat dictionary containing science data fields and
values.
- Return type:
science_payload
- api.datamodel.unpack_component_groups(component_groups: List[List[DataModelComponent]]) List[DataModelComponent] [source]¶
Unpacks list of datamodel component groups into a flat structure
- Parameters:
component_groups (List[List[DataModelComponent]]) – list of groups to be unpacked
- Returns:
flattened list of components
- Return type:
flat_components (List[DataModelComponent])