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

Python: updated tests and integration runners #9828

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8c27409
updated tests and integration runners
eavanvalkenburg Nov 26, 2024
0e8ebfc
updated coverage
eavanvalkenburg Nov 26, 2024
d119410
test download-artifact
eavanvalkenburg Nov 26, 2024
953fe4f
download all
eavanvalkenburg Nov 26, 2024
22e0253
temp not on target
eavanvalkenburg Nov 26, 2024
c615dc1
changed name
eavanvalkenburg Nov 26, 2024
aa261d8
test without wait
eavanvalkenburg Nov 26, 2024
2bee977
update
eavanvalkenburg Nov 26, 2024
1d07ecf
test coverage update
eavanvalkenburg Nov 26, 2024
5c26692
updated uv
eavanvalkenburg Nov 26, 2024
5930cf2
increased timeout
eavanvalkenburg Nov 26, 2024
767c02b
updated check job
eavanvalkenburg Nov 26, 2024
eda0f92
removed commented out parts
eavanvalkenburg Nov 26, 2024
d39af93
different redis container address
eavanvalkenburg Nov 26, 2024
a936971
fix for getenv
eavanvalkenburg Nov 26, 2024
191ebb8
updated setup
eavanvalkenburg Nov 26, 2024
8210db4
updated annotations of PES's and fixed tests and addressed comments
eavanvalkenburg Nov 27, 2024
c511d01
fixed missing default
eavanvalkenburg Nov 27, 2024
e7076ce
fix notify
eavanvalkenburg Nov 27, 2024
44e7adf
using title
eavanvalkenburg Nov 27, 2024
ce92640
fixed typo in path
eavanvalkenburg Nov 27, 2024
08941f0
remove cosmosdb container and tests
eavanvalkenburg Nov 27, 2024
e376d83
small updates to conftest and setup
eavanvalkenburg Nov 27, 2024
280b798
remove explicit cache prune and surface tasks
eavanvalkenburg Nov 28, 2024
770cd71
fix mistaken delete
eavanvalkenburg Nov 28, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
version: "0.4.30"
version: "0.5.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
- name: Check version
Expand Down
153 changes: 87 additions & 66 deletions .github/workflows/python-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ permissions:
env:
# Configure a constant location for the uv cache
UV_CACHE_DIR: /tmp/.uv-cache
HNSWLIB_NO_NATIVE: 1
Python_Integration_Tests: Python_Integration_Tests
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME }} # azure-text-embedding-ada-002
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_CHAT_DEPLOYMENT_NAME }}
Expand Down Expand Up @@ -92,8 +91,8 @@ jobs:
if: steps.filter.outputs.python != 'true'
run: echo "NOT python file"

python-merge-gate:
name: Python Pre-Merge Integration Tests
python-merge-gate-ai-services:
name: Python Pre-Merge Integration Tests - AI Services (incl samples using those)
needs: paths-filter
if: github.event_name != 'pull_request' && github.event_name != 'schedule' && needs.paths-filter.outputs.pythonChanges == 'true'
strategy:
Expand All @@ -107,21 +106,18 @@ jobs:
working-directory: python
runs-on: ${{ matrix.os }}
environment: "integration"
env:
UV_PYTHON: ${{ matrix.python-version }}
COMPLETIONS_CONCEPT_SAMPLE: "true"
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
version: "0.4.30"
version: "0.5.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
- name: Install dependencies with hnswlib native disabled
if: matrix.os == 'macos-latest' && matrix.python-version == '3.11'
run: |
export HNSWLIB_NO_NATIVE=1
uv sync --all-extras --dev
- name: Install dependencies with hnswlib native enabled
if: matrix.os != 'macos-latest' || matrix.python-version != '3.11'
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Install Ollama
Expand Down Expand Up @@ -152,66 +148,92 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Setup Redis Stack Server
if: matrix.os == 'ubuntu-latest'
run: docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest
- name: Setup Weaviate docker deployment
if: matrix.os == 'ubuntu-latest'
run: docker run -d -p 8080:8080 -p 50051:50051 cr.weaviate.io/semitechnologies/weaviate:1.26.6
- name: Start Azure Cosmos DB emulator
if: matrix.os == 'windows-latest'
run: |
Write-Host "Launching Cosmos DB Emulator"
Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
Start-CosmosDbEmulator
- name: Azure CLI Login
if: github.event_name != 'pull_request'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Run Integration Tests - Completions
id: run_tests_completions
timeout-minutes: 15
- name: Run Integration Tests
id: run_tests_ai_services
timeout-minutes: 25
shell: bash
run: |
uv run pytest -n logical --dist loadfile --dist worksteal ./tests/integration/completions -v --junitxml=pytest-completions.xml
- name: Run Integration Tests - Embeddings
id: run_tests_embeddings
timeout-minutes: 5
shell: bash
uv run pytest -n logical --dist loadfile --dist worksteal -v --junitxml=pytest-completions.xml ./tests/integration/completions ./tests/integration/embeddings ./tests/samples ./tests/integration/cross_language
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@main
with:
path: python/pytest-completions.xml
summary: true
display-options: fEX
fail-on-empty: true
title: Test results
- name: Minimize uv cache
run: uv cache prune --ci

