Internal components
This section describes how the plugin is built. You do not need it to use the runner. Read it when you want to understand a behaviour in detail, to debug a problem, or to contribute to the code.
The components and where they run
| Component | Role | Module |
|---|---|---|
RayRunner | The class Nornir calls. It prepares the first run and hands each run to Nornir's own runners | runner.py |
| Settings | Reads the options from the code, the configuration and the environment, and checks them | settings.py |
| Ray connection | Starts or connects to Ray, records whether the runner started it, and holds the pools shared by the runners of the process | cluster.py |
| Worker pool | Starts the workers of each node, replaces the ones that stopped, and places the hosts | pool.py |
| Host assignment | Computes the worker of each host | assignment.py |
| Stand-in task | A Nornir task that runs on the driver in place of your task | _nornir_adapter.py |
| Relay function | Sends the call to the worker and turns the worker's events into Nornir results | relay.py |
| Wire types | The messages sent between the driver and the workers | wire.py |
TaskWorker | The worker: a Ray actor that runs tasks and keeps hosts and sessions | worker.py |
| Results and errors | The ray attribute and the error classes | results.py, errors.py |
The modules are in src/nornir_ray/ of the
repository.
One run through the components
- First run only.
RayRunnermerges the settings, connects to Ray through the Ray connection, and takes the worker pool that the runners of the process with the same pool settings share. - Each run. The runner checks that the task can be serialized. The pool fills its empty worker places, retires workers with too many abandoned calls, and assigns each host to a worker.
- The runner wraps your task in a stand-in task and hands it to Nornir's
ThreadedRunner, or toAsyncioRunnerfor an async run. Nornir records each host as it does for those runners. - For each host, the stand-in task runs the relay function on the driver.
- The relay sends a
TaskCallto the host's worker and turns the events the worker sends back into partial results, processor events and the final result.
The pages of this section
| Page | Explains |
|---|---|
| The stand-in task and the relay | How the runner reuses Nornir's own runners on the driver |
| The worker | What a worker process holds and the calls it accepts |
| Host assignment | How each host gets its worker |
| Session reuse | How a worker decides to keep or replace a host's sessions |
| Abandoned calls and worker replacement | What happens to sync tasks that do not stop |
| The connection to Ray | When the runner starts, connects to and stops Ray |