Ops 3.4.0b1 (and ops-scenario 8.4.0b1 and ops-tracing 3.4.0b1) released

This is a beta release of Ops, so you won’t pick it up automatically with pinning like ~3.1, and may need to explicitly allow pre-releases to use it - for example, uvx --with=ops[testing]==3.4.0b1 --prerelease=allow python


The main feature in this release is the introduction of ops.hookcmds, which provides an API to the Juju hook commands. The API is low-level, complete (other than deprecated commands), and generally a 1-1 mapping to the hook commands, but providing a Pythonic interface.

The intention is that this makes it easier to build experimental charm APIs or frameworks (in particular, having the Juju knowledge encapsulated in Ops) rather than for charms to use the ops.hookcmds package directly.

This new API is also used by the Ops model, which is the primary reason we are doing a beta release. We’re confident that there will be no charm-visible differences, but this is at the heart of the framework, so we would really appreciate you trying it out and letting us know if there are any issues.

If you are a Canonical employee attending the upcoming events in Sweden: run your charms’ integration tests using ops 3.4.0b1, DM me the results, find me in either week, and as thanks, you’ll get a small, sweet, New Zealand treat. If you’re not a Canonical employee, or won’t be there, but do test it out, message me and I’ll see what I can do.


There’s also a breaking change to ops.testing as part of a bug fix in this release. If you have tests like:

with pytest.raises(MyCharmError):
    with ctx(ctx.on.update_status(), state_in) as mgr:
        mgr.run()

Then you’ll need to update those to look like:

from ops.testing import errors
...
with pytest.raises(errors.UncaughtCharmError) as exc_info:
    with ctx(ctx.on.update_status(), state_in) as mgr:
        mgr.run()
# You might assert here that the wrapped exception is still MyCharmError.

(Please direct any hate for UncaughtCharmError to hearts on this ops issue.)

There are also the usual bug fixes, documentation improvements, and small features. Read more in the full release notes on GitHub .

1 Like