Submit a job to a worker
========================

The client may want to start a workflow execution remotely and wait for the result
while doing other work.

Installation
------------

Install on the client side

.. code-block:: bash

    pip install ewoksjob[redis]

Install on the worker side

.. code-block:: bash

    pip install ewoksjob[worker,redis,monitor]

The communication between client and worker goes through *Redis*, *RabbitMQ* or *Sqlite3*.
Depending on which one you choose, the `redis` installation option may vary. Both client and
worker need access to a configuration that specifies the URL of the database and/or broker.
For more information see the `ewoksjob documentation <https://ewoksjob.readthedocs.io/>`_.

Submit a workflow
-----------------

Start a worker that can execute *ewoks* graphs

.. code-block:: bash

    ewoksjob worker

Submit a workflow from python, possible from another machine

.. code-block:: python

    from ewoksjob.client import submit

    workflow = {"graph": {"id": "mygraph"}}
    future = submit(args=(workflow,))
    result = future.get()

Submit a workflow from the command line, possible from another machine

.. code-block:: bash

    ewoks submit empty --test

Submit a workflow in *BLISS*
----------------------------

In the context of *Bliss*

.. code-block:: bash

    BEACON_HOST=hostname:25000 ewoksjob worker

Submit a workflow as usual

.. code-block:: bash

    BEACON_HOST=hostname:25000 ewoks submit empty --test

The environment variables are needed for communication between worker and client via the message broker.

Workflow monitoring
-------------------

Start a web server for monitoring jobs

.. code-block:: bash

    ewoksjob monitor
