Skip to main content

Configure the runner

Where to set an option​

You can set each option in three places. The runner reads an option from the first place that sets it:

  1. In code: the arguments given to RayRunner(...).
  2. In the Nornir configuration: runner.options, when runner.plugin is ray.
  3. In the environment: the variable RAY_ADDRESS, for the option address only.
  4. Otherwise the runner uses the default.

In the configuration:

config.yaml
runner:
plugin: ray
options:
address: "10.0.0.1:6379"
role: server
workers_per_node: 8
per_host_timeout: 30

In code:

from nornir_ray import RayRunner

runner = RayRunner(
address="10.0.0.1:6379",
role="server",
workers_per_node=8,
per_host_timeout=30,
)
nr = nr.with_runner(runner)

You can combine the two. For example, set the role in code and leave the address in the configuration.

Deadlines of a runner created in code

Nornir reads per_host_timeout and timeout before the run starts. For a runner that you create with RayRunner(...), give the deadlines as arguments. The runner does not read deadlines that are set only in the Nornir configuration in that case.

The options most people change​

OptionChange it when
address and roleYou run on a cluster. See Choose a deployment
workers_per_nodeYou want more or fewer worker processes on each node
hosts_per_workerYou want each worker to run more or fewer hosts at the same time
per_host_timeout, timeoutYou want to limit how long a host or a whole run may take

The full list, with defaults, is in Runner options.

Mistakes in options​

An unknown option name or an invalid value raises RunnerSettingsError. The error names the option, the value and the place it came from: code, config or the environment.

RayRunner(workers_per_nod=8) # RunnerSettingsError: unknown option
  • Options given in code are checked when the runner is created.
  • Options in the Nornir configuration are checked when InitNornir creates the runner, or at the first run when the runner was created in code.
  • The check of the role against the address runs at the first run, before any host starts.

Use several runners in one process​

Runners in the same Python process share one connection to Ray. Runners with the same pool settings also share the same workers, so a host keeps its worker and its sessions whichever of these runners runs it.