Skip to content

Commit a62b341

Browse files
committed
client: Extend Python version support
Extend support to Python versions 3.10, 3.11, 3.12, and 3.13, updating pyproject.toml and poetry.lock accordingly. Split the Python tests CI action to run the client tests separately on all supported Python versions and update the publish-client workflow to rely on the new job. Extending Python version support allows for broader compatibility and is an easy win given the minimal client dependencies. Remove automated PyPI publishing for now. Signed-off-by: Phoevos Kalemkeris <[email protected]>
1 parent 7c73b73 commit a62b341

File tree

9 files changed

+462
-17
lines changed

9 files changed

+462
-17
lines changed

.github/workflows/client-ci.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Client Python tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*.*.*"
9+
paths:
10+
- "client/**"
11+
pull_request:
12+
paths:
13+
- "client/**"
14+
15+
jobs:
16+
unit:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
python-version: ["3.10", "3.11", "3.12", "3.13"]
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Install Poetry
32+
run: |
33+
curl -sSL https://install.python-poetry.org | python3 -
34+
35+
- name: Install dependencies
36+
run: |
37+
poetry install -P client --with dev
38+
39+
- name: Run client tests
40+
run: |
41+
poetry run -P client pytest tests/unit/client

.github/workflows/ci.yaml renamed to .github/workflows/cmg-ci.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python tests
1+
name: Gateway Python tests
22

33
on:
44
push:
@@ -27,13 +27,11 @@ jobs:
2727
2828
- name: Install dependencies
2929
run: |
30-
eval $(poetry env activate)
3130
poetry install --with dev
32-
poetry install -P client
3331
3432
- name: Run unit tests
3533
run: |
36-
poetry run pytest tests/unit
34+
poetry run pytest tests/unit --ignore=tests/unit/client
3735
3836
integration:
3937
runs-on: ubuntu-latest

.github/workflows/publish-client.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,31 @@ name: Publish Python Client to PyPI
33
on:
44
workflow_run:
55
workflows:
6-
- "Python tests"
6+
- "Client Python tests"
77
types:
88
- completed
9-
paths:
10-
- "client/**"
119
workflow_dispatch:
1210

1311
jobs:
1412
build-and-publish:
1513
runs-on: ubuntu-latest
1614
if: |
1715
github.event_name == 'workflow_dispatch' ||
18-
github.event.workflow_run.conclusion == 'success'
16+
(github.event_name == 'workflow_run' &&
17+
github.event.workflow_run.conclusion == 'success' &&
18+
startsWith(github.event.workflow_run.head_branch, 'v') &&
19+
contains(github.event.workflow_run.head_branch, '.'))
1920
defaults:
2021
run:
2122
working-directory: client
23+
2224
steps:
2325
- uses: actions/checkout@v3
26+
with:
27+
fetch-depth: 0
2428

2529
- name: Build and publish to pypi
2630
uses: JRubics/[email protected]
2731
with:
2832
pypi_token: ${{ secrets.PYPI_API_TOKEN }}
33+
plugins: "poetry-dynamic-versioning[plugin]"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ ipython_config.py
9595
#Pipfile.lock
9696

9797
# poetry
98+
.poetry/
9899
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99100
# This is especially recommended for binary packages to ensure reproducibility, and is more
100101
# commonly ignored for libraries.

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@ repos:
2727
- id: poetry-check
2828
- id: poetry-lock
2929
- id: poetry-install
30+
- repo: https://github.com/python-poetry/poetry
31+
rev: 2.1.3
32+
hooks:
33+
- id: poetry-check
34+
args: ["-P", "client"]
35+
- id: poetry-lock
36+
args: ["-P", "client"]
37+
- id: poetry-install
38+
args: ["-P", "client"]

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ getting you started.
2929
```shell
3030
poetry install --with dev --with migrations
3131
# explicitly install the CogStackModel Gateway client for development
32-
poetry install -P client
32+
poetry install -P client --with dev
3333
```
3434
3535
## Pre-commit Hooks

client/cogstack_model_gateway_client/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ async def get_task_result(self, task_uuid: str, parse: bool = True):
140140
pass
141141

142142
try:
143-
if jsonl := [json.loads(line) for line in result_str.split("\n") if line]:
143+
jsonl = [json.loads(line) for line in result_str.split("\n") if line]
144+
if jsonl:
144145
return jsonl
145146
except Exception:
146147
pass
@@ -155,7 +156,8 @@ async def wait_for_task(
155156
start = asyncio.get_event_loop().time()
156157
while True:
157158
task = await self.get_task(task_uuid, detail=detail)
158-
if (status := task.get("status")) in ("succeeded", "failed"):
159+
status = task.get("status")
160+
if status in ("succeeded", "failed"):
159161
if status == "failed" and raise_on_error:
160162
error_message = task.get("error_message", "Unknown error")
161163
raise RuntimeError(f"Task '{task_uuid}' failed: {error_message}")

0 commit comments

Comments
 (0)