Skip to main content

Python SDK for the Stitch workflow execution engine

Project description

stitch-eng-sdk

Python SDK for the Stitch workflow execution engine.

Install

pip install stitch-eng-sdk

Quickstart (Embedded Zero-Config Mode)

Stitch comes with an embedded Go binary so you don't even need to start a server locally!

import threading
import stitch

@stitch.task(max_attempts=5)
def charge_payment(order_id, amount):
    return {"txn_id": "txn_123"}

@stitch.task
def send_email(email, txn_id):
    return {"sent": True}

@stitch.workflow
def process_order(inp):
    # Pass the output of one task directly to the next to create a dependency!
    payment = charge_payment(order_id=inp["order_id"], amount=inp["amount"])
    send_email(email=inp["email"], txn_id=payment["txn_id"])

# 1. Start the embedded server and client
client = stitch.Client()

# 2. Start a background worker to poll for tasks
worker = stitch.Worker(client, tasks=[charge_payment, send_email])
threading.Thread(target=worker.start, daemon=True).start()

# 3. Submit the workflow and wait for it to finish!
result = client.run(process_order, input={
    "order_id": "ORD-001",
    "amount": 9897,
    "email": "user@example.com",
}).wait()

print(result.status)  # → "completed"

worker.stop()
client.close()

Cloud Mode

To connect to the hosted Stitch backend, just pass your API key — the server URL is handled automatically:

client = stitch.Client(api_key="sk_your_api_key")

Full Cloud Example

import threading
import stitch

@stitch.task(max_attempts=5)
def charge_payment(order_id, amount):
    return {"txn_id": "txn_123"}

@stitch.task
def send_email(email, txn_id):
    return {"sent": True}

@stitch.workflow
def process_order(inp):
    payment = charge_payment(order_id=inp["order_id"], amount=inp["amount"])
    send_email(email=inp["email"], txn_id=payment["txn_id"])

# Connect to Stitch Cloud
client = stitch.Client(api_key="sk_your_api_key")

# Start a background worker
worker = stitch.Worker(client, tasks=[charge_payment, send_email])
threading.Thread(target=worker.start, daemon=True).start()

# Submit and wait
result = client.run(process_order, input={
    "order_id": "ORD-001",
    "amount": 9897,
    "email": "user@example.com",
}).wait()

print(result.status)  # → "completed"

worker.stop()
client.close()

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

stitch_eng_sdk-0.2.3.tar.gz (38.1 MB view details)

Uploaded Source

Built Distribution

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

stitch_eng_sdk-0.2.3-py3-none-any.whl (38.6 MB view details)

Uploaded Python 3

File details

Details for the file stitch_eng_sdk-0.2.3.tar.gz.

File metadata

  • Download URL: stitch_eng_sdk-0.2.3.tar.gz
  • Upload date:
  • Size: 38.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for stitch_eng_sdk-0.2.3.tar.gz
Algorithm Hash digest
SHA256 f453a968b9fe393de0e9633bed1ef099e0e92da0f6a2fc8ce3d7b7e4f374a27e
MD5 6d6cc64a2825fa328f54938f2f0694b4
BLAKE2b-256 ee30039bd6c8f1cd9bc899276cda4e0b315fcfbeb8aabccc72f128bf2a962bbb

See more details on using hashes here.

File details

Details for the file stitch_eng_sdk-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: stitch_eng_sdk-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 38.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for stitch_eng_sdk-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 021009564bc3e42b4b3413bde6f54b1940292353deb26a6e303c01a552ad79b2
MD5 c9a962d26154e8d430447ea219247b22
BLAKE2b-256 bd3a103477b3dbd82106cb141928324f68b35c4155cfa6e99aa064b76971ae99

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