Skip to main content

This is for workflow tracing on python environment.

Project description

My Dear Colleagues

This repository is for QA tools(workflows), you can use this on your python projects.

SS-PyWorkflow

This project is designed to simplify and standardize workflow execution using decorators to automate task execution and result tracking. It is primarily used for llm-graph, but it can be extended to other projects as well.


🚀 Installation

pip install ss-pyworkflow

Environment Variables

To configure the Workflow Monitoring Service, please add the following environment variables to your .env file or your environment settings:

Variable Name Description Example Value
WORKFLOW_MONITORING_URL The endpoint URL for sending data. https://example.com/api/v1/log
WORKFLOW_MONITORING_API_KEY The API key for authentication. your-secret-api-key

Example:

WORKFLOW_MONITORING_URL=https://example.com/api/v1/log
WORKFLOW_MONITORING_API_KEY=your-secret-api-key

📖 Usage

SS-PyWorkflow provides two main modes for managing workflows:

1️⃣ Single Function Mode

When you only need to track a single function, you can use the @workflow_entry decorator:

from ss_pyworkflow import workflow_entry

@workflow_entry(name="llm-graph")
async def _run_multigraph(**kwargs):
    # Your logic here...
    ...

After the function execution is completed, the result of this node will automatically be sent to the specified workflow backend and trigger the workflow end signal.

2️⃣ Chained Function Mode

If your workflow consists of multiple functions that execute sequentially, and each function's output is the next function's input, use the @workflow_lifecycle decorator:

from ss_pyworkflow import workflow_lifecycle

@workflow_lifecycle()
async def aexecute(self, state: AgentStateT) -> AgentStateT:
    # Each function's output will be passed to the next function
    ...

In this mode, after each function execution, data is automatically sent to the workflow and visualized as step-by-step nodes in the backend.

⚙️ Kwargs Explanation

Both @workflow_entry and @workflow_lifecycle require workflow_trace_data to be passed in kwargs for proper tracking and data transmission:

"workflow_trace_data": {
    "enable": true,
    "traceId": "592225192fb1ac17022e80c85fb8a749",
    "prevSpanId": "3f7decc34dc8d03a",
    "userId": "202505125600020250512145500563QSLVDGS96F",
    "projectId": "mtr-kiosk-pquzibd",
    "componentName": "llm-graph",
    "post_url": "https://dev.setsailapi.com/workflow/v1/event",
    "log_enabled": true
}

Parameter Description:

Parameter Name Type Description
enable bool Whether to enable the workflow. If False, no operations will be performed.
traceId str A unique identifier for the entire workflow execution (32-character hexadecimal format).
prevSpanId str The parent span ID (16-character hexadecimal format). Can be null for root spans.
userId str The user ID that triggers this workflow.
projectId str The project ID associated with this workflow.
componentName str Specifies the name of the workflow (e.g., llm-graph).
post_url str The backend API URL to send workflow data.
log_enabled bool Whether to enable logging.

📌 Examples

Single Function Mode

from ss_pyworkflow import workflow_entry

@workflow_entry(name="llm-graph")
async def run_task(**kwargs):
    print("Executing task...")

Chained Function Mode

from ss_pyworkflow import workflow_lifecycle

@workflow_lifecycle()
async def task_one(state):
    print("Task One")
    return state

@workflow_lifecycle()
async def task_two(state):
    print("Task Two")
    return state

🌐 Extension Support

Currently, it is mainly focused on llm-graph, but it can be extended to other workflow scenarios by modifying the decorators or adding new ones.

License

This project is licensed under the Apache License 2.0.
Copyright © 2025 Set Sail Venture Limited

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

ss_pyworkflow-0.1.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

ss_pyworkflow-0.1.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file ss_pyworkflow-0.1.1.tar.gz.

File metadata

  • Download URL: ss_pyworkflow-0.1.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for ss_pyworkflow-0.1.1.tar.gz
Algorithm Hash digest
SHA256 af0dd73522378f38935c8b74def7eb315e24de2a205c3473d6bbd144a4a5bd39
MD5 3a400df82e9705330a7fd78a8c5407c7
BLAKE2b-256 f8079d3d4266c0efd9097af6a721dd7f43d3f3060f294ebeef485a98a25b71dc

See more details on using hashes here.

File details

Details for the file ss_pyworkflow-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ss_pyworkflow-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for ss_pyworkflow-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dbd5bae742d857306c9c53879f1ccebf93c7db508336ff58e2fa7acc52000077
MD5 9f55ac7cfa0ee2a742382d1948b4479f
BLAKE2b-256 d8bee92e51b1309edbcf9e5553461a009a23895cae8b7353760731021b26b0f6

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