Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGVF-1686-software-version-req #933

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/igvfd/schemas/changelogs/software_version.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 7 additions & 1 deletion src/igvfd/schemas/software_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
]
}
],
"required": [
"award",
"lab",
"software",
"version"
],
"identifyingProperties": [
"uuid",
"aliases",
Expand Down Expand Up @@ -54,7 +60,7 @@
},
"properties": {
"schema_version": {
"default": "5"
"default": "6"
},
"software": {
"title": "Software",
Expand Down
13 changes: 13 additions & 0 deletions src/igvfd/tests/fixtures/schemas/software.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions src/igvfd/tests/fixtures/schemas/software_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ def software_version_v3(software_version_v2):
'description': '',
})
return item


@pytest.fixture
def software_version_v5(testapp):
item = {}
return item
19 changes: 19 additions & 0 deletions src/igvfd/tests/test_upgrade_software_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
)
26 changes: 26 additions & 0 deletions src/igvfd/upgrade/software_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()