python-merge-gate-memory:
name: Python Pre-Merge Integration Tests - Memory (incl samples using those)
needs: paths-filter
if: github.event_name != 'pull_request' && github.event_name != 'schedule' && needs.paths-filter.outputs.pythonChanges == 'true'
strategy:
max-parallel: 1
fail-fast: false
matrix:
python-version: ["3.11"]
os: [ubuntu-latest]
defaults:
run:
working-directory: python
runs-on: ${{ matrix.os }}
environment: "integration"
env:
UV_PYTHON: ${{ matrix.python-version }}
MEMORY_CONCEPT_SAMPLE: "true"
# Service containers to run with for the memory connectors, this only works on Ubuntu
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis/redis-stack-server:latest
ports:
# Opens tcp port 6379 on the host and service container
- 6379:6379
weaviate:
image: cr.weaviate.io/semitechnologies/weaviate:1.26.6
ports:
- 8080:8080
- 50051:50051
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
- name: Install dependencies
run: |
uv run pytest -n logical --dist loadfile --dist worksteal ./tests/integration/embeddings -v --junitxml=pytest-embeddings.xml
- name: Run Integration Tests - Memory
uv sync --all-extras --dev
- name: Azure CLI Login
if: github.event_name != 'pull_request'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Run Integration Tests
id: run_tests_memory
timeout-minutes: 10
shell: bash
run: |
uv run pytest -n logical --dist loadfile --dist worksteal ./tests/integration/memory -v --junitxml=pytest-memory.xml
- name: Run Integration Tests - Cross Language
id: run_tests_cross_language
timeout-minutes: 5
shell: bash
run: |
uv run pytest -n logical --dist loadfile --dist worksteal ./tests/integration/cross_language -v --junitxml=pytest-cross.xml
- name: Run Integration Tests - Planning
id: run_tests_planning
timeout-minutes: 5
shell: bash
run: |
uv run pytest -n logical --dist loadfile --dist worksteal ./tests/integration/planning -v --junitxml=pytest-planning.xml
eavanvalkenburg marked this conversation as resolved.
Show resolved Hide resolved
- name: Run Integration Tests - Samples
id: run_tests_samples
timeout-minutes: 5
shell: bash
run: |
uv run pytest -n logical --dist loadfile --dist worksteal ./tests/samples -v --junitxml=pytest-samples.xml
uv run pytest -n logical --dist loadfile --dist worksteal -v --junitxml=pytest-memory.xml ./tests/integration/memory ./tests/samples
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@main
with:
path: python/pytest-*.xml
path: python/pytest-memory.xml
summary: true
display-options: fEX
fail-on-empty: true
Expand All @@ -220,6 +242,7 @@ jobs:
run: uv cache prune --ci

python-integration-tests:
name: Python Integration Tests - Scheduled run
needs: paths-filter
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && needs.paths-filter.outputs.pythonChanges == 'true'
strategy:
Expand All @@ -233,21 +256,19 @@ jobs:
working-directory: python
runs-on: ${{ matrix.os }}
environment: "integration"
env:
UV_PYTHON: ${{ matrix.python-version }}
MEMORY_CONCEPT_SAMPLE: "true"
COMPLETIONS_CONCEPT_SAMPLE: "true"
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
version: "0.4.30"
version: "0.5.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
- name: Install dependencies with hnswlib native disabled
if: matrix.os == 'macos-latest' && matrix.python-version == '3.11'
run: |
export HNSWLIB_NO_NATIVE=1
uv sync --all-extras --dev
- name: Install dependencies with hnswlib native enabled
if: matrix.os != 'macos-latest' || matrix.python-version != '3.11'
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Install Ollama
Expand Down Expand Up @@ -352,7 +373,7 @@ jobs:
strategy:
max-parallel: 1
fail-fast: false
needs: [python-merge-gate, python-integration-tests]
needs: [python-merge-gate-ai-services, python-merge-gate-memory, python-integration-tests]
steps:
- name: Get Date
shell: bash
Expand Down Expand Up @@ -399,7 +420,7 @@ jobs:
dry_run: ${{ env.run_type != 'Daily' && env.run_type != 'Manual'}}
job: ${{ toJson(job) }}
steps: ${{ toJson(steps) }}
overwrite: "{title: ` ${{ env.run_type }}: ${{ env.date }} `, text: ` ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`}"
title: "{title: ` ${{ env.run_type }}: ${{ env.date }} `, text: ` ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`}"

