Skip to content

Commit

Permalink
Save eval CSVs (#20)
Browse files Browse the repository at this point in the history
* Save eval CSVs

* Play with logging
  • Loading branch information
fivegrant authored Jul 18, 2023
1 parent 820890c commit bbe001f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions workers/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
TDS_CONFIGURATIONS = "/model_configurations/"
TDS_SIMULATIONS = "/simulations/"
OUTPUT_FILENAME = os.getenv("PYCIEMSS_OUTPUT_FILEPATH")
EVAL_OUTPUT_FILENAME = "eval.csv"
TDS_API = os.getenv("TDS_URL")

logging.basicConfig()
Expand Down Expand Up @@ -59,7 +60,9 @@ def simulate(*args, **kwargs):
with open("visualization.json", "w") as f:
json.dump(schema, f, indent=2)
samples.to_csv(OUTPUT_FILENAME, index=False)
attach_files({OUTPUT_FILENAME: "result.csv", "visualization.json": "visualization.json"}, TDS_API, TDS_SIMULATIONS, job_id)
eval = output.get('quantiles')
eval.to_csv(EVAL_OUTPUT_FILENAME, index=False)
attach_files({OUTPUT_FILENAME: "result.csv", "visualization.json": "visualization.json", EVAL_OUTPUT_FILENAME: EVAL_OUTPUT_FILENAME}, TDS_API, TDS_SIMULATIONS, job_id)
logging.debug(f"{job_id} (username - {username}): finish simulate")

return
Expand Down Expand Up @@ -97,7 +100,9 @@ def calibrate_then_simulate(*args, **kwargs):
with open("visualization.json", "w") as f:
json.dump(schema, f, indent=2)
samples.to_csv(OUTPUT_FILENAME, index=False)
attach_files({OUTPUT_FILENAME: "simulation.csv", "visualization.json": "visualization.json"}, TDS_API, TDS_SIMULATIONS, job_id)
eval = output.get('quantiles')
eval.to_csv(EVAL_OUTPUT_FILENAME, index=False)
attach_files({OUTPUT_FILENAME: "simulation.csv", "visualization.json": "visualization.json", EVAL_OUTPUT_FILENAME: EVAL_OUTPUT_FILENAME}, TDS_API, TDS_SIMULATIONS, job_id)

logging.debug(f"{job_id} (username - {username}): finish calibrate")

Expand Down Expand Up @@ -139,7 +144,9 @@ def ensemble_simulate(*args, **kwargs):
with open("visualization.json", "w") as f:
json.dump(schema, f, indent=2)
samples.to_csv(OUTPUT_FILENAME, index=False)
attach_files({OUTPUT_FILENAME: "simulation.csv", "visualization.json": "visualization.json"}, TDS_API, TDS_SIMULATIONS, job_id)
eval = output.get('quantiles')
eval.to_csv(EVAL_OUTPUT_FILENAME, index=False)
attach_files({OUTPUT_FILENAME: "simulation.csv", "visualization.json": "visualization.json", EVAL_OUTPUT_FILENAME: EVAL_OUTPUT_FILENAME}, TDS_API, TDS_SIMULATIONS, job_id)
logging.debug(f"{job_id} (username - {username}): finish ensemble simulate")
return True

Expand Down Expand Up @@ -183,6 +190,8 @@ def ensemble_calibrate(*args, **kwargs):
with open("visualization.json", "w") as f:
json.dump(schema, f, indent=2)
samples.to_csv(OUTPUT_FILENAME, index=False)
attach_files({OUTPUT_FILENAME: "simulation.csv", "visualization.json": "visualization.json"}, TDS_API, TDS_SIMULATIONS, job_id)
eval = output.get('quantiles')
eval.to_csv(EVAL_OUTPUT_FILENAME, index=False)
attach_files({OUTPUT_FILENAME: "simulation.csv", "visualization.json": "visualization.json", EVAL_OUTPUT_FILENAME: EVAL_OUTPUT_FILENAME}, TDS_API, TDS_SIMULATIONS, job_id)
logging.debug(f"{job_id} (username - {username}): finish ensemble calibrate")
return True
2 changes: 1 addition & 1 deletion workers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def wrapped(*args, **kwargs):
result = function(*args, **kwargs)
end_time = time.perf_counter()
logging.info(
"Elapsed time for %s for %s: %d",
"Elapsed time for %s for %s: %f",
function.__name__, kwargs['username'], end_time - start_time
)
return result
Expand Down

0 comments on commit bbe001f

Please sign in to comment.