Kratix SDK for writing Promises workflows
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kratix_sdk-0.4.3.tar.gz.
File metadata
- Download URL: kratix_sdk-0.4.3.tar.gz
- Upload date:
- Size: 73.4 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b65a2b9962e35c3b9b657ec577d4518b0ad5bc5c90618a31e0b45f3708a067ad
|
|
| MD5 |
071709c85f749e37addda779d8be536a
|
|
| BLAKE2b-256 |
f00356a0d1c4c9d872e5920efc397beba4abe8004abda3a65796d1d6873f7a1b
|
File details
Details for the file kratix_sdk-0.4.3-py3-none-any.whl.
File metadata
- Download URL: kratix_sdk-0.4.3-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23bd49a83895cb6f197695f26840699a5023faa337f67cf3e10477f751325c27
|
|
| MD5 |
28dcc6199df4c9386f3cbf7ac4d7830e
|
|
| BLAKE2b-256 |
7abc22039a7d084544b4358ab262c9246d7faca4ee060068eac274ff5e89ca76
|