summaryrefslogtreecommitdiff
path: root/opendc/api/v1/simulations/simulationId/experiments/endpoint.py
diff options
context:
space:
mode:
authorleonoverweel <l.overweel@gmail.com>2017-02-27 02:33:02 +0100
committerleonoverweel <l.overweel@gmail.com>2017-02-27 02:33:02 +0100
commit855b654942d400204ea3ce952b5fe0cebf8492c2 (patch)
tree4f963b2bd11a1873d613fc78c0eda5f98e43dd75 /opendc/api/v1/simulations/simulationId/experiments/endpoint.py
parentcdfce7ce038826bd99be805b7e7579c9ec5d4fc2 (diff)
Add state and last_simulated_tick to Experiments
This change brings the web server back up to date with the new database schema.
Diffstat (limited to 'opendc/api/v1/simulations/simulationId/experiments/endpoint.py')
-rw-r--r--opendc/api/v1/simulations/simulationId/experiments/endpoint.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/opendc/api/v1/simulations/simulationId/experiments/endpoint.py b/opendc/api/v1/simulations/simulationId/experiments/endpoint.py
index 8cc4165f..034e82a1 100644
--- a/opendc/api/v1/simulations/simulationId/experiments/endpoint.py
+++ b/opendc/api/v1/simulations/simulationId/experiments/endpoint.py
@@ -89,6 +89,8 @@ def POST(request):
# Instantiate an Experiment
experiment = Experiment.from_JSON(request.params_body['experiment'])
+ experiment.state = 'QUEUED'
+ experiment.last_simulated_tick = 0
# Try to insert this Experiment
@@ -96,15 +98,10 @@ def POST(request):
experiment.insert()
except exceptions.ForeignKeyError as e:
- return Response(400, 'Foreign key constraint not met.')
-
- # Queue this Experiment for simulation
-
- queued_experiment = QueuedExperiment(experiment_id = experiment.id)
- queued_experiment.insert()
+ return Response(400, 'Foreign key constraint not met.' + e.message)
# Return this Experiment
-
+
experiment.read()
return Response(