Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.2%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Pure Python framework for writing Juju charms
Basic Info
- Host: GitHub
- Owner: canonical
- License: apache-2.0
- Language: Python
- Default Branch: main
- Homepage: https://documentation.ubuntu.com/ops
- Size: 6.15 MB
Statistics
- Stars: 253
- Watchers: 17
- Forks: 125
- Open Issues: 81
- Releases: 61
Topics
Metadata Files
README.md
The ops library
The ops library is a Python framework for developing and testing Kubernetes and machine charms. While charms can be written in any language, ops defines the latest standard, and charmers are encouraged to use Python with ops for all charms. The library is an official component of the Charm SDK, itself a part of the Juju universe.
opsis available on PyPI.- The latest version of
opsrequires Python 3.10 or above.- Read our docs for tutorials, how-to guides, the library reference, and more.
Give it a try
Let's use ops to build a Kubernetes charm:
Set up
See Juju | Set things up.
Choose the automatic track and MicroK8s.
Write your charm
On your Multipass VM, create a charm directory and use Charmcraft to initialise your charm file structure:
shell-script
mkdir ops-example
cd ops-example
charmcraft init
This has created a standard charm directory structure:
```shell-script $ ls -R .: CONTRIBUTING.md README.md pyproject.toml src tox.ini LICENSE charmcraft.yaml requirements.txt tests
./src: charm.py
./tests: integration unit
./tests/integration: test_charm.py
./tests/unit: test_charm.py ```
Things to note:
The
charmcraft.yamlfile shows that what we have is an example charm calledops-example, which uses an OCI image resourcehttpbinfromkennethreitz/httpbin.The
requirements.txtfile lists the version ofopsto use.The
src/charm.pyfile importsopsand usesopsconstructs to create a charm classOpsExampleCharm, observe Juju events, and pair them to event handlers:
```python import ops
class OpsExampleCharm(ops.CharmBase): """Charm the service."""
def __init__(self, *args):
super().__init__(*args)
self.framework.observe(self.on['httpbin'].pebble_ready, self._on_httpbin_pebble_ready)
self.framework.observe(self.on.config_changed, self._on_config_changed)
def _on_httpbin_pebble_ready(self, event: ops.PebbleReadyEvent):
"""Define and start a workload using the Pebble API.
Change this example to suit your needs. You'll need to specify the right entrypoint and
environment configuration for your specific workload.
Learn more about interacting with Pebble at
https://documentation.ubuntu.com/ops/latest/reference/pebble/
"""
# Get a reference the container attribute on the PebbleReadyEvent
container = event.workload
# Add initial Pebble config layer using the Pebble API
container.add_layer("httpbin", self._pebble_layer, combine=True)
# Make Pebble reevaluate its plan, ensuring any services are started if enabled.
container.replan()
# Learn more about statuses at
# https://documentation.ubuntu.com/juju/3.6/reference/status/
self.unit.status = ops.ActiveStatus()
```
See more:
ops.PebbleReadyEvent
- The
tests/unit/test_charm.pyfile importsops.testingand uses it to set up a unit test:
```python import ops from ops import testing
from charm import OpsExampleCharm
def testhttpbinpebbleready(): # Arrange: ctx = testing.Context(OpsExampleCharm) container = testing.Container("httpbin", canconnect=True) state_in = testing.State(containers={container})
# Act:
state_out = ctx.run(ctx.on.pebble_ready(container), state_in)
# Assert:
updated_plan = state_out.get_container(container.name).plan
expected_plan = {
"services": {
"httpbin": {
"override": "replace",
"summary": "httpbin",
"command": "gunicorn -b 0.0.0.0:80 httpbin:app -k gevent",
"startup": "enabled",
"environment": {"GUNICORN_CMD_ARGS": "--log-level info"},
}
},
}
assert expected_plan == updated_plan
assert (
state_out.get_container(container.name).service_statuses["httpbin"]
== ops.pebble.ServiceStatus.ACTIVE
)
assert state_out.unit_status == testing.ActiveStatus()
```
See more:
ops.testing
Explore further, start editing the files, or skip ahead and pack the charm:
shell-script
charmcraft pack
If you didn't take any wrong turn or simply left the charm exactly as it was, this has created a file called ops-example_ubuntu-22.04-amd64.charm (the architecture bit may be different depending on your system's architecture). Use this name and the resource from the metadata.yaml to deploy your example charm to your local MicroK8s cloud:
shell-script
juju deploy ./ops-example_ubuntu-22.04-amd64.charm --resource httpbin-image=kennethreitz/httpbin
Congratulations, you’ve just built your first Kubernetes charm using ops!
Clean up
See Juju | Tear things down.
Choose the automatic track.
Next steps
- Read the docs.
- Read our Code of conduct and join our chat and forum or open an issue.
- Read our CONTRIBUTING guide and contribute!
Owner
- Name: Canonical
- Login: canonical
- Kind: organization
- Location: London, UK
- Website: https://canonical.com
- Twitter: Canonical
- Repositories: 1,802
- Profile: https://github.com/canonical
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Pietro Pasotti | s****n@g****m | 444 |
| Tony Meyer | t****r@c****m | 293 |
| Ben Hoyt | b****t@c****m | 129 |
| Tiexin Guo | t****o@c****m | 75 |
| chipaca | c****a | 70 |
| Dima Tisnek | d****k@c****m | 50 |
| John Arbash Meinel | j****n@a****m | 49 |
| Dmitrii Shcherbakov | d****b | 44 |
| Cory Johns | j****a@g****m | 33 |
| James Garner | j****r@c****m | 33 |
| dependabot[bot] | 4****] | 27 |
| Dave Wilding | d****g@c****m | 26 |
| Robert Carlsen | r****n@c****m | 21 |
| Jon Seager | j****r@c****m | 18 |
| Facundo Batista | f****o@t****r | 17 |
| Ryan Barry | r****y@c****m | 16 |
| Gustavo Niemeyer | g****o@n****t | 15 |
| Jose C. Massón | j****n@c****m | 13 |
| Pete Vander Giessen | p****g@g****m | 12 |
| Leon | 8****i | 9 |
| Teodora Mihoc | t****c@g****m | 5 |
| Prints Charming | b****t@c****m | 5 |
| Michele Mancioppi | m****i@c****m | 5 |
| Harry Pidcock | h****k@c****m | 4 |
| Paul Goins | g****l@v****t | 4 |
| Weii Wang | w****g@c****m | 4 |
| Balbir Thomas | b****s@h****m | 4 |
| mthaddon | t****m@h****t | 3 |
| Yanks Yoon | 3****n | 3 |
| Harish Navnit | h****t@g****m | 3 |
| and 39 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 394
- Total pull requests: 1,263
- Average time to close issues: 8 months
- Average time to close pull requests: 7 days
- Total issue authors: 81
- Total pull request authors: 40
- Average comments per issue: 2.92
- Average comments per pull request: 1.49
- Merged pull requests: 976
- Bot issues: 0
- Bot pull requests: 62
Past Year
- Issues: 171
- Pull requests: 773
- Average time to close issues: 25 days
- Average time to close pull requests: 6 days
- Issue authors: 29
- Pull request authors: 17
- Average comments per issue: 1.12
- Average comments per pull request: 1.33
- Merged pull requests: 572
- Bot issues: 0
- Bot pull requests: 31
Top Authors
Issue Authors
- tonyandrewmeyer (54)
- dimaqq (50)
- benhoyt (48)
- sed-i (40)
- PietroPasotti (32)
- dwilding (27)
- rwcarlsen (9)
- stub42 (8)
- jameinel (7)
- james-garner-canonical (7)
- pengale (7)
- gruyaume (4)
- balbirthomas (4)
- arturo-seijas (3)
- weiiwang01 (3)
Pull Request Authors
- tonyandrewmeyer (436)
- dimaqq (186)
- IronCore864 (147)
- benhoyt (126)
- dwilding (109)
- james-garner-canonical (82)
- dependabot[bot] (61)
- PietroPasotti (34)
- prints-charming-bot (16)
- tmihoc (8)
- sed-i (5)
- weiiwang01 (4)
- jameinel (3)
- ghislainbourgeois (3)
- carlcsaposs-canonical (3)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 5
-
Total downloads:
- pypi 379,354 last-month
- Total docker downloads: 4,331
-
Total dependent packages: 9
(may contain duplicates) -
Total dependent repositories: 482
(may contain duplicates) - Total versions: 167
- Total maintainers: 7
- Total advisories: 1
pypi.org: ops
The Python library behind great charms
- Homepage: https://documentation.ubuntu.com/ops/latest/
- Documentation: https://documentation.ubuntu.com/ops/latest/
- License: apache-2.0
-
Latest release: 3.2.0
published 6 months ago
Rankings
Maintainers (4)
Advisories (1)
pypi.org: smooth
- Homepage: https://github.com/canonical/operator
- Documentation: https://smooth.readthedocs.io/
- License: apache-2.0
-
Latest release: 0.0.1
published almost 6 years ago
Rankings
Maintainers (1)
pypi.org: ops-scenario
Python library providing a state-transition testing API for Operator Framework charms.
- Homepage: https://github.com/canonical/operator
- Documentation: https://ops-scenario.readthedocs.io/
- License: apache-2.0
-
Latest release: 8.2.0
published 6 months ago
Rankings
Maintainers (1)
spack.io: py-ops
The Python library behind great charms
- Homepage: https://github.com/canonical/operator
- License: []
-
Latest release: 2.16.0
published over 1 year ago
Rankings
pypi.org: ops-tracing
The tracing facility for the Ops library.
- Documentation: https://documentation.ubuntu.com/ops/latest/
- License: apache-2.0
-
Latest release: 3.2.0
published 6 months ago
Rankings
Maintainers (3)
Dependencies
- sphinx ==3.
- sphinx_rtd_theme *
- PyYAML *
- typing_extensions ==4.2.0
- PyYAML *
- PyYAML *
- actions/checkout v3 composite
- canonical/setup-lxd ea57509243d3cf39f8ab926e021bb353947b01b5 composite
- actions/checkout v3 composite
- actions/checkout v3 composite
- actions/setup-go v1 composite
- actions/setup-python v2 composite
- actions/checkout v3 composite
- actions/setup-python v2 composite
- actions/checkout v3 composite
- actions/checkout v3 composite
- actions/setup-python v1 composite
- pypa/gh-action-pypi-publish release/v1 composite
- furo *
- lxd-sphinx-extensions *
- sphinx ==6.2.1
- sphinx-copybutton *
- sphinx-design *
- sphinx-tabs *