RESTful API for visualisations #1486
lukavdplas
started this conversation in
General
Replies: 1 comment 3 replies
-
Terminology nitpick: you are proposing to use more appropriate HTTP verbs. This has almost nothing to do with RESTfulness; see this slightly polemic blog post by the inventor of the words "REST" and "HATEOAS" about what it entails to work RESTful. We almost never do this at the RSL, although RDF data are intrinsically somewhat RESTful. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is something we discussed as part of #1430, but I think it also has advantages for general code quality.
Right now, visualisation requests to the backend are roughly made in two ways.
For fast visualisations:
For slower visualisations (which may cause timeouts if handled in a single request):
/api/task_status
with a list of celery task IDs in the payload. The response returns the status (done/working/error) of the task, and the results the task is done./api/abort_tasks
with a list of celery task IDs in the payload. This will cancel those tasks in celery.(The latter two request involve lists of tasks because a visualisation often involves multiple tasks for parallellisation.)
A most RESTful implementation would be:
Potentially, you could also support a PATCH request to update the parameters of the visualisation. (The backend would then cancel open tasks and create a new task to fetch results.)
This would make sense if visualisation objects are also represented as objects in the database, so this API can interact with that. That sounds fine to me; ideally with a periodic job to remove visualisations older than, say, 24 hours.
Advantages:
abort_task
/task_status
views are a minor security issue, as anyone is authorised to view or cancel any celery task. (This is mitigated by the fact that celery task IDs are long, random strings.) With this setup, we could actually check if someone is authorised to view the results of a visualisation.Beta Was this translation helpful? Give feedback.
All reactions