ops library 2.10.0 released: Pebble custom notices, improvements to relation-broken, and more

The Charm Tech team has just released version 2.10.0 of ops.

It’s available from PyPI by using pip install ops, which should pick up the latest version (pin with ops==2.10.0 if you want to pin to a specific version).

In addition to smaller improvements to docs and tests and some bug fixes, there are two main changes to note:

Pebble Notices

Ops now supports the new Pebble Notices feature - right now, this means that you can use custom notices with Juju 3.4+, allowing the workload to signal to Juju (via Pebble) that the charm should be woken up to do something - for example, perhaps a backup job has completed and the output should be moved somewhere appropriate. See the release notes and docs for more details about this works and how to make use of custom notices with your workloads.

relation-broken

Relation objects now have an .active attribute that will be True unless the charm was woken up to handle a relation-broken event, and the specific relation is the one that is now broken. In addition, Model.relations now excludes the broken relation, so you can iterate through .relations and get only active relations (for example, if you’re building a config).

More!

  • If a charm crashes when handling an action, Juju will now show you information about what happened and suggest going to the debug-log for the full traceback.
  • ops now reads all the v2 metadata fields (both from metadata.yaml for production and from charmcraft.yaml for when you’re running tests).
  • A ModelError is raised if an invalid status type is set in Harness, mirroring what happens with Juju in production.

Read more in the full release notes on GitHub.