Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Release beta 26
Browse files Browse the repository at this point in the history
# Conflicts:
#	setup.py
  • Loading branch information
hannes-ucsc committed Aug 4, 2020
2 parents afe97ab + 5de2135 commit ebd6607
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="hca-metadata-api",
version="1.0b25",
version="1.0b26",
license='MIT',
install_requires=[
"dataclasses >= 0.6;python_version<'3.7'"
Expand Down
28 changes: 16 additions & 12 deletions src/humancellatlas/data/metadata/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dataclasses import (
dataclass,
field,
fields,
)

from humancellatlas.data.metadata.age_range import AgeRange
Expand Down Expand Up @@ -582,27 +583,30 @@ class ImagingPreparationProtocol(Protocol):
pass


@dataclass
@dataclass(init=False)
class ManifestEntry:
content_type: str
json: JSON = field(init=False, repr=False)
content_type: str = field(init=False)
crc32c: str
indexed: bool
name: str
s3_etag: str
sha1: str
sha256: str
size: int
url: str # only populated if bundle was requested with `directurls` or `directurls` set
uuid: UUID4
# only populated if bundle was requested with `directurls` or `directurls` set
url: Optional[str] = field(init=False)
uuid: UUID4 = field(init=False)
version: str

@classmethod
def from_json(cls, json: JSON):
kwargs = dict(json)
kwargs['content_type'] = kwargs.pop('content-type')
kwargs['uuid'] = UUID4(json['uuid'])
kwargs.setdefault('url')
return cls(**kwargs)
def __init__(self, json: JSON):
self.json = json
self.content_type = json['content-type']
self.url = json.get('url')
self.uuid = UUID4(json['uuid'])
for f in fields(self):
if f.init:
setattr(self, f.name, json[f.name])


@dataclass(init=False)
Expand Down Expand Up @@ -760,7 +764,7 @@ class Bundle:
def __init__(self, uuid: str, version: str, manifest: List[JSON], metadata_files: Mapping[str, JSON]):
self.uuid = UUID4(uuid)
self.version = version
self.manifest = {m.name: m for m in map(ManifestEntry.from_json, manifest)}
self.manifest = {m.name: m for m in map(ManifestEntry, manifest)}

def from_json(core_cls: Type[E], json_entities: List[JSON], **kwargs) -> MutableMapping[UUID4, E]:
entities = (core_cls.from_json(entity, **kwargs) for entity in json_entities)
Expand Down
8 changes: 8 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ def _assert_bundle(self, uuid, version, manifest, metadata_files,
ncbi_taxon_ids=None,
content_description=None):
bundle = Bundle(uuid, version, manifest, metadata_files)

# Every data file's manifest entry should be referenced by a metadata
# entity that describes the data file. id() is used to work around the
# fact that dict instances aren't hashable and to ensure that no
# redundant copies are made.
self.assertEqual(set(id(f.manifest_entry.json) for f in bundle.files.values()),
set(id(me) for me in manifest if not me['indexed']))

biomaterials = bundle.biomaterials.values()

if ncbi_taxon_ids is not None:
Expand Down

0 comments on commit ebd6607

Please sign in to comment.