Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
marshHawk4 committed Jul 13, 2023
1 parent ec4bdb0 commit 752bd74
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions workers/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,19 @@ def calibrate_then_simulate(*args, **kwargs):

dataset_path = fetch_dataset(kwargs.pop("dataset"), TDS_API)

samples = load_and_calibrate_and_sample_petri_model(
output = load_and_calibrate_and_sample_petri_model(
amr_path,
dataset_path,
timepoints=timepoints,
**kwargs
)
logging.error('sssssssssssssssssssssssss')
logging.error(output)
samples = output.get('data')
schema = output.get('visual')
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"}, TDS_API, TDS_SIMULATIONS, job_id)
attach_files({OUTPUT_FILENAME: "simulation.csv", "visualization.json": "visualization.json"}, TDS_API, TDS_SIMULATIONS, job_id)

return True
6 changes: 5 additions & 1 deletion workers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import numpy as np
import time
import logging
import redis
REDIS = os.getenv("REDIS_HOST", "redis")

r = redis.Redis(host=REDIS, port=6379, decode_responses=True)

TDS_SIMULATIONS = "/simulations/"
OUTPUT_FILENAME = os.getenv("PYCIEMSS_OUTPUT_FILEPATH")
Expand All @@ -27,7 +31,6 @@ def parse_samples_into_file(samples):
else:
pyciemss_results["params"][key] = value

print(pyciemss_results)

file_output_json = {
"0": {
Expand Down Expand Up @@ -143,6 +146,7 @@ def attach_files(files: dict, tds_api, simulation_endpoint, job_id, status='comp
sim_results_url = tds_api + simulation_endpoint + job_id

if status!="error":
r.set(job_id, 100)
for (location, handle) in files.items():
upload_url = f"{sim_results_url}/upload-url?filename={handle}"
upload_response = requests.get(upload_url)
Expand Down

0 comments on commit 752bd74

Please sign in to comment.