コード例 #1
0
 def from_index(
     cls,
     field_types: CataloguedFieldTypes,
     hit: JSON,
     *,
     coordinates: Optional[
         DocumentCoordinates[CataloguedEntityReference]] = None
 ) -> 'Document':
     if coordinates is None:
         coordinates = DocumentCoordinates.from_hit(hit)
     if 'contents' in hit['_source']:
         file: JSON
         content_descriptions = [
             file['content_description']
             for file in hit['_source']['contents']['files']
         ]
         assert [] not in content_descriptions, 'Found empty list as content_description value'
     source = cls.translate_fields(hit['_source'],
                                   field_types[coordinates.entity.catalog],
                                   forward=False)
     # noinspection PyArgumentList
     # https://youtrack.jetbrains.com/issue/PY-28506
     self = cls(coordinates=coordinates,
                version=hit.get('_version', 0),
                contents=source.get('contents'),
                **cls._from_source(source))
     return self
コード例 #2
0
ファイル: aggregate.py プロジェクト: DataBiosphere/azul
 def _transform_entity(self, entity: JSON) -> JSON:
     fqid = entity['uuid'], entity['version']
     return dict(size=(fqid, entity['size']),
                 file_format=entity['file_format'],
                 file_source=entity['file_source'],
                 is_intermediate=entity['is_intermediate'],
                 count=(fqid, 1),
                 content_description=entity['content_description'],
                 matrix_cell_count=(fqid, entity.get('matrix_cell_count')))
コード例 #3
0
ファイル: document.py プロジェクト: DataBiosphere/azul
 def from_json(cls,
               *,
               coordinates: C,
               document: JSON,
               version: Optional[InternalVersion],
               **kwargs
               ) -> 'Aggregate':
     self = super().from_json(coordinates=coordinates,
                              document=document,
                              version=version,
                              num_contributions=document['num_contributions'],
                              sources=map(DocumentSource.from_json, document['sources']),
                              bundles=document.get('bundles'))
     assert isinstance(self, Aggregate)
     return self
コード例 #4
0
ファイル: document.py プロジェクト: DataBiosphere/azul
 def from_json(cls,
               *,
               coordinates: C,
               document: JSON,
               version: Optional[InternalVersion],
               **kwargs,
               ) -> 'Document':
     # noinspection PyArgumentList
     # https://youtrack.jetbrains.com/issue/PY-28506
     self = cls(coordinates=coordinates,
                version=version,
                contents=document.get('contents'),
                **kwargs)
     assert document['entity_id'] == self.entity.entity_id
     return self
コード例 #5
0
 def get_manifest(self, state: JSON) -> JSON:
     partition = ManifestPartition.from_json(
         state[self.partition_state_key])
     auth = state.get('authentication')
     result = self.service.get_manifest(
         format_=ManifestFormat(state['format_']),
         catalog=state['catalog'],
         filters=Filters.from_json(state['filters']),
         partition=partition,
         authentication=None
         if auth is None else Authentication.from_json(auth),
         object_key=state['object_key'])
     if isinstance(result, ManifestPartition):
         assert not result.is_last, result
         return {**state, self.partition_state_key: result.to_json()}
     elif isinstance(result, Manifest):
         return {
             # The presence of this key terminates the step function loop
             self.manifest_state_key:
             result.to_json()
         }
     else:
         assert False, type(result)
コード例 #6
0
 def _from_source(cls, source: JSON) -> Mapping[str, Any]:
     return dict(super()._from_source(source),
                 num_contributions=source['num_contributions'],
                 bundles=source.get('bundles'))
コード例 #7
0
 def _deep_get(self, d: JSON, *path: str) -> Optional[JSON]:
     if d is not None and path:
         key, *path = path
         return self._deep_get(d.get(key), *path)
     else:
         return d
コード例 #8
0
 def drs_path(self, manifest_entry: JSON) -> Optional[str]:
     return manifest_entry.get('drs_path')