-
Notifications
You must be signed in to change notification settings - Fork 3
REST API
The UI and backend server communicate with a simple HTTP API. This document describes the endpoints available on the backend server.
We avoid the term "REST API" above because this API is neither cacheable nor stateless.
Future work for Modelcollab will at some point include a dashboard for running models and model results. When this is implemented, this API will be modified so that getModelResults is no longer required. Instead, /computeModel will POST to the server, which will start computing and notify the UI through some other mechanism that it is in the process of doing so.
It may make sense to adapt /getCode to accept JSON containing the component data for the canvas and any imported models. This could make that request cacheable and the API truly RESTful. Alternatively, we could change /getCode to a POST called something like /computeJuliaCodeGen and access the results through the same dashboard as we do with /computeModel. This will be decided at the time that the dashboard is being planned, but in any case will involve moving to a real REST API.
-
GET
/getCode/<sessionId>- Access the components for
sessionIdin Firebase and interpret it as Julia code -
Responses
-
200 Responds with the Julia code OR an error message as
text/plain
-
200 Responds with the Julia code OR an error message as
- Access the components for
-
POST
/computeModel/<sessionId>/<scenarioName>- Ask the server to generate Julia code for
sessionIdand interpret it by starting a new Julia process. The codegen process overrides parameter values as specified by the given scenario. If the scenario name is "baseline" or if the provided scenario is not found, default values are used. -
Responses
-
200 Julia process started. Responds with a resultID to use with
/getModelResultsastext/plain -
500 Not able to successfully generate code and start the Julia process. Responds with an error message as
text/plain
-
200 Julia process started. Responds with a resultID to use with
- Ask the server to generate Julia code for
-
GET
/getModelResults/<resultId>- Get the results with the given id (returned from computeModel), if they exist
-
Responses
- 204 Results not available
- 200 Results available. Responds with the .png results graph as a binary blob
- 500 The Julia process exited without saving any results files