From 295d79152757e18dded7d0c2b12fa9b7428694ca Mon Sep 17 00:00:00 2001 From: Sean Schaefer Date: Tue, 31 Dec 2024 17:12:59 -0700 Subject: [PATCH 1/3] ci: add PyPI publishing workflow --- .github/workflows/publish.yaml | 84 +++++++++++++++++++++++++++++ .github/workflows/pull-request.yaml | 3 ++ pyproject.toml | 5 +- 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..7f768db --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,84 @@ +name: Publish TestPyPI +on: + push: + branches: + - main + - ci/pypi-publishing + tags: + - '*' +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Set up Poetry + uses: abatilo/actions-poetry@v3 + with: + poetry-version: 1.8.4 + + - name: Install dependencies + run: poetry install + + - name: Build distribution + run: poetry build + + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/tws-sdk + permissions: + id-token: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish dists to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + publish-to-testpypi: + name: Publish to TestPyPI + needs: + - build + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/tws-sdk + + permissions: + id-token: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish dists to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index c22b815..40e9262 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -29,6 +29,9 @@ jobs: - name: Install dependencies run: poetry install + - name: Build distribution + run: poetry build + - name: Add Poetry Python binary to PATH run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH diff --git a/pyproject.toml b/pyproject.toml index a39b29a..04acede 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "tws" +name = "tws-sdk" version = "0.1.0" description = "TWS client for Python." authors = ["Fireline Science "] @@ -13,6 +13,9 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent" ] +packages = [ + {include = "tws"} +] [tool.poetry.dependencies] python = "^3.9" From f7f2a3f5d3876ef19e6cc07404070fe606c22723 Mon Sep 17 00:00:00 2001 From: Sean Schaefer Date: Thu, 2 Jan 2025 07:11:27 -0700 Subject: [PATCH 2/3] ci: remove test pypi publish and add docs Unfortunately Supabase does not publish on Test PyPI so we can't install from it, so not much point for us to publish to it. --- .github/workflows/publish.yaml | 29 +---------------- README.md | 59 +++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 29 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 7f768db..a22b7ea 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,9 +1,6 @@ -name: Publish TestPyPI +name: Publish to PyPI on: push: - branches: - - main - - ci/pypi-publishing tags: - '*' jobs: @@ -58,27 +55,3 @@ jobs: path: dist/ - name: Publish dists to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - - publish-to-testpypi: - name: Publish to TestPyPI - needs: - - build - runs-on: ubuntu-latest - - environment: - name: testpypi - url: https://test.pypi.org/p/tws-sdk - - permissions: - id-token: write - - steps: - - name: Download all the dists - uses: actions/download-artifact@v4 - with: - name: python-package-distributions - path: dist/ - - name: Publish dists to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ diff --git a/README.md b/README.md index e052bed..79bd7b9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,64 @@ Python client for [TWS](https://www.tuneni.ai). +## Installation + +```bash +pip install tws-sdk +``` ## Usage -TBC +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 + +```python +from tws import create_client + +# Create a client instance +client = create_client( + public_key="your_public_key", + secret_key="your_secret_key", + api_url="your_api_url" +) + +# Run a workflow and wait for completion +result = 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 is created using `create_async_client` and client +methods are awaited. + +```python +from tws import create_async_client + + +async def main(): + # Create an async client instance + client = await create_async_client( + public_key="your_public_key", + secret_key="your_secret_key", + api_url="your_api_url" + ) + + # Run a workflow and wait for completion + result = await client.run_workflow( + workflow_definition_id="your_workflow_id", + workflow_args={ + "param1": "value1", + "param2": "value2" + }, + ) +``` \ No newline at end of file From bd8a99cb3066f5fc2b1bb2aa09496c8b1dd2b8b9 Mon Sep 17 00:00:00 2001 From: Sean Schaefer Date: Thu, 2 Jan 2025 07:17:13 -0700 Subject: [PATCH 3/3] ci: no need to check for tag push anymore --- .github/workflows/publish.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index a22b7ea..3bedad1 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -37,7 +37,6 @@ jobs: publish-to-pypi: name: Publish to PyPI - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes needs: - build runs-on: ubuntu-latest