smif.controller.scheduler module

Summary

Classes:

Scheduler The scheduler can run instances of smif as a subprocess and can provide information whether the modelrun is running, is done or has failed.

Reference

class smif.controller.scheduler.Scheduler[source]

Bases: object

The scheduler can run instances of smif as a subprocess and can provide information whether the modelrun is running, is done or has failed.

add(model_run_name, args)[source]

Add a model_run to the Modelrun scheduler.

Parameters:
  • model_run_name (str) – Name of the modelrun
  • args (dict) – Arguments for the command-line interface
  • Exception
  • ---------
  • Exception – When the modelrun was already started

Notes

There is no queuing mechanism implemented, each add will directly start a subprocess. This means that it is possible to run multiple modelruns concurrently. This may cause conflicts, it depends on the implementation whether a certain sector model / wrapper touches the filesystem or other shared resources.

kill(model_run_name)[source]

Kill a Modelrun that is already running

Parameters:model_run_name (str) – Name of the modelrun
get_status(model_run_name)[source]

Get the status from the Modelrun scheduler.

Parameters:model_run_name (str) – Name of the modelrun
Returns:
  • dict (A message containing the status, command-line)
  • output and error that can be directly sent back over
  • the http api.

Notes

Possible status:

unstarted:
Model run was not started
queing:
Model run is waiting to be executed
running:
Model run is running
stopped:
Model run was stopped (killed) by user
done:
Model run was completed succesfully
failed:
Model run completed running with an exit code