diff --git a/src/igvfd/schemas/changelogs/software_version.md b/src/igvfd/schemas/changelogs/software_version.md index a6061fa97..b1a68d8d9 100644 --- a/src/igvfd/schemas/changelogs/software_version.md +++ b/src/igvfd/schemas/changelogs/software_version.md @@ -1,5 +1,12 @@ ## Changelog for *`software_version.json`* +### Schema version 6 + +* Require `award`. +* Require `lab`. +* Require `software`. +* Require `version`. + ### Schema version 5 * Require `release_timestamp` for any objects with `released` or `archived` status. diff --git a/src/igvfd/schemas/software_version.json b/src/igvfd/schemas/software_version.json index 862ce1c89..d71f70e34 100644 --- a/src/igvfd/schemas/software_version.json +++ b/src/igvfd/schemas/software_version.json @@ -24,6 +24,12 @@ ] } ], + "required": [ + "award", + "lab", + "software", + "version" + ], "identifyingProperties": [ "uuid", "aliases", @@ -54,7 +60,7 @@ }, "properties": { "schema_version": { - "default": "5" + "default": "6" }, "software": { "title": "Software", diff --git a/src/igvfd/tests/fixtures/schemas/software.py b/src/igvfd/tests/fixtures/schemas/software.py index 3d758f0db..4df652da3 100644 --- a/src/igvfd/tests/fixtures/schemas/software.py +++ b/src/igvfd/tests/fixtures/schemas/software.py @@ -15,6 +15,19 @@ def software(testapp, lab, award): return testapp.post_json('/software', item, status=201).json['@graph'][0] +@pytest.fixture +def software_graphreg(testapp, lab, award): + item = { + 'award': award['@id'], + 'lab': lab['@id'], + 'title': 'Graphreg', + 'name': 'graphreg', + 'description': 'GraphReg (Chromatin interaction aware gene regulatory modeling with graph attention networks) is a graph neural network based gene regulation model.', + 'source_url': 'https://genome.cshlp.org/content/32/5/930.full' + } + return testapp.post_json('/software', item, status=201).json['@graph'][0] + + @pytest.fixture def software_v1(software): item = software.copy() diff --git a/src/igvfd/tests/fixtures/schemas/software_version.py b/src/igvfd/tests/fixtures/schemas/software_version.py index 1cb870398..48d9bd07a 100644 --- a/src/igvfd/tests/fixtures/schemas/software_version.py +++ b/src/igvfd/tests/fixtures/schemas/software_version.py @@ -51,3 +51,9 @@ def software_version_v3(software_version_v2): 'description': '', }) return item + + +@pytest.fixture +def software_version_v5(testapp): + item = {} + return item diff --git a/src/igvfd/tests/test_upgrade_software_version.py b/src/igvfd/tests/test_upgrade_software_version.py index 94e10c98b..099e3c265 100644 --- a/src/igvfd/tests/test_upgrade_software_version.py +++ b/src/igvfd/tests/test_upgrade_software_version.py @@ -30,3 +30,22 @@ def test_software_version_upgrade_3_4(upgrader, software_version_v3): current_version='3', target_version='4') assert value['schema_version'] == '4' assert 'description' not in value + + +def test_software_version_upgrade_5_6(upgrader, software_version_v5): + value = upgrader.upgrade( + 'software_version', software_version_v5, + current_version='5', target_version='6') + assert value['schema_version'] == '6' + assert value['software'] == '/software/graphreg/' + assert value['version'] == 'v1.0.0' + assert value['notes'].endswith( + 'This software version lacked a link to a software ' + 'and has been upgraded to link to /software/graphreg/ ' + 'as a placeholder. This software version lacked a version ' + 'and has been upgraded to v1.0.0 as a placeholder. This ' + 'software version lacked a lab and has been upgraded to ' + '/labs/j-michael-cherry/ as a placeholder. This software ' + 'version lacked an award and has been upgraded to ' + '/awards/HG012012/ as a placeholder.' + ) diff --git a/src/igvfd/upgrade/software_version.py b/src/igvfd/upgrade/software_version.py index a80e165ba..c304263a7 100644 --- a/src/igvfd/upgrade/software_version.py +++ b/src/igvfd/upgrade/software_version.py @@ -42,3 +42,29 @@ def software_version_4_5(value, system): notes = value.get('notes', '') notes += f'This object\'s release_timestamp has been set to 2024-03-06T12:34:56Z' value['notes'] = notes.strip() + + +@upgrade_step('software_version', '5', '6') +def software_version_5_6(value, system): + # https://igvf.atlassian.net/browse/IGVF-1686 + software_note = '' + version_note = '' + lab_note = '' + award_note = '' + if 'software' not in value: + value['software'] = '/software/graphreg/' + software_note = 'This software version lacked a link to a software and has been upgraded to link to /software/graphreg/ as a placeholder.' + if 'version' not in value: + value['version'] = 'v1.0.0' + version_note = 'This software version lacked a version and has been upgraded to v1.0.0 as a placeholder.' + if 'lab' not in value: + value['lab'] = '/labs/j-michael-cherry/' + lab_note = 'This software version lacked a lab and has been upgraded to /labs/j-michael-cherry/ as a placeholder.' + if 'award' not in value: + value['award'] = '/awards/HG012012/' + award_note = 'This software version lacked an award and has been upgraded to /awards/HG012012/ as a placeholder.' + merged_note = ' '.join([x for x in [software_note, version_note, lab_note, award_note] if x != '']) + notes = value.get('notes', '') + notes += merged_note + if notes: + value['notes'] = notes.strip()