Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: do not return response object #6195

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ jobs:
python -m cibuildwheel --output-dir dist

- name: Upload wheels as artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
path: dist/*.whl

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/[email protected]
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v4
- uses: wagoid/commitlint-github-action@v3

lint-flake-8:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -691,7 +691,7 @@ jobs:
python -m cibuildwheel --output-dir dist

- name: Upload wheels as artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
path: dist/*.whl

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/force-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
python -m cibuildwheel --output-dir dist

- name: Upload wheels as artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
path: dist/*.whl

Expand Down
3 changes: 2 additions & 1 deletion jina/clients/base/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ async def send_message(self, request: 'Request'):
r_str = await response.json()
except aiohttp.ContentTypeError:
r_str = await response.text()
r_status = response.status
handle_response_status(response.status, r_str, self.url)
return response
return r_status, r_str
except (ValueError, ConnectionError, BadClient, aiohttp.ClientError, aiohttp.ClientConnectionError) as err:
self.logger.debug(f'Got an error: {err} sending POST to {self.url} in attempt {attempt}/{self.max_attempts}')
await retry.wait_or_raise_err(
Expand Down
4 changes: 1 addition & 3 deletions jina/clients/base/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,7 @@ def _result_handler(result):
async for response in streamer.stream(
request_iterator=request_iterator, results_in_order=results_in_order
):
r_status = response.status

r_str = await response.json()
r_status, r_str = response
handle_response_status(r_status, r_str, url)

da = None
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/clients/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ async def test_http_clientlet():
) as iolet:
request = _new_data_request('/', None, {'a': 'b'})
assert request.header.target_executor == ''
r = await iolet.send_message(request)
response = DataRequest(await r.json())
r_status, r_json = await iolet.send_message(request)
response = DataRequest(r_json)
assert response.header.exec_endpoint == '/'
assert response.parameters == {'a': 'b'}

Expand All @@ -55,7 +55,8 @@ async def test_http_clientlet_target():
request = _new_data_request('/', 'nothing', {'a': 'b'})
assert request.header.target_executor == 'nothing'
r = await iolet.send_message(request)
response = DataRequest(await r.json())
r_status, r_json = r
response = DataRequest(r_json)
assert response.header.exec_endpoint == '/'
assert response.parameters == {'a': 'b'}

Expand Down
Loading