Skip to main content

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​

ComponentRoleModule
RayRunnerThe class Nornir calls. It prepares the first run and hands each run to Nornir's own runnersrunner.py
SettingsReads the options from the code, the configuration and the environment, and checks themsettings.py
Ray connectionStarts or connects to Ray, records whether the runner started it, and holds the pools shared by the runners of the processcluster.py
Worker poolStarts the workers of each node, replaces the ones that stopped, and places the hostspool.py
Host assignmentComputes the worker of each hostassignment.py
Stand-in taskA Nornir task that runs on the driver in place of your task_nornir_adapter.py
Relay functionSends the call to the worker and turns the worker's events into Nornir resultsrelay.py
Wire typesThe messages sent between the driver and the workerswire.py
TaskWorkerThe worker: a Ray actor that runs tasks and keeps hosts and sessionsworker.py
Results and errorsThe ray attribute and the error classesresults.py, errors.py

The modules are in src/nornir_ray/ of the repository.

One run through the components​

  1. First run only. RayRunner merges 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.
  2. 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.
  3. The runner wraps your task in a stand-in task and hands it to Nornir's ThreadedRunner, or to AsyncioRunner for an async run. Nornir records each host as it does for those runners.
  4. For each host, the stand-in task runs the relay function on the driver.
  5. The relay sends a TaskCall to 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​

PageExplains
The stand-in task and the relayHow the runner reuses Nornir's own runners on the driver
The workerWhat a worker process holds and the calls it accepts
Host assignmentHow each host gets its worker
Session reuseHow a worker decides to keep or replace a host's sessions
Abandoned calls and worker replacementWhat happens to sync tasks that do not stop
The connection to RayWhen the runner starts, connects to and stops Ray