ops
The Python library behind great charms
What it is and what it does
The ops library is the official Python framework for writing charms—Juju's declarative, event-driven model for managing Kubernetes workloads and machines. It provides a base class (CharmBase) that charm authors subclass to observe Juju events (config changes, pebble readiness, relation changes) and pair them to handler methods. The library abstracts Juju's event model and state management, letting developers focus on charm logic rather than low-level protocol details.
Ops includes a testing module (ops.testing) for unit testing charms in isolation, a Pebble API for managing container workloads, and integrations with PyYAML for configuration, websocket-client for Juju communication, and opentelemetry-api for observability. It is actively maintained by Canonical and is the recommended way to write new charms; the framework is production-stable and widely used in the Juju ecosystem.
Use it for:
- Write a Kubernetes charm to manage a containerized application's lifecycle, configuration, and relations within Juju.
- Unit test charm logic using ops.testing.Context to simulate Juju events and verify charm behavior.
- Define and manage container workloads via the Pebble API, including service startup, configuration, and health checks.
- Handle charm configuration changes and relation events to coordinate multi-charm deployments.
- Integrate observability into charms using opentelemetry-api for tracing and metrics.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Python framework for developing charms—declarative, event-driven applications that manage Kubernetes workloads and machines in Juju environments.
Yes. If you are writing charms for Juju (Kubernetes or machine), ops is the standard, actively maintained framework with low install friction and no security vulnerabilities. It is production-stable and the recommended choice for new charm development. Install it as part of your charm project's dependencies via charmcraft or requirements.txt.
Install
ops on PyPI
pip
pip install opsuv
uv add opspoetry
poetry add opsInstalling ops
Before you install
Low install friction; pure Python wheel with three runtime dependencies (PyYAML, websocket-client, opentelemetry-api). Actively maintained with a recent release and ongoing commits; requires Python 3.10 or above.
License in practice
Licensed under Apache-2.0 (permissive); safe for commercial and proprietary use with minimal attribution requirements.
Quickstart
pip install ops
import ops
class MyCharm(ops.CharmBase):
def __init__(self, *args):
super().__init__(*args)
self.framework.observe(self.on.config_changed, self._on_config_changed)
def _on_config_changed(self, event):
self.unit.status = ops.ActiveStatus()
Requires Python 3.10 or above; intended for use within a Juju charm project structure (typically initialized via charmcraft).
Verify before relying
- Whether ops 3.8.1 is compatible with all currently supported Juju versions.
- Performance characteristics when managing large numbers of containers or relations.
- Maturity of opentelemetry-api integration and observability features.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — PyYAML, websocket-client, opentelemetry-api |
| Maintenance | actively maintained — 15 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 484,840/month — #6,401 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ops-3.8.1-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
charmlibs-pathopsProvides a pathlib-like interface for reading…
permissive · top 15,000 on PyPI
coslProvides utilities for COS Lite charms,…
permissive · top 15,000 on PyPI
jubilantJubilant wraps the Juju CLI with a…
permissive · top 15,000 on PyPI
ops-scenarioops-scenario is a state-transition testing…
permissive · top 15,000 on PyPI
jujuA Python library providing asynchronous…
permissive · top 15,000 on PyPI
pytest-operatorA pytest plugin that provides fixtures and…
permissive · top 15,000 on PyPI
charmcraftlocalPacks Juju charms with local Python package…
unclear · top 15,000 on PyPI
craft-partsCraft Parts provides a declarative framework…
unclear · top 15,000 on PyPI
charmcraftcacheAccelerates charmcraft builds by…
unclear · top 15,000 on PyPI
dagger-ioDagger Python SDK is a client for defining and…
permissive · top 15,000 on PyPI