Skip to content

Repository files navigation

Lightning Utilities

PyPI StatuslicensePyPI - DownloadsPyPI - Python Version

UnitTestsApply checksDocs Statuspre-commit.ci status

This repository covers the following use-cases:

  1. Reusable GitHub workflows
  2. Shared GitHub actions
  3. General Python utilities in lightning_utilities.core
  4. CLI python -m lightning_utilities.cli --help

1. Reusable workflows

Usage:

name: Check schemaon: [push]jobs:
check-schema:
uses: Lightning-AI/utilities/.github/workflows/check-schema.yml@v0.5.0with:
azure-dir: ""# skip Azure checkcheck-code:
uses: Lightning-AI/utilities/.github/workflows/check-code.yml@mainwith:
actions-ref: main # normally you shall use the same version as the workflow

See usage of other workflows in .github/workflows/ci-use-checks.yaml.

2. Reusable composite actions

See available composite actions .github/actions/.

Usage:

name: Do something with cacheon: [push]jobs:
pytest:
runs-on: ubuntu-24.04steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4with:
python-version: 3.10
- uses: Lightning-AI/utilities/.github/actions/cachewith:
python-version: 3.10requires: oldest # or latest

3. General Python utilities lightning_utilities.core

Installation From source:
pip install https://github.com/Lightning-AI/utilities/archive/refs/heads/main.zip

From pypi:

pip install lightning_utilities

Usage:

Example for optional imports:

fromlightning_utilities.core.importsimportmodule_availableifmodule_available("some_package.something"):
fromsome_packageimportsomething

4. CLI lightning_utilities.cli

The package provides common CLI commands.

Installation

From pypi:

pip install lightning_utilities[cli]

Usage:

python -m lightning_utilities.cli [group] [command]
Example for setting min versions
$ cat requirements/test.txtcoverage>=5.0codecov>=2.1pytest>=6.0pytest-covpytest-timeout
$ python -m lightning_utilities.cli requirements set-oldest
$ cat requirements/test.txtcoverage==5.0codecov==2.1pytest==6.0pytest-covpytest-timeout

About

Common Python utilities and GitHub Actions in Lightning Ecosystem

Topics

Resources

Stars

62 stars

Watchers

7 watching

Forks

Releases

Used by

Contributors

Languages