Skip to content

Commit 93b47f8

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. Signed-off-by: Phoevos Kalemkeris <[email protected]>
1 parent 7c73b73 commit 93b47f8

File tree

8 files changed

+439
-13
lines changed

8 files changed

+439
-13
lines changed

.github/workflows/ci.yaml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -58,3 +56,30 @@ jobs:
5856
- name: Run integration tests
5957
run: |
6058
poetry run pytest tests/integration -s
59+
60+
client:
61+
runs-on: ubuntu-latest
62+
strategy:
63+
matrix:
64+
python-version: ["3.10", "3.11", "3.12", "3.13"]
65+
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v4
69+
70+
- name: Set up Python ${{ matrix.python-version }}
71+
uses: actions/setup-python@v5
72+
with:
73+
python-version: ${{ matrix.python-version }}
74+
75+
- name: Install Poetry
76+
run: |
77+
curl -sSL https://install.python-poetry.org | python3 -
78+
79+
- name: Install dependencies
80+
run: |
81+
poetry install -P client --with dev
82+
83+
- name: Run client tests
84+
run: |
85+
poetry run pytest tests/unit/client

.github/workflows/publish-client.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
if: |
1717
github.event_name == 'workflow_dispatch' ||
18-
github.event.workflow_run.conclusion == 'success'
18+
github.event.workflow_run.workflow_run.jobs["client"].conclusion == 'success'
1919
defaults:
2020
run:
2121
working-directory: client

.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)