ops.main entry point

The main entry point to initialise and run your charm.

ops.main(
charm_class: Type[CharmBase],
use_juju_for_storage: bool | None = None,
)

Set up the charm and dispatch the observed event.

Recommended usage:

import ops

class SomeCharm(ops.CharmBase): ...

if __name__ == "__main__":
    ops.main(SomeCharm)
Parameters:
  • charm_class – the charm class to instantiate and receive the event.

  • use_juju_for_storage – whether to use controller-side storage. The default is False for most charms. Podspec charms that haven’t previously used local storage and that are running on a new enough Juju default to controller-side storage, and local storage otherwise.

legacy main module

Support legacy ops.main.main() import.

ops.main.main(
charm_class: Type[CharmBase],
use_juju_for_storage: bool | None = None,
)[source]

Legacy entrypoint to set up the charm and dispatch the observed event.

Deprecated since version 2.16.0: This entrypoint has been deprecated, use ops.main() instead.

See ops.main() for details.