Skip to content

Commit

Permalink
Merge branch 'main' into mshadbolt/docs-and-error-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mshadbolt authored Nov 21, 2023
2 parents 2eba9b4 + df88741 commit a8aefad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 6 additions & 6 deletions mohschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ def validate_immunotherapies(self, map_json):


def validate_radiations(self, map_json):
index = self.validation_schema["radiations"]["extra_args"]["index"]
if index > 0:
self.fail("Only one radiation is allowed per treatment")
# index = self.validation_schema["radiations"]["extra_args"]["index"]
# if index > 0:
# self.fail("Only one radiation is allowed per treatment")

for prop in map_json:
match prop:
Expand All @@ -373,9 +373,9 @@ def validate_radiations(self, map_json):

def validate_surgeries(self, map_json):
specimen_ids = self.validation_schema["primary_diagnoses"]["extra_args"]["specimen_ids"]
index = self.validation_schema["surgeries"]["extra_args"]["index"]
if index > 0:
self.fail("Only one surgery is allowed per treatment")
# index = self.validation_schema["surgeries"]["extra_args"]["index"]
# if index > 0:
# self.fail("Only one surgery is allowed per treatment")

if "submitter_specimen_id" not in map_json:
if "surgery_site" not in map_json or map_json["surgery_site"] is None:
Expand Down
5 changes: 2 additions & 3 deletions test_data_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ def test_validation(packets, schema):
# DONOR_5 > PD_5 > TR_10: treatment type Immunotherapy should have one or more immunotherapies submitted

print(schema.validation_errors)
assert len(schema.validation_errors) == 3
# should be the following 3 errors:
# DONOR_5 > PD_5 > TR_5 > Radiation 1: Only one radiation is allowed per treatment
assert len(schema.validation_errors) == 2
# should be the following 2 errors:
# DONOR_6 > PD_6 > TR_9 > Surgery 0: submitter_specimen_id SPECIMEN_43 does not correspond to one of the available specimen_ids ['SPECIMEN_3']
# Duplicated IDs: in schema followups, FOLLOW_UP_4 occurs 2 times

Expand Down
5 changes: 4 additions & 1 deletion validate_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ def validate_coverage(map_json, verbose=False):
mappings.VERBOSE = True

# read the schema and generate a scaffold
if "openapi_url" not in map_json:
return {"message": "No openapi_url schema available"}
schema = MoHSchema(map_json["openapi_url"])
if schema.json_schema is None:
sys.exit(f"Did not find an openapi schema at {map_json['openapi_url']}; please check the 'openapi_url' in the map json file.")
Expand All @@ -223,7 +225,8 @@ def validate_coverage(map_json, verbose=False):
# print(json.dumps(schema.validation_results, indent=4))
return {
"errors": schema.validation_errors,
"warnings": schema.validation_warnings
"warnings": schema.validation_warnings,
"statistics": schema.statistics
}

def main(args):
Expand Down

0 comments on commit a8aefad

Please sign in to comment.