Skip to main content

Find where each host ran

Each host's result records the node and the worker that ran the host. Use it to check a deployment, or to find the machine to look at when a host fails.

Read the location​

The top-level result of each host has a ray attribute:

result = nr.run(task=my_task)

location = getattr(result["r1"][0], "ray", None)
if location:
print(location.node_name) # the node's name
print(location.node_id) # the Ray node ID
print(location.worker_id) # "<node_id>/<n>"
print(location.site) # the host's site, or None
FieldValue
node_idThe Ray node ID
node_nameThe node's name
worker_idThe worker, in the form <node_id>/<n>, where n is the worker's number on the node
siteThe host's site from the inventory, or None

Results without a location​

Read the attribute with getattr(result, "ray", None). Some results have no ray attribute, because Nornir records them without a result from a worker:

  • hosts cancelled before they started;
  • hosts past their deadline;
  • hosts whose worker stopped during the call;
  • results of subtasks.

Record a host's site​

The site is a label you give a host in the inventory, under the key ray:

hosts.yaml
r1:
hostname: 192.0.2.1
data:
ray:
site: paris

The runner copies the site into the host's RunLocation. In this version the site does not change which worker runs the host: a host can go to any worker. See Host inventory.