Skip to content

Commit 5a94cfd

Browse files
authored
Define a ZenML Bundle (#2)
* Add ZenML bundle
1 parent 266999a commit 5a94cfd

File tree

8 files changed

+86
-16
lines changed

8 files changed

+86
-16
lines changed

CONTRIBUTING.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ source .tox/unit/bin/activate
3131

3232
### Testing
3333

34-
**Unit and integration tests are coming soon!**
35-
3634
```shell
3735
tox -e lint # code style
38-
tox # runs 'lint' and 'fmt' environments
36+
tox # runs 'lint', 'fmt' and 'unit' environments
3937
```
4038

4139
## Build Charm

metadata.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: zenml-server
22
description: |
3-
zenml is a Kubernetes charm bundle for ZenML Server. This bundle automates the deployment and operation of ZenML Server on any Kubernetes cluster.
3+
zenml-server is a Kubernetes charm bundle for ZenML Server. This bundle automates the deployment and operation of ZenML Server on Kubernetes cluster.
44
summary: |
55
A charm which provides a Kubernetes installation of the ZenML (https://www.zenml.io/) server.
6-
docs: https://github.com/RafalSiwek/zenml-operator
6+
docs:
77
containers:
88
zenml-server:
99
resource: oci-image

releases/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# MLflow Operators
2+
3+
## Introduction
4+
5+
Charmed ZenML is a full set of Kubernetes operators to deliver the [ZenML](https://www.zenml.io/), for easy operations on a Kubernetes cluster.
6+
7+
A charm is a software package that includes an operator together with metadata that supports the integration of many operators in a coherent aggregated system.
8+
9+
This technology leverages the Juju Operator Lifecycle Manager to provide day-0 to day-2 operations of Kubeflow.
10+
11+
## Documentation
12+
13+
Read the [Start with Charmed ZenML guide][docs] for more information.
14+
15+
[docs]: https://github.com/RafalSiwek/zenml-server-operator
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
bundle: kubernetes
2+
name: zenml
3+
docs:
4+
applications:
5+
zenml-mysql:
6+
charm: mysql-k8s
7+
channel: 8.0/stable
8+
scale: 1
9+
trust: true
10+
_github_repo_name: mysql-k8s-operator
11+
zenml-server:
12+
charm: zenml-server
13+
channel: latest/edge
14+
scale: 1
15+
trust: true
16+
_github_repo_name: RafalSiwek/zenml-server-operator
17+
relations:
18+
- [zenml-server, zenml-mysql]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type: bundle

requirements-integration.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ aiohttp
22
jinja2
33
# Pinning to <4.0 due to compatibility with the 3.1 controller version
44
juju<4.0
5-
zenml==0.52.0
65
pytest-operator
76
requests
7+
zenml==0.52.0
88
-r requirements.txt

tests/integration/test_bundle.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import logging
2+
import subprocess
3+
4+
import pytest
5+
from pytest_operator.plugin import OpsTest
6+
7+
BUNDLE_PATH = "./releases/latest/edge/zenml/bundle.yaml"
8+
ZENML_APP_NAME = "zenml-server"
9+
10+
logger = logging.getLogger(__name__)
11+
12+
13+
class TestCharm:
14+
@pytest.mark.abort_on_fail
15+
async def test_deploy_bundle_works_and_test_connection(self, ops_test: OpsTest):
16+
subprocess.Popen(["juju", "deploy", f"{BUNDLE_PATH}", "--trust"])
17+
await ops_test.model.wait_for_idle(
18+
apps=[ZENML_APP_NAME],
19+
status="active",
20+
raise_on_blocked=False,
21+
raise_on_error=False,
22+
timeout=1500,
23+
)
24+
assert ops_test.model.applications[ZENML_APP_NAME].units[0].workload_status == "active"
25+
26+
config = await ops_test.model.applications[ZENML_APP_NAME].get_config()
27+
zenml_nodeport = config["zenml_nodeport"]["value"]
28+
zenml_url = f"http://localhost:{zenml_nodeport}"
29+
zenml_subprocess = subprocess.run(
30+
["zenml", "connect", "--url", zenml_url, "--username", "default", "--password", ""]
31+
)
32+
logger.info(f"ZenML command stdout: {zenml_subprocess.stdout}")
33+
if zenml_subprocess.stderr:
34+
logger.info(f"ZenML command stderr: {zenml_subprocess.stderr}")
35+
assert zenml_subprocess.returncode == 0

tox.ini

+13-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ max-line-length = 100
44
[tox]
55
skipsdist = True
66
skip_missing_interpreters = True
7-
envlist = fmt, lint, unit, integration
7+
envlist = fmt, lint, unit
88

99
[vars]
1010
all_path = {[vars]src_path} {[vars]tst_path}
@@ -22,14 +22,6 @@ setenv =
2222
PYTHONBREAKPOINT=ipdb.set_trace
2323
PY_COLORS=1
2424

25-
[testenv:fmt]
26-
commands =
27-
isort {[vars]all_path}
28-
black {[vars]all_path}
29-
deps =
30-
-r requirements-fmt.txt
31-
description = Apply coding style standards to code
32-
3325
[testenv:lint]
3426
commands =
3527
# uncomment the following line if this charm owns a lib
@@ -61,4 +53,15 @@ commands =
6153
pytest -v --tb native --asyncio-mode=auto {[vars]tst_path}integration/test_charm.py --log-cli-level=INFO -s {posargs}
6254
deps =
6355
-r requirements-integration.txt
64-
description = Run integration tests
56+
description = Run integration tests
57+
58+
[testenv:bundle-test]
59+
commands =
60+
pytest -v --tb native --asyncio-mode=auto {[vars]tst_path}integration/test_bundle.py --keep-models --log-cli-level=INFO -s {posargs}
61+
deps =
62+
aiohttp
63+
pytest-operator
64+
ops>=2.3.0
65+
juju==3.0.4
66+
zenml==0.52.0
67+
description = Run bundle test

0 commit comments

Comments
 (0)