A bridge is a simple library in the task’s target language that hide all the complexity of the communication protocol. If not available in your target language, implement the communication protocol by hand.

A bridge provides an easy way to send messages to the worker shell or to receive messages. It also provides methods to get path of input/output files.

Python bridge

We provide the Python bridge as a Python module named optimserverworkerbridge, you can install it using pip and our Nexus PyPI repository (you’ll need credentials, see the contact section:

pip3 install -i "" optimserver-workerbridge==3.2.1 

You must then, instantiate the ExecutionContext and start it:

from optimserver.workerbridge import ExecutionContext

execution_context = ExecutionContext()

Note that calling the start method will make the bridge wait for messages on the standard input of the process. If you need to use the standard input for a debugging purpose for instance, don’t call this method but remember it must be called when the task is ran whithin the worker shell.

The rest of the code is up to you, you can use execution_context.get_input_path or execution_context.get_all_input_paths to locate the task input parameter files. Use execution_context.get_output_path to get the path where a particular output parameter file must be saved.

To handle stop, register a callback with execution_context.add_should_stop_callback. To send messages use the execution_context.notify_* methods.

For more details, use help(optimserver.workerbridge) and help(ExecutionContext) with Python in interactive mode.