Skip to content

Commit

Permalink
migration fix, lint
Browse files Browse the repository at this point in the history
  • Loading branch information
v-rocheleau committed Sep 15, 2023
1 parent 2a93fe4 commit eb93de0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion chord_metadata_service/experiments/migrations/0009_v4_1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
LIB_SELECTION_CONVERIONS: List[Tuple[str, str]] = [
("Random", "RANDOM"),
("Random PCR", "RANDOM PCR"),
("Exome capture", "other"), # 'Exome capture' no longer supported
("Exome capture", "Hybrid Selection"), # 'Exome capture' no longer supported
("Other", "other"),
]


def set_experiment_library(apps, _schema_editor):
Experiment = apps.get_model("experiments", "Experiment")
for (old_val, new_val) in LIB_STRATEGY_CONVERSIONS:
Expand All @@ -28,6 +29,7 @@ def set_experiment_library(apps, _schema_editor):
exp.library_selection = new_val
exp.save()


class Migration(migrations.Migration):
dependencies = [
('experiments', '0007_v4_0_0'),
Expand Down
6 changes: 3 additions & 3 deletions chord_metadata_service/ontologies/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def read_xsd_simple_type_values(xsd_file_name: str, type_name: str) -> List[str]
https://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html
"""
xsd_file_path = os.path.join(XSD_ONTOLOGIES_PATH, xsd_file_name)
with open(xsd_file_path, 'r') as file:
with open(xsd_file_path, "r") as file:
xsd_file = file.read()

xsd_data = xmltodict.parse(xsd_file, namespaces={'xs': None})
xsd_data = xmltodict.parse(xsd_file, namespaces={"xs": None})
simple_types = {sp["@name"]: sp for sp in xsd_data["schema"]["simpleType"]}
target_type = simple_types[type_name]
values = [val['@value'] for val in target_type['restriction']['enumeration']]
values = [val["@value"] for val in target_type["restriction"]["enumeration"]]
return values

0 comments on commit eb93de0

Please sign in to comment.