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

fix: pass header kwargs to get openapi endpoints #6177

Merged
merged 1 commit into from
Jul 10, 2024
Merged
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
11 changes: 8 additions & 3 deletions jina/clients/base/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
super().__init__(*args, **kwargs)
self._endpoints = []

async def _get_endpoints_from_openapi(self):
async def _get_endpoints_from_openapi(self, **kwargs):

Check warning on line 27 in jina/clients/base/http.py

View check run for this annotation

Codecov / codecov/patch

jina/clients/base/http.py#L27

Added line #L27 was not covered by tests
def extract_paths_by_method(spec):
paths_by_method = {}
for path, methods in spec['paths'].items():
Expand All @@ -39,10 +39,15 @@

import aiohttp

session_kwargs = {}
if 'headers' in kwargs:
session_kwargs = {'headers': kwargs['headers']}

Check warning on line 44 in jina/clients/base/http.py

View check run for this annotation

Codecov / codecov/patch

jina/clients/base/http.py#L42-L44

Added lines #L42 - L44 were not covered by tests

proto = 'https' if self.args.tls else 'http'
target_url = f'{proto}://{self.args.host}:{self.args.port}/openapi.json'
try:
async with aiohttp.ClientSession() as session:

async with aiohttp.ClientSession(**session_kwargs) as session:

Check warning on line 50 in jina/clients/base/http.py

View check run for this annotation

Codecov / codecov/patch

jina/clients/base/http.py#L50

Added line #L50 was not covered by tests
async with session.get(target_url) as response:
content = await response.read()
openapi_response = json.loads(content.decode())
Expand Down Expand Up @@ -129,7 +134,7 @@
request_iterator = self._get_requests(**kwargs)
on = kwargs.get('on', '/post')
if len(self._endpoints) == 0:
await self._get_endpoints_from_openapi()
await self._get_endpoints_from_openapi(**kwargs)

Check warning on line 137 in jina/clients/base/http.py

View check run for this annotation

Codecov / codecov/patch

jina/clients/base/http.py#L137

Added line #L137 was not covered by tests

async with AsyncExitStack() as stack:
cm1 = ProgressBar(
Expand Down
Loading