def from_json_dict(cls, dict_data: Dict[Text, Any]) -> Any: artifact_type = metadata_store_pb2.ArtifactType() json_format.Parse(json.dumps(dict_data['type']), artifact_type) type_cls = artifact_utils.get_artifact_type_class(artifact_type) artifacts = list( Artifact.from_json_dict(a) for a in dict_data['artifacts']) producer_component_id = dict_data.get('producer_component_id', None) output_key = dict_data.get('output_key', None) return Channel(type=type_cls, artifacts=artifacts, producer_component_id=producer_component_id, output_key=output_key)
def parse_artifact_dict(json_str: Text) -> Dict[Text, List[Artifact]]: """Parse a dict from key to list of Artifact from its json format.""" tfx_artifacts = {} for k, l in json.loads(json_str).items(): tfx_artifacts[k] = [Artifact.from_json_dict(v) for v in l] return tfx_artifacts