Skip to main content

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 install installs all dependencies

  • make test runs all tests under tests/

  • make fmt code formatting using ruff

  • make lint linting using ruff

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

kratix_sdk-0.4.3.tar.gz (73.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kratix_sdk-0.4.3-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

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

Hashes for kratix_sdk-0.4.3.tar.gz
Algorithm Hash digest
SHA256 b65a2b9962e35c3b9b657ec577d4518b0ad5bc5c90618a31e0b45f3708a067ad
MD5 071709c85f749e37addda779d8be536a
BLAKE2b-256 f00356a0d1c4c9d872e5920efc397beba4abe8004abda3a65796d1d6873f7a1b

See more details on using hashes here.

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

Hashes for kratix_sdk-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 23bd49a83895cb6f197695f26840699a5023faa337f67cf3e10477f751325c27
MD5 28dcc6199df4c9386f3cbf7ac4d7830e
BLAKE2b-256 7abc22039a7d084544b4358ab262c9246d7faca4ee060068eac274ff5e89ca76

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page