Skip to content

Commit

Permalink
add a _normalize_value function
Browse files Browse the repository at this point in the history
  • Loading branch information
mbthornton-lbl committed Nov 15, 2024
1 parent 98d4322 commit e20f88f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion nmdc_automation/workflow_automation/wfutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,21 @@ def make_workflow_execution_record(self, data_objects: List[DataObject]) -> Dict
for field_name in field_names:
# add to wf_dict if it has a value
if field_name in data:
wf_dict[field_name] = data[field_name]
wf_dict[field_name] = _normalize_value(field_name,data[field_name])
else:
logging.warning(f"Field {field_name} not found in {data_path}")

return wf_dict


def _normalize_value(field_name,value: Any) -> Any:
""" Normalize values and fix common issues """
# completeness and contamination need to be converted from string to float
if field_name in ["completeness", "contamination"]:
return float(value)

return value

def _json_tmp(data):
fp, fname = tempfile.mkstemp(suffix=".json")
with os.fdopen(fp, "w") as fd:
Expand Down

0 comments on commit e20f88f

Please sign in to comment.