-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1839 from 4dn-dcic/drs
Implement DRS for Fourfront
- Loading branch information
Showing
7 changed files
with
307 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[tool.poetry] | ||
# Note: Various modules refer to this system as "encoded", not "fourfront". | ||
name = "encoded" | ||
version = "6.3.0" | ||
version = "6.4.0" | ||
description = "4DN-DCIC Fourfront" | ||
authors = ["4DN-DCIC Team <[email protected]>"] | ||
license = "MIT" | ||
|
@@ -47,7 +47,7 @@ colorama = "0.3.3" | |
# we get odd 'pyo3_runtime.PanicException: Python API call failed' error on import | ||
# of cryptography.hazmat.bindings._rust in cryptography package. 2023-04-21. | ||
cryptography = "39.0.2" | ||
dcicsnovault = "^10.0.2" | ||
dcicsnovault = "^10.0.4" | ||
dcicutils = "^7.5.0" | ||
elasticsearch = "7.13.4" | ||
elasticsearch-dsl = "^7.0.0" # TODO: port code from cgap-portal to get rid of uses | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import pytest | ||
|
||
|
||
pytestmark = [pytest.mark.setone, pytest.mark.working] | ||
|
||
|
||
DRS_PREFIX = f'/ga4gh/drs/v1/objects' | ||
|
||
|
||
@pytest.fixture | ||
def mcool_file_json(award, experiment, lab, file_formats): | ||
""" Duplicating fixture since these live in another file that is not shared """ | ||
item = { | ||
'award': award['@id'], | ||
'lab': lab['@id'], | ||
'file_format': file_formats.get('mcool').get('uuid'), | ||
'md5sum': '00000000000000000000000000000000', | ||
'content_md5sum': '00000000000000000000000000000000', | ||
'filename': 'my.cool.mcool', | ||
'status': 'uploaded', | ||
} | ||
return item | ||
|
||
|
||
@pytest.fixture | ||
def file(testapp, award, experiment, lab, file_formats): | ||
""" Duplicating fixture since these live in another file that is not shared """ | ||
item = { | ||
'award': award['@id'], | ||
'lab': lab['@id'], | ||
'file_format': file_formats.get('fastq').get('uuid'), | ||
'md5sum': '00000000000000000000000000000000', | ||
'content_md5sum': '00000000000000000000000000000000', | ||
'filename': 'my.fastq.gz', | ||
'status': 'uploaded', | ||
} | ||
res = testapp.post_json('/file_fastq', item) | ||
return res.json['@graph'][0] | ||
|
||
|
||
def validate_drs_conversion(drs_obj, meta, uri=None): | ||
""" Validates drs object structure against the metadata in the db """ | ||
assert drs_obj['id'] == meta['@id'] | ||
assert drs_obj['created_time'] == meta['date_created'] | ||
assert drs_obj['drs_id'] == meta['accession'] | ||
assert drs_obj['self_uri'] == f'drs://localhost:80{meta["@id"]}@@drs' if not uri else uri | ||
assert drs_obj['version'] == meta['md5sum'] | ||
assert drs_obj['name'] == meta['filename'] | ||
assert drs_obj['aliases'] == [meta['uuid']] | ||
|
||
|
||
def test_processed_file_drs_view(testapp, mcool_file_json): | ||
""" Tests that processed mcool gives a valid DRS response """ | ||
meta = testapp.post_json('/file_processed', mcool_file_json).json['@graph'][0] | ||
drs_meta = testapp.get(meta['@id'] + '@@drs').json | ||
validate_drs_conversion(drs_meta, meta) | ||
drs_meta = testapp.get(f'{DRS_PREFIX}/{meta["uuid"]}').json | ||
validate_drs_conversion(drs_meta, meta, uri=f'{DRS_PREFIX}/{meta["uuid"]}') | ||
|
||
|
||
def test_fastq_file_drs_view(testapp, file): | ||
""" Tests that a fastq file has valid DRS response """ | ||
drs_meta = testapp.get(file['@id'] + '@@drs').json | ||
validate_drs_conversion(drs_meta, file) | ||
drs_meta = testapp.get(f'{DRS_PREFIX}/{file["uuid"]}').json | ||
validate_drs_conversion(drs_meta, file, uri=f'{DRS_PREFIX}/{file["uuid"]}') | ||
|
||
|
||
def test_fastq_file_drs_access(testapp, file): | ||
""" Tests that access URLs are retrieved successfully """ | ||
drs_meta = testapp.get(file['@id'] + '@@drs').json | ||
drs_object_uri = drs_meta['drs_id'] | ||
drs_object_download = testapp.get(f'/ga4gh/drs/v1/objects/{drs_object_uri}/access/').json | ||
assert drs_object_download == { | ||
'url': f'https://localhost:80/{drs_object_uri}/@@download' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters