Skip to main content

nornir_progressbar

published

nornir_progressbar is a runner plugin for turning your task executions into nice-looking tqdm progress bars. It can be used with both of Nornir's standard Runners:

  • SerialRunner
  • ThreadedRunner

Installation

Install the package from PyPi with pip.

pip install nornir-progressbar

Usage

Be sure to register the RunnerPlugin within your Nornir script before using it.

To use the Multi-threaded execution, register the class ThreadedProgressBarRunner:

from nornir_progressbar.plugins.runners import ThreadedProgressBarRunner
from nornir.core.plugins.runners import RunnersPluginRegister
from nornir import InitNornir

RunnersPluginRegister.register("ProgressBar", ThreadedProgressBarRunner)

nr = InitNornir(config_file='sample_config.yaml')

For serial executions, use SerialProgressBarRunner instead:

from nornir_progressbar.plugins.runners import SerialProgressBarRunner
from nornir.core.plugins.runners import RunnersPluginRegister
from nornir import InitNornir

RunnersPluginRegister.register("ProgressBar", SerialProgressBarRunner)

nr = InitNornir(config_file='sample_config.yaml')

Your nornir config file should point to the new runner plugin:

---
inventory:
    plugin: SimpleInventory
    options:
        host_file: "inventory/hosts.yaml"
        group_file: "inventory/groups.yaml"
        defaults_file: "inventory/defaults.yaml"
runner:
    plugin: ProgressBar
    options:
        num_workers: 10

And that's it! Whenever you execute a nornir task, a progress bar will appear for each host in the inventory, incrementing for each host that finishes execution. The name of the task being run is used as the progress bar's description.

Progress bar example

Configuration

The plugin uses tqdm to render the progress bar. Keyword arguments can be passed directly to the tqdm() call by setting them under the plugin options. Adding a 'desc' argument will provide a custom description to the progress bar. Consult tqdm's documentation for all the keyword arguments supported.

---
inventory:
    plugin: SimpleInventory
    options:
        host_file: "inventory/hosts.yaml"
        group_file: "inventory/groups.yaml"
        defaults_file: "inventory/defaults.yaml"
runner:
    plugin: ProgressBar
    options:
        num_workers: 10
        desc: Toto tata
        leave: False

The above configuration yields a single progress bar with description "Toto tata" that gets replaced every time a task finishes execution. Progress bar with description

Use the ascii option to get an ASCII progress bar.

---
inventory:
    plugin: SimpleInventory
    options:
        host_file: "inventory/hosts.yaml"
        group_file: "inventory/groups.yaml"
        defaults_file: "inventory/defaults.yaml"
runner:
    plugin: ProgressBar
    options:
        num_workers: 10
        ascii: True

ASCII Progress Bar

Metadata

Release files for nornir-progressbar 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nornir-progressbar 0.1.1
File Size Uploaded
nornir_progressbar-0.1.1.tar.gz 7.3 kB Details

Release files / nornir_progressbar-0.1.1.tar.gz

Download URL nornir_progressbar-0.1.1.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2b4466db86bd4d249edc71835526351558f823a617489e210ea9383242f405ad
BLAKE2b-256 checksum
How to use checksums
0e432726870573def579136bd1ba05e82894e10b1202b06b8f1715f1529db221
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page