def from_dict()

in collection_manager/collection_manager/entities/Collection.py [0:0]


    def from_dict(properties: dict):
        """
        Accepting either `variable` or `variables` from the configmap
        """
        # Inhibiting this for now...
        # logger.debug(f'Incoming properties dict: {properties}')

        try:
            date_to = datetime.fromisoformat(properties['to']) if 'to' in properties else None
            date_from = datetime.fromisoformat(properties['from']) if 'from' in properties else None

            store_type = properties.get('storeType')

            slices = properties.get('slices', {}).items()

            preprocess = json.dumps(properties['preprocess']) if 'preprocess' in properties else None
            extra_processors = json.dumps(properties['processors']) if 'processors' in properties else None
            config = properties['config'] if 'config' in properties else None

            projection = properties['projection'] if 'projection' in properties else None

            collection = Collection(dataset_id=properties['id'],
                                    projection=projection,
                                    dimension_names=frozenset(Collection.__decode_dimension_names(properties['dimensionNames'])),
                                    slices=frozenset(slices),
                                    path=properties['path'],
                                    historical_priority=properties['priority'],
                                    forward_processing_priority=properties.get('forward-processing-priority', None),
                                    date_to=date_to,
                                    date_from=date_from,
                                    preprocess=preprocess,
                                    processors=extra_processors,
                                    group=properties.get('group'),
                                    store_type=store_type,
                                    config=config
                                    )
            return collection
        except KeyError as e:
            raise MissingValueCollectionError(missing_value=e.args[0])