Skip to main content

Python SDK for Perceptic Workflow definitions - cross-language Temporal workflow types

Project description

Perceptic Workflow SDK

Python SDK for Perceptic Workflow definitions. This package provides cross-language Temporal workflow types that are compatible with the Java workflow definitions in perceptic-core-client.

Installation

pip install perceptic-workflow-sdk

Usage

Workflow Events

from perceptic_workflow import (
    WorkflowEvent,
    InfoEvent,
    CheckpointEvent,
    UserInputEvent,
    UserInputRequestEvent,
    WorkflowCheckpointStatus,
)

# Create events
info_event = InfoEvent(
    event_id=1,
    type="progress",
    payload={"step": "processing"},
    timestamp=datetime.now()
)

Implementing Workflows

The SDK provides a mixin class for implementing Perceptic-compatible workflows:

from temporalio import workflow
from perceptic_workflow import PercepticWorkflowMixin, WorkflowEvent

@workflow.defn
class MyWorkflow(PercepticWorkflowMixin):
    def __init__(self):
        self._events: list[WorkflowEvent] = []
        self._paused = False

    @workflow.run
    async def run(self, input: dict) -> dict:
        # Your workflow logic here
        pass

    @workflow.update(name=PercepticWorkflowMixin.UPDATE_SUBMIT_USER_INPUT)
    async def submit_user_input(self, inputs: dict) -> None:
        self._paused = False
        # Handle user input

    @workflow.update(name=PercepticWorkflowMixin.UPDATE_INTERRUPT)
    async def interrupt(self, reason: str) -> None:
        # Handle interruption
        pass

    @workflow.query(name=PercepticWorkflowMixin.QUERY_IS_PAUSED)
    def is_paused(self) -> bool:
        return self._paused

    @workflow.query(name=PercepticWorkflowMixin.QUERY_GET_EVENTS)
    def get_events(self, after_event_id: int | None = None) -> list[WorkflowEvent]:
        if after_event_id is None:
            return self._events
        return [e for e in self._events if e.event_id > after_event_id]

Compatibility

This package is designed to be compatible with:

  • perceptic-core-client (Java)
  • perceptic-core-workflow-runtime (Java)

The workflow definitions and event types are generated from the same JSON Schema sources to ensure cross-language compatibility.

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

perceptic_workflow_sdk-0.50.94.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

perceptic_workflow_sdk-0.50.94-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file perceptic_workflow_sdk-0.50.94.tar.gz.

File metadata

  • Download URL: perceptic_workflow_sdk-0.50.94.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for perceptic_workflow_sdk-0.50.94.tar.gz
Algorithm Hash digest
SHA256 928f029b46a800c9a8d7e1fe212fecf2282034ea526b60e3bc30354c873a00a5
MD5 6e7405295c62604e6fa6890daa9e27a7
BLAKE2b-256 bf3f27c58264115519658ab0489f30db0ea9ea8cf15758230d10ac68bfd87186

See more details on using hashes here.

Provenance

The following attestation bundles were made for perceptic_workflow_sdk-0.50.94.tar.gz:

Publisher: publish-python.yml on perceptic/perceptic-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file perceptic_workflow_sdk-0.50.94-py3-none-any.whl.

File metadata

File hashes

Hashes for perceptic_workflow_sdk-0.50.94-py3-none-any.whl
Algorithm Hash digest
SHA256 61b779f4810301e12440e1688996152453a3b61f6ad8e10d1ffa61ca6fd4e344
MD5 8996b39e10b3252c58b2691264ef2e3d
BLAKE2b-256 0fbbf68d951080b4e072c10e17cc2a6be491ef3248f01fe222183c05d2d499f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for perceptic_workflow_sdk-0.50.94-py3-none-any.whl:

Publisher: publish-python.yml on perceptic/perceptic-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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