Skip to content

Commit

Permalink
Remove entries that have no relevance to spreadsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
tcezard committed Sep 7, 2023
1 parent fbf3bc3 commit 1806ceb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
11 changes: 8 additions & 3 deletions cli/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ def convert_metadata_validation_results(self):
new_description = f'In sheet "{sheet}", row "{row}", column "{column}" is not populated'
else:
new_description = error["description"].replace(sheet_json, sheet)
if column is None:
# We do not know this attribute. It's most likely about bioSampleObject
continue
if 'schema' in new_description:
# This is an error specific to json schema
continue
self.results['metadata_check']['spreadsheet_errors'].append({
'sheet': sheet, 'row': row, 'column': column,
'description': new_description
Expand All @@ -290,16 +296,15 @@ def _convert_metadata_sheet(self, json_attribute, xls2json_conf):

def _convert_metadata_row(self, sheet, json_row, xls2json_conf):
if json_row is None:
# This is for Sheet that can only have a single entry (Project)
json_row = 0
return ''
if 'header_row' in xls2json_conf[sheet]:
return int(json_row) + xls2json_conf[sheet]['header_row']
else:
return int(json_row) + 2

def _convert_metadata_attribute(self, sheet, json_attribute, xls2json_conf):
if json_attribute is None:
return None
return ''
attributes_dict = {}
attributes_dict.update(xls2json_conf[sheet].get('required', {}))
attributes_dict.update(xls2json_conf[sheet].get('optional', {}))
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/validation_reports/expected_report.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@
{'property': '/analysis/0.description', 'description': "should have required property 'description'"},
{'property': '/analysis/0.experimentType', 'description': "should have required property 'experimentType'"},
{'property': '/analysis/0.referenceGenome', 'description': "should have required property 'referenceGenome'"},
{'property': '/sample/0.bioSampleAccession', 'description': "should have required property 'bioSampleAccession'"},
{'property': '/sample/0.bioSampleObject', 'description': "should have required property 'bioSampleObject'"},
{'property': '/sample/0', 'description': 'should match exactly one schema in oneOf'}
{'property': '/sample/0.bioSampleAccession', 'description': "should have required property 'bioSampleAccession'"}
],
'report_path': '/path/to/metadata/report'
}
Expand All @@ -98,5 +96,7 @@ def test_generate_html_report(self):
reporter.convert_metadata_validation_results()
validation_results = reporter.results
report = generate_html_report(validation_results, datetime.datetime(2023, 8, 31, 12, 34, 56), "My cool project")
with open('report.html', 'w') as open_html:
assert open_html.write(report)
with open(self.expected_report) as open_html:
assert report == open_html.read()
8 changes: 2 additions & 6 deletions tests/test_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,15 @@ def test__collect_validation_workflow_results(self):
{'property': '/sample/0', 'description': 'should match exactly one schema in oneOf'}
],
'spreadsheet_errors': [
{'sheet': 'Files', 'row': 2, 'column': None, 'description': 'Sheet "Files" is missing'},
{'sheet': 'Project', 'row': 2, 'column': 'Project Title',
{'sheet': 'Files', 'row': '', 'column': '', 'description': 'Sheet "Files" is missing'},
{'sheet': 'Project', 'row': '', 'column': 'Project Title',
'description': 'In sheet "Project", column "Project Title" is not populated'},
{'sheet': 'Analysis', 'row': 2, 'column': 'Description',
'description': 'In sheet "Analysis", row "2", column "Description" is not populated'},
{'sheet': 'Analysis', 'row': 2, 'column': 'Reference',
'description': 'In sheet "Analysis", row "2", column "Reference" is not populated'},
{'sheet': 'Sample', 'row': 3, 'column': 'Sample Accession',
'description': 'In sheet "Sample", row "3", column "Sample Accession" is not populated'},
{'sheet': 'Sample', 'row': 3, 'column': None,
'description': "should have required property 'bioSampleObject'"},
{'sheet': 'Sample', 'row': 3, 'column': None,
'description': 'should match exactly one schema in oneOf'}
]
}
}
Expand Down

0 comments on commit 1806ceb

Please sign in to comment.