Skip to content

Commit 5c29dcc

Browse files
authored
add workflow on the specified Python versions (3.8, 3.9, 3.10, 3.11, 3.12) and perform the steps defined under the steps section for each version. (#42)
add workflow on the specified Python versions (3.8, 3.9, 3.10, 3.11, 3.12) and perform the steps defined under the steps section for each version.
1 parent 070f63d commit 5c29dcc

File tree

7 files changed

+130
-91
lines changed

7 files changed

+130
-91
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: integration_test
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
working-directory:
7+
required: true
8+
type: string
9+
default: '.'
10+
description: "From which folder this pipeline executes"
11+
12+
env:
13+
POETRY_VERSION: "1.7.1"
14+
15+
jobs:
16+
build:
17+
if: github.ref == 'refs/heads/main'
18+
runs-on: ubuntu-latest
19+
20+
environment: Scheduled testing publish
21+
outputs:
22+
pkg-name: ${{ steps.check-version.outputs.pkg-name }}
23+
version: ${{ steps.check-version.outputs.version }}
24+
strategy:
25+
matrix:
26+
python-version:
27+
- "3.8"
28+
- "3.9"
29+
- "3.10"
30+
- "3.11"
31+
- "3.12"
32+
name: "make integration_test #${{ matrix.python-version }}"
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
37+
uses: "./.github/actions/poetry_setup"
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
poetry-version: ${{ env.POETRY_VERSION }}
41+
working-directory: ${{ inputs.working-directory }}
42+
cache-key: core
43+
44+
45+
- name: Import test dependencies
46+
run: poetry install --with test
47+
working-directory: ${{ inputs.working-directory }}
48+
49+
- name: Run integration tests
50+
shell: bash
51+
env:
52+
ZHIPUAI_API_KEY: ${{ secrets.ZHIPUAI_API_KEY }}
53+
ZHIPUAI_BASE_URL: ${{ secrets.ZHIPUAI_BASE_URL }}
54+
run: |
55+
make integration_tests
56+
57+
- name: Ensure the tests did not create any additional files
58+
shell: bash
59+
run: |
60+
set -eu
61+
62+
STATUS="$(git status)"
63+
echo "$STATUS"
64+
65+
# grep will exit non-zero if the target message isn't found,
66+
# and `set -e` above will cause the step to fail.
67+
echo "$STATUS" | grep 'nothing to commit, working tree clean'

.github/workflows/_test.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: test
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
working-directory:
7+
required: true
8+
type: string
9+
default: '.'
10+
description: "From which folder this pipeline executes"
11+
12+
env:
13+
POETRY_VERSION: "1.7.1"
14+
15+
jobs:
16+
build:
17+
defaults:
18+
run:
19+
working-directory: ${{ inputs.working-directory }}
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
python-version:
24+
- "3.8"
25+
- "3.9"
26+
- "3.10"
27+
- "3.11"
28+
- "3.12"
29+
name: "make test #${{ matrix.python-version }}"
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
34+
uses: "./.github/actions/poetry_setup"
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
poetry-version: ${{ env.POETRY_VERSION }}
38+
working-directory: ${{ inputs.working-directory }}
39+
cache-key: core
40+
41+
42+
- name: Import test dependencies
43+
run: poetry install --with test
44+
working-directory: ${{ inputs.working-directory }}
45+
46+
- name: Run core tests
47+
shell: bash
48+
run: |
49+
make test
50+
51+
- name: Ensure the tests did not create any additional files
52+
shell: bash
53+
run: |
54+
set -eu
55+
56+
STATUS="$(git status)"
57+
echo "$STATUS"
58+
59+
# grep will exit non-zero if the target message isn't found,
60+
# and `set -e` above will cause the step to fail.
61+
echo "$STATUS" | grep 'nothing to commit, working tree clean'

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ pydantic = ">=1.9.0,<3.0"
1212
pydantic-core = ">=2.14.6"
1313
cachetools = ">=4.2.2"
1414
pyjwt = "~=2.8.0"
15-
pandas = {version = ">=1.0.0", python = ">=3.8,<3.9.7 || >3.9.7,<4.0"}
16-
openpyxl = {version = ">=3.1.0", python = ">=3.8,<3.9.7 || >3.9.7,<4.0"}
1715

1816

1917
[tool.poetry.group.test.dependencies]

tests/unit_tests/batchinput.xlsx

-8.75 KB
Binary file not shown.

tests/unit_tests/test_http_client_file.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,7 @@ def test_file_download_jsonl(self, test_file_path: str, respx_mock: MockRouter)
5050

5151
text = next(files_content.iter_text())
5252
assert text == '{"custom_id": "request-1", "method": "POST", "url": "/v4/chat/completions", "body": {"model": "glm-4", "messages": [{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Hello world!"}],"max_tokens": 1000}}'
53-
54-
@pytest.mark.respx(base_url=base_url)
55-
def test_file_download_xlsx(self, test_file_path: str, respx_mock: MockRouter) -> None:
56-
with open(os.path.join(test_file_path, "batchinput.xlsx"), "rb") as file:
57-
respx_mock.get("/files/1/content").mock(
58-
return_value=httpx.Response(200, content=file.read(),
59-
headers={
60-
"Content-Type": "application/jsonl",
61-
"Content-Disposition": "attachment; filename=batchinput.xlsx"
62-
}
63-
)
64-
)
65-
legacy = FilesWithRawResponse(self.client.files)
66-
response = legacy.content("1")
67-
files_content = response.parse()
68-
assert files_content.json() == []
69-
text = next(files_content.iter_text())
70-
# 去除换行符
71-
assert text.replace("\n", "") == ""
53+
7254

7355
def test_is_closed(self):
7456
assert self.client.is_closed() is False

zhipuai/core/_legacy_response.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from ._sse_client import StreamResponse, is_stream_class_type, extract_stream_chunk_type
2121
from ._errors import APIResponseValidationError
2222
from ._legacy_binary_response import HttpxBinaryResponseContent, HttpxTextBinaryResponseContent, HttpxResponseContent
23-
from ._legacy_xlsx_response import HttpxXlsxBinaryResponseContent
2423

2524
if TYPE_CHECKING:
2625
from ._request_opt import FinalRequestOptions
@@ -253,7 +252,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
253252
if filename and filename.endswith(".jsonl"):
254253
return cast(R, HttpxTextBinaryResponseContent(response))
255254
elif filename and filename.endswith(".xlsx"):
256-
return cast(R, HttpxXlsxBinaryResponseContent(response))
255+
return cast(R, HttpxTextBinaryResponseContent(response))
257256
else:
258257
return cast(R, cast_type(response)) # type: ignore
259258

zhipuai/core/_legacy_xlsx_response.py

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)