Skip to content

Commit

Permalink
update record normalization to set 0 to None
Browse files Browse the repository at this point in the history
  • Loading branch information
mbthornton-lbl committed Oct 4, 2024
1 parent d05ff8c commit 1711fe3
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions nmdc_automation/workflow_automation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,6 @@ def workflow_process_factory(record: Dict[str, Any]) -> Union[DataGeneration, Wo
}
record = _normalize_record(record)


# add type to Mags Analysis mags_list records
if record["type"] == "nmdc:MagsAnalysis" and "mags_list" in record:
for mag in record["mags_list"]:
if not mag.get("type"):
mag["type"] = "nmdc:MagBin"
if mag["gene_count"] == 'null':
mag["gene_count"] = 0

if "num_tRNA" in mag:
mag["num_t_rna"] = mag.pop("num_tRNA")


try:
cls = process_types[record["type"]]
except KeyError:
Expand All @@ -69,6 +56,9 @@ def _normalize_record(record: Dict[str, Any]) -> Dict[str, Any]:
for key, value in record.items():
if value == "null":
record[key] = None
# set zero values to None so they don't get serialized
if value == 0:
record[key] = None

# type-specific normalization
# add type to Mags Analysis mags_list records
Expand Down

0 comments on commit 1711fe3

Please sign in to comment.