Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Longer wait/retries #253
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
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Longer wait/retries #253
Changes from all commits
5c7ace1File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Check failure on line 106 in nuclia_e2e/nuclia_e2e/tests/test_kb_features.py
test_kb_features.test_kb_usage[gke-stage-1]
Raw output
@contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield nuclia_e2e/.venv/lib/python3.10/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ nuclia_e2e/.venv/lib/python3.10/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) nuclia_e2e/.venv/lib/python3.10/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None nuclia_e2e/.venv/lib/python3.10/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( nuclia_e2e/.venv/lib/python3.10/site-packages/httpcore/_async/connection.py:103: in handle_async_request return await self._connection.handle_async_request(request) nuclia_e2e/.venv/lib/python3.10/site-packages/httpcore/_async/http11.py:136: in handle_async_request raise exc nuclia_e2e/.venv/lib/python3.10/site-packages/httpcore/_async/http11.py:106: in handle_async_request ) = await self._receive_response_headers(**kwargs) nuclia_e2e/.venv/lib/python3.10/site-packages/httpcore/_async/http11.py:177: in _receive_response_headers event = await self._receive_event(timeout=timeout) nuclia_e2e/.venv/lib/python3.10/site-packages/httpcore/_async/http11.py:217: in _receive_event data = await self._network_stream.read( nuclia_e2e/.venv/lib/python3.10/site-packages/httpcore/_backends/anyio.py:32: in read with map_exceptions(exc_map): /usr/lib/python3.10/contextlib.py:153: in __exit__ self.gen.throw(typ, value, traceback) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {<class 'TimeoutError'>: <class 'httpcore.ReadTimeout'>, <class 'anyio.BrokenResourceError'>: <class 'httpcore.ReadErr... 'anyio.ClosedResourceError'>: <class 'httpcore.ReadError'>, <class 'anyio.EndOfStream'>: <class 'httpcore.ReadError'>} @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ReadError nuclia_e2e/.venv/lib/python3.10/site-packages/httpcore/_exceptions.py:14: ReadError The above exception was the direct cause of the following exception: request = <FixtureRequest for <Function test_kb_usage[gke-stage-1]>> regional_api_config = ZoneConfig(name='gke-stage-1', zone_slug='europe-1', test_kb_slug='nuclia-e2e-live-europe-1', permanent_nua_key='eyJhb...1f-4197-be76-6fc611082fe8', grafana_url='http://platform.grafana.nuclia.com', tempo_datasource_id='P95F6455D1776E941')) global_api = <nuclia_e2e.tests.conftest.GlobalAPI object at 0x7f4367db6110> @pytest.mark.asyncio_cooperative async def test_kb_usage( request: pytest.FixtureRequest, regional_api_config: ZoneConfig, global_api: GlobalAPI ): """ This test is conducted separately from the main test_kb to ensure more deterministic results. The retries that typically occur in test_kb make it difficult to achieve the level of precision required for this validation. In this test, the actual response from the ask endpoint is not relevant—as long as the request consumes input tokens, the test remains valid. The primary objective is to verify that all usage data generated by an ask request is properly collected and integrated into the audit event. This includes tracking data from NucliaDB, Predict, and ensuring it aligns with the data recorded by Accounting. Since usage tracking is performed on a per-request basis, this test assumes that only a single request is being made and that the data captured by Accounting corresponds solely to that request. """ def logger(msg): print(f"{request.node.name} ::: {msg}") zone = regional_api_config.zone_slug assert regional_api_config.global_config is not None account = regional_api_config.global_config.permanent_account_id # noqa: F841 auth = get_auth() kb_slug = f"{regional_api_config.test_kb_slug}-test_kb_usage" # Make sure the kb used for this test is deleted, as the slug is reused: old_kbid = await get_kbid_from_slug(regional_api_config.zone_slug, kb_slug) if old_kbid is not None: await AsyncNucliaKBS().delete(zone=regional_api_config.zone_slug, id=old_kbid) # Creates a brand new kb that will be used troughout this test kbid = await create_test_kb(regional_api_config, kb_slug, logger) # Configures a nucliadb client defaulting to a specific kb, to be used # to override all the sdk endpoints that automagically creates the client # as this is incompatible with the cooperative tests async_ndb = get_async_kb_ndb_client(zone, kbid, user_token=auth._config.token) # Import a preexisting export containing several resources (coming from the financial-news kb) # and wait for the resources to be completely imported > await run_test_import_kb(regional_api_config, async_ndb, logger) nuclia_e2e/nuclia_e2e/tests/test_kb_features.py:909: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ nuclia_e2e/.venv/lib/python3.10/site-packages/backoff/_async.py:151: in retry ret = await target(*args, **kwargs) nuclia_e2e/nuclia_e2e/tests/test_kb_features.py:106: in run_test_import_kb response = await kb.imports.start(path=f"{ASSETS_FILE_PATH}/e2e.financial.mini.export", ndb=ndb) nuclia_e2e/.venv/lib/python3.10/site-packages/nuclia/decorators.py:44: in async_wrapper_checkout return await func(*args, **kwargs) nuclia_e2e/.venv/lib/python3.10/site-packages/nuclia/sdk/export_import.py:209: in start response = await ndb.ndb.start_import(kbid=ndb.kbid, content=iterator(path)) nuclia_e2e/.venv/lib/python3.10/site-packages/nucliadb_sdk/v2/sdk.py:756: in _func resp = await self._request( nuclia_e2e/.venv/lib/python3.10/site-packages/nucliadb_sdk/v2/sdk.py:1180: in _request response: httpx.Response = await getattr(self.session, method.lower())(url, **opts) nuclia_e2e/.venv/lib/python3.10/site-packages/httpx/_client.py:1859: in post return await self.request( nuclia_e2e/.venv/lib/python3.10/site-packages/httpx/_client.py:1540: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) nuclia_e2e/.venv/lib/python3.10/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( nuclia_e2e/.venv/lib/python3.10/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( nuclia_e2e/.venv/lib/python3.10/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) nuclia_e2e/.venv/lib/python3.10/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) nuclia_e2e/.venv/lib/python3.10/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): /usr/lib/python3.10/contextlib.py:153: in __exit__ self.gen.throw(typ, value, traceback) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ReadError nuclia_e2e/.venv/lib/python3.10/site-packages/httpx/_transports/default.py:118: ReadErrorUh oh!
There was an error while loading. Please reload this page.