Skip to content

Commit

Permalink
Merge pull request #70 from DARPA-ASKEM/TS/2906-Add-simulation-risk-t…
Browse files Browse the repository at this point in the history
…o-results

change the tensor to list before serializing
  • Loading branch information
Tom-Szendrey authored Mar 14, 2024
2 parents 24ea9ce + d7e7877 commit 94f6c98
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion service/utils/tds.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,16 @@ def attach_files(output: dict, job_id, status="complete"):
files[output_filename] = "result.csv"

risk_result = output.get("risk", None)
print("Tom")
print(risk_result)
if risk_result is not None:
json_obj = json.loads(json.dumps(risk_result, default=str))
# Update qoi (tensor) to a list before serializing with json.dumps
for k, v in risk_result.items():
risk_result[k]["qoi"] = v["qoi"].tolist()
risk_json_obj = json.dumps(risk_result, default=str)
print(risk_json_obj)
json_obj = json.loads(risk_json_obj)
print(json_obj)
json_filename = os.path.join(job_dir, "./risk.json")
with open(json_filename, "w") as f:
json.dump(json_obj, f, ensure_ascii=False, indent=4)
Expand Down

0 comments on commit 94f6c98

Please sign in to comment.