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.
opsnow reads all the v2 metadata fields (both frommetadata.yamlfor production and fromcharmcraft.yamlfor when you’re running tests).- A
ModelErroris raised if an invalid status type is set in Harness, mirroring what happens with Juju in production.