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
Release history Release notifications | RSS feed
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 ss_pyworkflow-0.1.2.tar.gz.
File metadata
- Download URL: ss_pyworkflow-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0379a138975baf231969c2af79c55da9ce1ce11c3039fa0a41ee96ae687c5e7
|
|
| MD5 |
62a6eeb3e84decb2913c7a2688d1801e
|
|
| BLAKE2b-256 |
62230990029afc630f1f4a9e6761bb1207eff771cbbdbd6f154495828815dd31
|
File details
Details for the file ss_pyworkflow-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ss_pyworkflow-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29ddd5df352cf7f8bf7325cf7ff234a0bcb4d2794bae39954a8cbcfffd3d8a7d
|
|
| MD5 |
d179c7768ed989f893658bcf269c38d3
|
|
| BLAKE2b-256 |
5daf4ae4a74b43b3555393b28a8376d7e34d213f6b261be7b9fdf4b92f3b6aad
|