Skip to main content

TWS client for Python.

Project description

tws-sdk

Python client for TWS.

Installation

pip install tws-sdk

Usage

The library provides both synchronous and asynchronous clients for interacting with TWS.

The primary API is run_workflow, which executes a workflow configured via the TWS UI, waits for completion, and returns the result.

Synchronous Usage

from tws import Client as TWSClient

# Use the client with a context manager
with TWSClient(
    public_key="your_public_key",
    secret_key="your_secret_key",
    api_url="your_api_url"
) as tws_client:
    # Run a workflow and wait for completion
    result = tws_client.run_workflow(
        workflow_definition_id="your_workflow_id",
        workflow_args={
            "param1": "value1",
            "param2": "value2"
        },
    )

Asynchronous Usage

The signatures are exactly the same for async usage, but the client class is TWSAsyncClient and client methods are awaited.

from tws import AsyncClient as TWSAsyncClient


async def main():
    # Use the async client with a context manager
    async with TWSAsyncClient(
        public_key="your_public_key",
        secret_key="your_secret_key",
        api_url="your_api_url"
    ) as tws_client:
        # Run a workflow and wait for completion
        result = await tws_client.run_workflow(
            workflow_definition_id="your_workflow_id",
            workflow_args={
                "param1": "value1",
                "param2": "value2"
            },
        )

Tags

You can specify tags, which are string key-value pairs, when calling the run_workflow method. These tags can then be used when designing workflows in TWS to lookup and filter the results of workflow runs. This allows you to associate the results of a workflow run with a specific entity or grouping mechanism within your system, such as a user ID or a lesson ID.

Provide tags to the run_workflow method as a dictionary. Keep in mind that both tag keys and values must be strings that are at most 255 characters long.

tws_client.run_workflow(
    workflow_definition_id="your_workflow_id",
    workflow_args={
        "param1": "value1",
        "param2": "value2"
    },
    tags={
        "user_id": "12345",
        "lesson_id": "67890"
    }
)

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

tws_sdk-0.3.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

tws_sdk-0.3.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file tws_sdk-0.3.0.tar.gz.

File metadata

  • Download URL: tws_sdk-0.3.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tws_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4600f99d7ee35de96b7b5e34de5b18b03dc73355b1b7308de974fac0d11219dd
MD5 9eae208ce3617ef952c914d8986ab203
BLAKE2b-256 c5d8523ce4081fa06c3da59eea2c0edc7fe0c2ac3091f418b349397f25739434

See more details on using hashes here.

Provenance

The following attestation bundles were made for tws_sdk-0.3.0.tar.gz:

Publisher: publish.yaml on Fireline-Science/tws-py

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

File details

Details for the file tws_sdk-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: tws_sdk-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tws_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09ea2daf4aae566bb741d173fad4abfb298e3ce91bdeb5e91921e28ecc30215b
MD5 35fbf8bb7ea7d8c41595fa9a936a84db
BLAKE2b-256 0d261bac7f2adcf0c6fe41f363db743cfdc0dae9ae8e9711e2fefdbc3acd74db

See more details on using hashes here.

Provenance

The following attestation bundles were made for tws_sdk-0.3.0-py3-none-any.whl:

Publisher: publish.yaml on Fireline-Science/tws-py

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