kratix-python
Library documentation can be found here.
Installation
# From PyPI (preferred once published)
pip install kratix-sdk
# From the main branch
pip install git+https://github.com/syntasso/kratix-python.git
# Editable install for local development
pip install -e .
Usage
import kratix_sdk as ks
import yaml
# Initialize the sdk
sdk = ks.KratixSDK()
resource = sdk.read_resource_input()
# Read from resource input
name = resource.get_value("spec.key")
# Write workload documents to OUTPUT_DIR
manifest = {
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {"name": name, "labels": {"app": name}},
"spec": {
"replicas": 1,
"selector": {"matchLabels": {"app": name}},
"template": {
"metadata": {"labels": {"app": name}},
"spec": {
"containers": [
{"name": name, "image": "busybox"}
]
},
},
},
}
data = yaml.safe_dump(manifest).encode("utf-8")
sdk.write_output("deployment.yaml", data)
# Publish status during workflow run
status = ks.Status()
status.set("phase", "updates-from-mid-stage")
sdk.publish_status(resource, status)
# Set status
status = ks.Status()
status.set("message", f"created deployment {key}")
sdk.write_status(status)
# Write destination selectors for dynamic scheduling
selectors: List[ks.DestinationSelector] = [
ks.DestinationSelector(match_labels={"environment": "test"})
]
sdk.write_destination_selectors(selectors)
Development
Library is under kratix_sdk. Examples of Promises using this library can be found under examples.
-
make installinstalls all dependencies -
make testruns all tests undertests/ -
make fmtcode formatting usingruff -
make lintlinting usingruff
See RELEASING.md for the tested release workflow when publishing to TestPyPI/PyPI.
Metadata
Release files for kratix-sdk 0.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kratix_sdk-0.4.3.tar.gz | 73.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kratix_sdk-0.4.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 85.2 kB
Release files / kratix_sdk-0.4.3.tar.gz
| Download URL | kratix_sdk-0.4.3.tar.gz |
|---|---|
| Size | 73.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b65a2b9962e35c3b9b657ec577d4518b0ad5bc5c90618a31e0b45f3708a067ad
|
|
BLAKE2b-256 checksum How to use checksums |
f00356a0d1c4c9d872e5920efc397beba4abe8004abda3a65796d1d6873f7a1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / kratix_sdk-0.4.3-py3-none-any.whl
| Download URL | kratix_sdk-0.4.3-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23bd49a83895cb6f197695f26840699a5023faa337f67cf3e10477f751325c27
|
|
BLAKE2b-256 checksum How to use checksums |
7abc22039a7d084544b4358ab262c9246d7faca4ee060068eac274ff5e89ca76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|