Files
semantic-kernel/python/tests/conftest.py
T
Abby Harrison 00ff74e2e7 Feature python integration tests (#1134)
### 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
2023-05-21 06:04:09 +00:00

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