mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### Motivation and Context Python integration tests were failing consistently for 2 reasons. First, all ubuntu system tests were failing due to missing shared object files related to cuda. Second, macOS + python 3.11 tests were failing due to hsnwlib unable to install on native hardware. See https://github.com/microsoft/semantic-kernel/pull/1066 for description of changes to integration test code to condense test code, make better use of pytest fixtures, and reduce the number of calls to external APIs (OpenAI, AOAI) ### Description - Integration tests were failing on Linux due to a regression in python torch=2.0.1. Downgrading the version to 2.0.0 resolved these failures. - For MacOS + 3.11 specifically, setting the environment variable `HNSWLIB_NO_NATIVE=1` ensures that the hnswlib wheel can be built and installed properly on M1 hardware. - Python integration tests reliably and consistently passing: https://github.com/microsoft/semantic-kernel/actions/runs/5035748596
40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
import semantic_kernel as sk
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def create_kernel():
|
|
kernel = sk.Kernel()
|
|
return kernel
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def get_aoai_config():
|
|
if "Python_Integration_Tests" in os.environ:
|
|
deployment_name = os.environ["AzureOpenAIEmbeddings__DeploymentName"]
|
|
api_key = os.environ["AzureOpenAI__ApiKey"]
|
|
endpoint = os.environ["AzureOpenAI__Endpoint"]
|
|
else:
|
|
# Load credentials from .env file
|
|
deployment_name, api_key, endpoint = sk.azure_openai_settings_from_dot_env()
|
|
deployment_name = "text-embedding-ada-002"
|
|
|
|
return deployment_name, api_key, endpoint
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def get_oai_config():
|
|
if "Python_Integration_Tests" in os.environ:
|
|
api_key = os.environ["OpenAI__ApiKey"]
|
|
org_id = None
|
|
else:
|
|
# Load credentials from .env file
|
|
api_key, org_id = sk.openai_settings_from_dot_env()
|
|
|
|
return api_key, org_id
|