Skip to content

Commit

Permalink
Include replica_type in JSONL manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc committed Apr 20, 2024
1 parent 02e863b commit d057e78
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/azul/service/manifest_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ def _all_replicas(self) -> Iterable[JSON]:
replica_id = replica.meta.id
if replica_id not in emitted_replica_ids:
num_new_replicas += 1
yield replica.contents.to_dict()
yield replica.to_dict()
# Note that this will be zero for replicas that use implicit
# hubs, in which case there are actually many hubs
explicit_hub_count = len(replica.hub_ids)
Expand Down Expand Up @@ -2113,6 +2113,10 @@ def create_file(self) -> tuple[str, Optional[str]]:
os.close(fd)
with open(path, 'w') as f:
for replica in self._all_replicas():
json.dump(replica, f)
entry = {
'contents': replica['contents'],
'type': replica['replica_type']
}
json.dump(entry, f)
f.write('\n')
return path, None
26 changes: 16 additions & 10 deletions test/service/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,15 +1317,18 @@ def test_manifest_content_disposition_header(self):
@manifest_test
def test_verbatim_jsonl_manifest(self):
expected = [
bundle.metadata_files[d]
{
'type': replica_type,
'contents': bundle.metadata_files[key],
}
for bundle in map(self._load_canned_bundle, self.bundles())
for d in [
'links.json',
'cell_suspension_0.json',
'project_0.json',
'sequence_file_0.json',
'sequence_file_1.json',
'specimen_from_organism_0.json'
for replica_type, key in [
('links', 'links.json'),
('cell_suspension', 'cell_suspension_0.json'),
('project', 'project_0.json'),
('file', 'sequence_file_0.json'),
('file', 'sequence_file_1.json'),
('sample', 'specimen_from_organism_0.json')
]
]
response = self._get_manifest(ManifestFormat.verbatim_jsonl, {})
Expand Down Expand Up @@ -2058,8 +2061,11 @@ def test_verbatim_jsonl_manifest(self):
response = self._get_manifest(ManifestFormat.verbatim_jsonl, filters={})
self.assertEqual(200, response.status_code)
expected = [
entity
{
'type': 'anvil_' + entity_ref.entity_type,
'contents': entity,
}
for bundle in self.bundles()
for entity in self._load_canned_bundle(bundle).entities.values()
for entity_ref, entity in self._load_canned_bundle(bundle).entities.items()
]
self._assert_jsonl(expected, response)

0 comments on commit d057e78

Please sign in to comment.