The code from the mesido and simulator pip packages is run inside workers: optimizer worker and simulator worker. The feature described here allows for progress updates during worker runs, and error handling, to the sdk (front-end).
A worker registers a specific function as its worker's task. This task receives a number of
arguments including an update_progress_function
.
To initiate running of the mesido and simulator code, a specific start function in each of the pip
packages is called in the workers. This start function is passed the update_progress_function
callback function. Upon calling this function the following happens:
- The worker sends a
TaskProgressUpdate
protobuf message to theomotes_task_progress_events
rabbitmq queue - The orchestrator receives this
TaskProgressUpdate
message and:- updates the status of the job in the orchestrator postgres database if it is the first progress update.
- sends a
JobProgressUpdate
protobuf message withjobs.<job_uuid>.progress
as routing key
- The sdk receives this
JobProgressUpdate
message and thecallback_on_progress_update
is executed - (omotes-rest will update the omotes-rest postgres database in
callback_on_progress_update
)
When an exception is thrown during the execution of a worker the celery worker is terminated.
The job will be of ERROR
result type and the exception message will be displayed in the job logs.
TODO
: catch specific exception with a 'nice' error message to be relayed separately to the
front-end.