skillfed

ops

The Python library behind great charms

ops v3.8.1 484.8K downloads/30d#6,401 on PyPI265
Permissive license Apache-2.0 Active released

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 ops

uv

uv add ops

poetry

poetry add ops

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: System AdministratorsOperating System :: MacOS :: MacOS XOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3

Tags

juju charm development pythonkubernetes charm frameworkjuju ops librarycharm sdk pythondeclarative workload managementjuju event-driven applicationscharm testing framework
jujucharm-developmentkubernetes-orchestration

More Application Frameworks packages