Skip to content

Archie0125/osop-sdk-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OSOP Python SDK

License PyPI Python

Serves both SOP Doc and The Loop. Build workflow tools in Python.

Parse .osop files, validate, render, execute. Build custom SOP Doc viewers or integrate The Loop into Python applications. Sync and async clients.

Website: osop.ai | GitHub: github.com/osop/osop-sdk-py

Installation

pip install osop-sdk

Quick Start

from osop_sdk import OsopClient

client = OsopClient(base_url="http://localhost:8080")

# Validate a workflow
result = client.validate(file_path="deploy.osop.yaml")
print(result.valid)  # True

# Run a workflow in dry-run mode
execution = client.run(
    file_path="deploy.osop.yaml",
    inputs={"environment": "staging"},
    dry_run=True,
)
print(execution.status)  # "completed"

# Render a Mermaid diagram
diagram = client.render(file_path="deploy.osop.yaml", format="mermaid")
print(diagram.content)

# Run test cases
test_result = client.test(file_path="deploy.osop.yaml")
print(f"{test_result.passed}/{test_result.total} passed")

Async Usage

from osop_sdk import AsyncOsopClient

async def main():
    client = AsyncOsopClient(base_url="http://localhost:8080")
    result = await client.validate(file_path="workflow.osop.yaml")
    print(result.valid)

API Reference

OsopClient / AsyncOsopClient

Parameter Type Required Description
base_url str Yes OSOP server base URL
api_key str No API key for authentication
timeout float No Request timeout in seconds (default: 30.0)

Methods

Method Description
validate(content=, file_path=, strict=) Validate a workflow against the schema
run(content=, file_path=, inputs=, dry_run=, timeout_seconds=) Execute a workflow
render(content=, file_path=, format=, direction=) Render a workflow diagram
test(content=, file_path=, filter=, verbose=) Run workflow test cases

Development

git clone https://github.com/osop/osop-sdk-py.git
cd osop-sdk-py
pip install -e ".[dev]"
pytest

License

Apache License 2.0 — see LICENSE for details.

About

osop-sdk-py

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages