Organizing Bluesky Startup Code

Documentation is coming soon …

Detecting if the Code is Executed by RE Worker

Calling the is_re_worker_active() API anywhere in the startup code or an imported module allows to detect if the code is executed by RE Worker. The function returns True if the code is running in RE Worker environment and False otherwise.

The API may be used to conditionally avoid execution of some code (e.g. the code that interacts with the user) when experiments are controlled remotely:

from bluesky_queueserver import is_re_worker_active

...

if is_re_worker_active():
    <code without interactive features, e.g. reading data from a file>
else:
    <code with interactive features, e.g. manual data input>

...

Note

Queue Server provides additional set_re_worker_active() and clear_re_worker_active() API, which modify the value returned by subsequent calls to is_re_worker_active() in the current process. These API are intended for implementation of tests and should never be used in startup scripts.

is_re_worker_active

The function can be used in startup scripts or modules to check if the script is imported or executed in RE Worker environment.

set_re_worker_active

Set the environment variable used to determine if the current process is RE Worker process.

clear_re_worker_active

Clear the environment variable used to determine if the current process is RE Worker process.