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:
- In code: the arguments given to
RayRunner(...). - In the Nornir configuration:
runner.options, whenrunner.pluginisray. - In the environment: the variable
RAY_ADDRESS, for the optionaddressonly. - Otherwise the runner uses the default.
In the configuration:
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.
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
| Option | Change it when |
|---|---|
address and role | You run on a cluster. See Choose a deployment |
workers_per_node | You want more or fewer worker processes on each node |
hosts_per_worker | You want each worker to run more or fewer hosts at the same time |
per_host_timeout, timeout | You 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
InitNornircreates 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.