True ============================= test session starts ============================= platform win32 -- Python 3.12.7, pytest-8.1.2, pluggy-1.5.0 rootdir: d:\dev\raft-distillation-recipe\infra\tests configfile: ..\..\pyproject.toml plugins: anyio-4.6.2.post1 collected 4 items infra\tests\test_baseline.py F [ 25%] infra\tests\test_embeddings.py F [ 50%] infra\tests\test_scoring.py F [ 75%] infra\tests\test_teacher.py F [100%] ================================== FAILURES =================================== ________________________________ test_baseline ________________________________ def test_baseline(): > do_test_openai_endpoint("BASELINE") infra\tests\test_baseline.py:9: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ infra\tests\utils.py:50: in do_test_openai_endpoint response = client.chat.completions.create( .venv\Lib\site-packages\openai\_utils\_utils.py:274: in wrapper return func(*args, **kwargs) .venv\Lib\site-packages\openai\resources\chat\completions.py:742: in create return self._post( .venv\Lib\site-packages\openai\_base_client.py:1270: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) .venv\Lib\site-packages\openai\_base_client.py:947: in request return self._request( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _request( self, *, cast_to: Type[ResponseT], options: FinalRequestOptions, retries_taken: int, stream: bool, stream_cls: type[_StreamT] | None, ) -> ResponseT | _StreamT: # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) cast_to = self._maybe_override_cast_to(cast_to, options) options = self._prepare_options(options) remaining_retries = options.get_max_retries(self.max_retries) - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth log.debug("Sending HTTP Request: %s %s", request.method, request.url) try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: return self._retry_request( input_options, cast_to, retries_taken=retries_taken, stream=stream, stream_cls=stream_cls, response_headers=None, ) log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: return self._retry_request( input_options, cast_to, retries_taken=retries_taken, stream=stream, stream_cls=stream_cls, response_headers=None, ) log.debug("Raising connection error") raise APIConnectionError(request=request) from err log.debug( 'HTTP Response: %s %s "%i %s" %s', request.method, request.url, response.status_code, response.reason_phrase, response.headers, ) log.debug("request_id: %s", response.headers.get("x-request-id")) try: response.raise_for_status() except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code log.debug("Encountered httpx.HTTPStatusError", exc_info=True) if remaining_retries > 0 and self._should_retry(err.response): err.response.close() return self._retry_request( input_options, cast_to, retries_taken=retries_taken, response_headers=err.response.headers, stream=stream, stream_cls=stream_cls, ) # If the response is streamed then we need to explicitly read the response # to completion before attempting to access the response text. if not err.response.is_closed: err.response.read() log.debug("Re-raising status error") > raise self._make_status_error_from_response(err.response) from None E openai.AuthenticationError: Error code: 401 - {'error': {'code': 'PermissionDenied', 'message': 'Principal does not have access to API/Operation.'}} .venv\Lib\site-packages\openai\_base_client.py:1051: AuthenticationError _______________________________ test_embeddings _______________________________ def test_embeddings(): (client, model) = create_client("EMBEDDING") > response = client.embeddings.create(input = ["Hello"], model=model) infra\tests\test_embeddings.py:15: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .venv\Lib\site-packages\openai\resources\embeddings.py:124: in create return self._post( .venv\Lib\site-packages\openai\_base_client.py:1270: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) .venv\Lib\site-packages\openai\_base_client.py:947: in request return self._request( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _request( self, *, cast_to: Type[ResponseT], options: FinalRequestOptions, retries_taken: int, stream: bool, stream_cls: type[_StreamT] | None, ) -> ResponseT | _StreamT: # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) cast_to = self._maybe_override_cast_to(cast_to, options) options = self._prepare_options(options) remaining_retries = options.get_max_retries(self.max_retries) - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth log.debug("Sending HTTP Request: %s %s", request.method, request.url) try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: return self._retry_request( input_options, cast_to, retries_taken=retries_taken, stream=stream, stream_cls=stream_cls, response_headers=None, ) log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: return self._retry_request( input_options, cast_to, retries_taken=retries_taken, stream=stream, stream_cls=stream_cls, response_headers=None, ) log.debug("Raising connection error") raise APIConnectionError(request=request) from err log.debug( 'HTTP Response: %s %s "%i %s" %s', request.method, request.url, response.status_code, response.reason_phrase, response.headers, ) log.debug("request_id: %s", response.headers.get("x-request-id")) try: response.raise_for_status() except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code log.debug("Encountered httpx.HTTPStatusError", exc_info=True) if remaining_retries > 0 and self._should_retry(err.response): err.response.close() return self._retry_request( input_options, cast_to, retries_taken=retries_taken, response_headers=err.response.headers, stream=stream, stream_cls=stream_cls, ) # If the response is streamed then we need to explicitly read the response # to completion before attempting to access the response text. if not err.response.is_closed: err.response.read() log.debug("Re-raising status error") > raise self._make_status_error_from_response(err.response) from None E openai.AuthenticationError: Error code: 401 - {'error': {'code': 'PermissionDenied', 'message': 'Principal does not have access to API/Operation.'}} .venv\Lib\site-packages\openai\_base_client.py:1051: AuthenticationError _________________________________ test_judge __________________________________ def test_judge(): > do_test_openai_endpoint("JUDGE") infra\tests\test_scoring.py:9: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ infra\tests\utils.py:50: in do_test_openai_endpoint response = client.chat.completions.create( .venv\Lib\site-packages\openai\_utils\_utils.py:274: in wrapper return func(*args, **kwargs) .venv\Lib\site-packages\openai\resources\chat\completions.py:742: in create return self._post( .venv\Lib\site-packages\openai\_base_client.py:1270: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) .venv\Lib\site-packages\openai\_base_client.py:947: in request return self._request( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _request( self, *, cast_to: Type[ResponseT], options: FinalRequestOptions, retries_taken: int, stream: bool, stream_cls: type[_StreamT] | None, ) -> ResponseT | _StreamT: # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) cast_to = self._maybe_override_cast_to(cast_to, options) options = self._prepare_options(options) remaining_retries = options.get_max_retries(self.max_retries) - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth log.debug("Sending HTTP Request: %s %s", request.method, request.url) try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: return self._retry_request( input_options, cast_to, retries_taken=retries_taken, stream=stream, stream_cls=stream_cls, response_headers=None, ) log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: return self._retry_request( input_options, cast_to, retries_taken=retries_taken, stream=stream, stream_cls=stream_cls, response_headers=None, ) log.debug("Raising connection error") raise APIConnectionError(request=request) from err log.debug( 'HTTP Response: %s %s "%i %s" %s', request.method, request.url, response.status_code, response.reason_phrase, response.headers, ) log.debug("request_id: %s", response.headers.get("x-request-id")) try: response.raise_for_status() except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code log.debug("Encountered httpx.HTTPStatusError", exc_info=True) if remaining_retries > 0 and self._should_retry(err.response): err.response.close() return self._retry_request( input_options, cast_to, retries_taken=retries_taken, response_headers=err.response.headers, stream=stream, stream_cls=stream_cls, ) # If the response is streamed then we need to explicitly read the response # to completion before attempting to access the response text. if not err.response.is_closed: err.response.read() log.debug("Re-raising status error") > raise self._make_status_error_from_response(err.response) from None E openai.AuthenticationError: Error code: 401 - {'error': {'code': 'PermissionDenied', 'message': 'Principal does not have access to API/Operation.'}} .venv\Lib\site-packages\openai\_base_client.py:1051: AuthenticationError ________________________________ test_teacher _________________________________ def test_teacher(): > do_test_openai_endpoint("TEACHER") infra\tests\test_teacher.py:9: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ infra\tests\utils.py:48: in do_test_openai_endpoint (client, model) = create_client(env_prefix) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ env_prefix = 'TEACHER' def create_client(env_prefix): # OpenAI API base_url = getenv(f"{env_prefix}_OPENAI_BASE_URL") # Azure OpenAI API endpoint = getenv(f"{env_prefix}_AZURE_OPENAI_ENDPOINT") if base_url: model = getenv(f"{env_prefix}_OPENAI_DEPLOYMENT") api_key = getenv(f"{env_prefix}_OPENAI_API_KEY") assert model assert api_key client = OpenAI( base_url = base_url, api_key = api_key, ) elif endpoint: model = getenv(f"{env_prefix}_AZURE_OPENAI_DEPLOYMENT") version = getenv(f"{env_prefix}_OPENAI_API_VERSION") assert model assert version # Authenticate using the default Azure credential chain azure_credential = DefaultAzureCredential() client = AzureOpenAI( api_version=version, azure_endpoint=endpoint, azure_ad_token_provider = get_bearer_token_provider( azure_credential, "https://cognitiveservices.azure.com/.default" ) ) else: > raise Exception("Couldn't find either OpenAI or Azure OpenAI env vars") E Exception: Couldn't find either OpenAI or Azure OpenAI env vars infra\tests\utils.py:40: Exception ============================== warnings summary =============================== test_baseline.py::test_baseline test_baseline.py::test_baseline test_baseline.py::test_baseline test_embeddings.py::test_embeddings test_embeddings.py::test_embeddings test_embeddings.py::test_embeddings test_scoring.py::test_judge test_scoring.py::test_judge test_scoring.py::test_judge d:\dev\raft-distillation-recipe\.venv\Lib\site-packages\msal\token_cache.py:164: DeprecationWarning: Use list(search(...)) instead to explicitly get a list. warnings.warn( -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================== short test summary info =========================== FAILED infra\tests\test_baseline.py::test_baseline - openai.AuthenticationError: Error code: 401 - {'error': {'code': 'Permissio... FAILED infra\tests\test_embeddings.py::test_embeddings - openai.AuthenticationError: Error code: 401 - {'error': {'code': 'Permissio... FAILED infra\tests\test_scoring.py::test_judge - openai.AuthenticationError: Error code: 401 - {'error': {'code': 'Permissio... FAILED infra\tests\test_teacher.py::test_teacher - Exception: Couldn't find either OpenAI or Azure OpenAI env vars ======================== 4 failed, 9 warnings in 6.59s ========================