- name: Microsoft Teams Notification (Dry Run)
uses: skitionek/notify-microsoft-teams@master
Expand All @@ -409,4 +430,4 @@ jobs:
dry_run: ${{ env.run_type != 'Daily' && env.run_type != 'Manual'}}
job: ${{ toJson(job) }}
steps: ${{ toJson(steps) }}
overwrite: "{title: ` ${{ env.run_type }}: ${{ env.date }} `, text: ` ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`}"
title: "{title: ` ${{ env.run_type }}: ${{ env.date }} `, text: ` ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`}"
4 changes: 2 additions & 2 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
version: "0.4.30"
version: "0.5.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
- name: Install the project
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/python-test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,19 @@ jobs:
- uses: actions/checkout@v4
- name: Setup filename variables
run: echo "FILE_ID=${{ github.event.number }}" >> $GITHUB_ENV
- name: Download coverage
uses: dawidd6/action-download-artifact@v6
- name: Download Files
uses: actions/download-artifact@v4
with:
name: python-coverage-${{ env.FILE_ID }}.txt
github_token: ${{ secrets.GH_ACTIONS_PR_WRITE }}
workflow: python-unit-tests.yml
search_artifacts: true
if_no_artifact_found: warn
- name: Download pytest
uses: dawidd6/action-download-artifact@v6
with:
name: pytest-${{ env.FILE_ID }}.xml
github_token: ${{ secrets.GH_ACTIONS_PR_WRITE }}
workflow: python-unit-tests.yml
search_artifacts: true
if_no_artifact_found: warn
github-token: ${{ secrets.GH_ACTIONS_PR_WRITE }}
run-id: ${{ github.event.workflow_run.id }}
path: python/
merge-multiple: true
- name: Display structure of downloaded files
run: ls python/
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
eavanvalkenburg marked this conversation as resolved.
Show resolved Hide resolved
continue-on-error: true
with:
github-token: ${{ secrets.GH_ACTIONS_PR_WRITE }}
pytest-coverage-path: python-coverage.txt
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/python-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
version: "0.4.30"
version: "0.5.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
- name: Install the project
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.30"
version: "0.5.2"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ env.UV_PYTHON }}
- name: Install the project
Expand Down
11 changes: 6 additions & 5 deletions python/samples/concepts/chat_completion/simple_chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Services,
get_chat_completion_service_and_request_settings,
)
from semantic_kernel.contents.chat_history import ChatHistory
from semantic_kernel.contents import ChatHistory

# This sample shows how to create a chatbot. This sample uses the following two main components:
# - a ChatCompletionService: This component is responsible for generating responses to user messages.
Expand All @@ -26,7 +26,7 @@
# - Services.ONNX
# - Services.VERTEX_AI
# Please make sure you have configured your environment correctly for the selected chat completion service.
chat_completion_service, request_settings = get_chat_completion_service_and_request_settings(Services.AZURE_OPENAI)
chat_completion_service, request_settings = get_chat_completion_service_and_request_settings(Services.OPENAI)

# This is the system message that gives the chatbot its personality.
system_message = """
Expand Down Expand Up @@ -64,10 +64,11 @@ async def chat() -> bool:
chat_history=chat_history,
settings=request_settings,
)
print(f"Mosscap:> {response}")
if response:
print(f"Mosscap:> {response}")

# Add the chat message to the chat history to keep track of the conversation.
chat_history.add_assistant_message(str(response))
# Add the chat message to the chat history to keep track of the conversation.
chat_history.add_message(response)

return True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
Services,
get_chat_completion_service_and_request_settings,
)
from semantic_kernel.contents.chat_history import ChatHistory
from semantic_kernel.functions.kernel_arguments import KernelArguments
from semantic_kernel.kernel import Kernel
from semantic_kernel import Kernel
from semantic_kernel.contents import ChatHistory
from semantic_kernel.functions import KernelArguments

# This sample shows how to create a chatbot using a kernel function.
# This sample uses the following two main components:
Expand Down Expand Up @@ -97,15 +97,15 @@ async def chat() -> bool:
user_input=user_input,
)

answer = await kernel.invoke(chat_function, kernel_arguments)
answer = await kernel.invoke(plugin_name="ChatBot", function_name="Chat", arguments=kernel_arguments)
# Alternatively, you can invoke the function directly with the kernel as an argument:
# answer = await chat_function.invoke(kernel, kernel_arguments)

print(f"Mosscap:> {answer}")

# Add the chat message to the chat history to keep track of the conversation.
chat_history.add_user_message(user_input)
chat_history.add_assistant_message(str(answer))
if answer:
print(f"Mosscap:> {answer}")
# Since the user_input is rendered by the template, it is not yet part of the chat history, so we add it here.
chat_history.add_user_message(user_input)
# Add the chat message to the chat history to keep track of the conversation.
chat_history.add_message(answer.value[0])

return True

Expand Down
Loading
Loading