From 07c89846082d93108ee33b1c61274c115613a63f Mon Sep 17 00:00:00 2001 From: edvan_microsoft Date: Thu, 11 Jul 2024 14:25:00 +0200 Subject: [PATCH 1/9] add experimental unit tests for python 3.13 --- .github/workflows/python-test-coverage.yml | 7 +++++-- .github/workflows/python-unit-tests.yml | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/python-test-coverage.yml b/.github/workflows/python-test-coverage.yml index b6609ea232ea..aaa41f9c9141 100644 --- a/.github/workflows/python-test-coverage.yml +++ b/.github/workflows/python-test-coverage.yml @@ -24,6 +24,9 @@ jobs: python-version: ["3.10"] os: [ubuntu-latest] steps: + - name: Setup filename variables + run: | + echo "FILE_ID=$(${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV - name: Wait for unit tests to succeed continue-on-error: true uses: lewagon/wait-on-check-action@v1.3.4 @@ -38,7 +41,7 @@ jobs: continue-on-error: true uses: dawidd6/action-download-artifact@v3 with: - name: python-coverage-${{ matrix.os }}-${{ matrix.python-version }}.txt + name: python-coverage-${{ $FILE_ID }}.txt github_token: ${{ secrets.GH_ACTIONS_PR_WRITE }} workflow: python-unit-tests.yml search_artifacts: true @@ -47,7 +50,7 @@ jobs: continue-on-error: true uses: dawidd6/action-download-artifact@v3 with: - name: pytest-${{ matrix.os }}-${{ matrix.python-version }}.xml + name: pytest-${{ $FILE_ID }}.xml github_token: ${{ secrets.GH_ACTIONS_PR_WRITE }} workflow: python-unit-tests.yml search_artifacts: true diff --git a/.github/workflows/python-unit-tests.yml b/.github/workflows/python-unit-tests.yml index da9eef81eeb2..9edcfae0a9ad 100644 --- a/.github/workflows/python-unit-tests.yml +++ b/.github/workflows/python-unit-tests.yml @@ -10,17 +10,26 @@ jobs: python-unit-tests: name: Python Unit Tests runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} strategy: - fail-fast: false + fail-fast: true matrix: python-version: ["3.10", "3.11", "3.12"] os: [ubuntu-latest, windows-latest, macos-latest] + experimental: [false] + include: + - python-version: "3.13" + os: "ubuntu-latest" + experimental: true permissions: contents: write defaults: run: working-directory: ./python steps: + - name: Setup filename variables + run: | + echo "FILE_ID=$(echo ${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV - uses: actions/checkout@v4 - name: Install poetry run: pipx install poetry @@ -32,19 +41,18 @@ jobs: - name: Install dependencies run: poetry install --with unit-tests - name: Test with pytest - run: poetry run pytest -q --junitxml=pytest-${{ matrix.os }}-${{ matrix.python-version }}.xml --cov=semantic_kernel --cov-report=term-missing:skip-covered ./tests/unit | tee python-coverage-${{ matrix.os }}-${{ matrix.python-version }}.txt - continue-on-error: false + run: poetry run pytest -q --junitxml=pytest-${{ $FILE_ID }}.xml --cov=semantic_kernel --cov-report=term-missing:skip-covered ./tests/unit | tee python-coverage-${{ $FILE_ID }}.txt - name: Upload coverage uses: actions/upload-artifact@v4 with: - name: python-coverage-${{ matrix.os }}-${{ matrix.python-version }}.txt - path: python/python-coverage-${{ matrix.os }}-${{ matrix.python-version }}.txt + name: python-coverage-${{ $FILE_ID }}.txt + path: python/python-coverage-${{ $FILE_ID }}.txt overwrite: true retention-days: 1 - name: Upload pytest.xml uses: actions/upload-artifact@v4 with: - name: pytest-${{ matrix.os }}-${{ matrix.python-version }}.xml - path: python/pytest-${{ matrix.os }}-${{ matrix.python-version }}.xml + name: pytest-${{ $FILE_ID }}.xml + path: python/pytest-${{ $FILE_ID }}.xml overwrite: true retention-days: 1 From 11a07d9e883b59b06a2acbb6df1735bb37ed9cb3 Mon Sep 17 00:00:00 2001 From: edvan_microsoft Date: Thu, 11 Jul 2024 14:32:27 +0200 Subject: [PATCH 2/9] test rename to trigger --- .../connectors/ai/prompt_execution_settings.py | 18 ++++++++---------- ...gs.py => test_prompt_execution_settings.py} | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) rename python/tests/unit/connectors/{test_ai_request_settings.py => test_prompt_execution_settings.py} (80%) diff --git a/python/semantic_kernel/connectors/ai/prompt_execution_settings.py b/python/semantic_kernel/connectors/ai/prompt_execution_settings.py index d40a9913fee7..c530c09342a6 100644 --- a/python/semantic_kernel/connectors/ai/prompt_execution_settings.py +++ b/python/semantic_kernel/connectors/ai/prompt_execution_settings.py @@ -36,17 +36,15 @@ class PromptExecutionSettings(KernelBaseModel): @model_validator(mode="before") @classmethod - def parse_function_choice_behavior(cls, data: dict[str, Any]) -> dict[str, Any] | None: + def parse_function_choice_behavior(cls, data: dict[str, Any]) -> dict[str, Any]: """Parse the function choice behavior data.""" - if data: - function_choice_behavior_data = data.get("function_choice_behavior") - if function_choice_behavior_data: - if isinstance(function_choice_behavior_data, str): - data["function_choice_behavior"] = FunctionChoiceBehavior.from_string(function_choice_behavior_data) - elif isinstance(function_choice_behavior_data, dict): - data["function_choice_behavior"] = FunctionChoiceBehavior.from_dict(function_choice_behavior_data) - return data - return None + function_choice_behavior_data = data.get("function_choice_behavior") + if function_choice_behavior_data: + if isinstance(function_choice_behavior_data, str): + data["function_choice_behavior"] = FunctionChoiceBehavior.from_string(function_choice_behavior_data) + elif isinstance(function_choice_behavior_data, dict): + data["function_choice_behavior"] = FunctionChoiceBehavior.from_dict(function_choice_behavior_data) + return data def __init__(self, service_id: str | None = None, **kwargs: Any): """Initialize the prompt execution settings. diff --git a/python/tests/unit/connectors/test_ai_request_settings.py b/python/tests/unit/connectors/test_prompt_execution_settings.py similarity index 80% rename from python/tests/unit/connectors/test_ai_request_settings.py rename to python/tests/unit/connectors/test_prompt_execution_settings.py index 1bde8a863e78..fae89e44425b 100644 --- a/python/tests/unit/connectors/test_ai_request_settings.py +++ b/python/tests/unit/connectors/test_prompt_execution_settings.py @@ -3,13 +3,13 @@ from semantic_kernel.connectors.ai import PromptExecutionSettings -def test_default_complete_prompt_execution_settings(): +def test_init(): settings = PromptExecutionSettings() assert settings.service_id is None assert settings.extension_data == {} -def test_custom_complete_prompt_execution_settings(): +def test_init_with_data(): ext_data = {"test": "test"} settings = PromptExecutionSettings(service_id="test", extension_data=ext_data) assert settings.service_id == "test" From 208dd25b8bc2912320a2b9068a318704d070a474 Mon Sep 17 00:00:00 2001 From: edvan_microsoft Date: Thu, 11 Jul 2024 14:38:40 +0200 Subject: [PATCH 3/9] change env var --- .github/workflows/python-test-coverage.yml | 4 ++-- .github/workflows/python-unit-tests.yml | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-test-coverage.yml b/.github/workflows/python-test-coverage.yml index aaa41f9c9141..20ce77e37577 100644 --- a/.github/workflows/python-test-coverage.yml +++ b/.github/workflows/python-test-coverage.yml @@ -41,7 +41,7 @@ jobs: continue-on-error: true uses: dawidd6/action-download-artifact@v3 with: - name: python-coverage-${{ $FILE_ID }}.txt + name: python-coverage-$FILE_ID.txt github_token: ${{ secrets.GH_ACTIONS_PR_WRITE }} workflow: python-unit-tests.yml search_artifacts: true @@ -50,7 +50,7 @@ jobs: continue-on-error: true uses: dawidd6/action-download-artifact@v3 with: - name: pytest-${{ $FILE_ID }}.xml + name: pytest-$FILE_ID.xml github_token: ${{ secrets.GH_ACTIONS_PR_WRITE }} workflow: python-unit-tests.yml search_artifacts: true diff --git a/.github/workflows/python-unit-tests.yml b/.github/workflows/python-unit-tests.yml index 9edcfae0a9ad..8a0c95f3ffeb 100644 --- a/.github/workflows/python-unit-tests.yml +++ b/.github/workflows/python-unit-tests.yml @@ -29,7 +29,7 @@ jobs: steps: - name: Setup filename variables run: | - echo "FILE_ID=$(echo ${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV + echo "file_id=$(echo ${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV - uses: actions/checkout@v4 - name: Install poetry run: pipx install poetry @@ -41,18 +41,18 @@ jobs: - name: Install dependencies run: poetry install --with unit-tests - name: Test with pytest - run: poetry run pytest -q --junitxml=pytest-${{ $FILE_ID }}.xml --cov=semantic_kernel --cov-report=term-missing:skip-covered ./tests/unit | tee python-coverage-${{ $FILE_ID }}.txt + run: poetry run pytest -q --junitxml=pytest-$FILE_ID.xml --cov=semantic_kernel --cov-report=term-missing:skip-covered ./tests/unit | tee python-coverage-$FILE_ID.txt - name: Upload coverage uses: actions/upload-artifact@v4 with: - name: python-coverage-${{ $FILE_ID }}.txt - path: python/python-coverage-${{ $FILE_ID }}.txt + name: python-coverage-$FILE_ID.txt + path: python/python-coverage-$FILE_ID.txt overwrite: true retention-days: 1 - name: Upload pytest.xml uses: actions/upload-artifact@v4 with: - name: pytest-${{ $FILE_ID }}.xml - path: python/pytest-${{ $FILE_ID }}.xml + name: pytest-$FILE_ID.xml + path: python/pytest-$FILE_ID.xml overwrite: true retention-days: 1 From d6057a75408a7ada8017b5cd19ca9fff9444795a Mon Sep 17 00:00:00 2001 From: edvan_microsoft Date: Thu, 11 Jul 2024 14:40:06 +0200 Subject: [PATCH 4/9] echo fix --- .github/workflows/python-test-coverage.yml | 2 +- .github/workflows/python-unit-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-test-coverage.yml b/.github/workflows/python-test-coverage.yml index 20ce77e37577..57ea83ed20b7 100644 --- a/.github/workflows/python-test-coverage.yml +++ b/.github/workflows/python-test-coverage.yml @@ -26,7 +26,7 @@ jobs: steps: - name: Setup filename variables run: | - echo "FILE_ID=$(${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV + echo "FILE_ID=${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV - name: Wait for unit tests to succeed continue-on-error: true uses: lewagon/wait-on-check-action@v1.3.4 diff --git a/.github/workflows/python-unit-tests.yml b/.github/workflows/python-unit-tests.yml index 8a0c95f3ffeb..d02ac60bf4e3 100644 --- a/.github/workflows/python-unit-tests.yml +++ b/.github/workflows/python-unit-tests.yml @@ -29,7 +29,7 @@ jobs: steps: - name: Setup filename variables run: | - echo "file_id=$(echo ${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV + echo "FILE_ID=${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV - uses: actions/checkout@v4 - name: Install poetry run: pipx install poetry From 838ccde61ce2bd0d2cc8029ef5939acf47856758 Mon Sep 17 00:00:00 2001 From: edvan_microsoft Date: Thu, 11 Jul 2024 14:42:19 +0200 Subject: [PATCH 5/9] small fixes to working directory --- .github/workflows/python-unit-tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-unit-tests.yml b/.github/workflows/python-unit-tests.yml index d02ac60bf4e3..80a27111d977 100644 --- a/.github/workflows/python-unit-tests.yml +++ b/.github/workflows/python-unit-tests.yml @@ -25,7 +25,7 @@ jobs: contents: write defaults: run: - working-directory: ./python + working-directory: python steps: - name: Setup filename variables run: | @@ -41,18 +41,18 @@ jobs: - name: Install dependencies run: poetry install --with unit-tests - name: Test with pytest - run: poetry run pytest -q --junitxml=pytest-$FILE_ID.xml --cov=semantic_kernel --cov-report=term-missing:skip-covered ./tests/unit | tee python-coverage-$FILE_ID.txt + run: poetry run pytest -q --junitxml=pytest.xml --cov=semantic_kernel --cov-report=term-missing:skip-covered ./tests/unit | tee python-coverage.txt - name: Upload coverage uses: actions/upload-artifact@v4 with: name: python-coverage-$FILE_ID.txt - path: python/python-coverage-$FILE_ID.txt + path: python-coverage.txt overwrite: true retention-days: 1 - name: Upload pytest.xml uses: actions/upload-artifact@v4 with: name: pytest-$FILE_ID.xml - path: python/pytest-$FILE_ID.xml + path: pytest.xml overwrite: true retention-days: 1 From 877e53ac7e8eeb4dd1302331e66cf7765f74aeec Mon Sep 17 00:00:00 2001 From: edvan_microsoft Date: Thu, 11 Jul 2024 14:43:42 +0200 Subject: [PATCH 6/9] change order --- .github/workflows/python-test-coverage.yml | 5 ++--- .github/workflows/python-unit-tests.yml | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-test-coverage.yml b/.github/workflows/python-test-coverage.yml index 57ea83ed20b7..c8b27f83f3ef 100644 --- a/.github/workflows/python-test-coverage.yml +++ b/.github/workflows/python-test-coverage.yml @@ -24,9 +24,6 @@ jobs: python-version: ["3.10"] os: [ubuntu-latest] steps: - - name: Setup filename variables - run: | - echo "FILE_ID=${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV - name: Wait for unit tests to succeed continue-on-error: true uses: lewagon/wait-on-check-action@v1.3.4 @@ -37,6 +34,8 @@ jobs: wait-interval: 10 allowed-conclusions: success - uses: actions/checkout@v4 + - name: Setup filename variables + run: echo "FILE_ID=${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV - name: Download coverage continue-on-error: true uses: dawidd6/action-download-artifact@v3 diff --git a/.github/workflows/python-unit-tests.yml b/.github/workflows/python-unit-tests.yml index 80a27111d977..fd3877dcd9fb 100644 --- a/.github/workflows/python-unit-tests.yml +++ b/.github/workflows/python-unit-tests.yml @@ -27,10 +27,9 @@ jobs: run: working-directory: python steps: - - name: Setup filename variables - run: | - echo "FILE_ID=${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV - uses: actions/checkout@v4 + - name: Setup filename variables + run: echo "FILE_ID=${{ github.run_id }}-${{ matrix.os }}-${{ matrix.python-version }}" >> $GITHUB_ENV - name: Install poetry run: pipx install poetry - name: Set up Python ${{ matrix.python-version }} From 90b285dfc7be3cc3f430f893940b06efe8ecd76e Mon Sep 17 00:00:00 2001 From: edvan_microsoft Date: Thu, 11 Jul 2024 14:45:36 +0200 Subject: [PATCH 7/9] updated 3.13 version --- .github/workflows/python-unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-unit-tests.yml b/.github/workflows/python-unit-tests.yml index fd3877dcd9fb..5075931a6ce9 100644 --- a/.github/workflows/python-unit-tests.yml +++ b/.github/workflows/python-unit-tests.yml @@ -18,7 +18,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] experimental: [false] include: - - python-version: "3.13" + - python-version: "3.13.0-beta.3" os: "ubuntu-latest" experimental: true permissions: From 1e6334f14e9cc30da0737e775b078b9b040ae2ad Mon Sep 17 00:00:00 2001 From: edvan_microsoft Date: Thu, 11 Jul 2024 14:46:14 +0200 Subject: [PATCH 8/9] added path back --- .github/workflows/python-unit-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-unit-tests.yml b/.github/workflows/python-unit-tests.yml index 5075931a6ce9..3e7678d5a3df 100644 --- a/.github/workflows/python-unit-tests.yml +++ b/.github/workflows/python-unit-tests.yml @@ -45,13 +45,13 @@ jobs: uses: actions/upload-artifact@v4 with: name: python-coverage-$FILE_ID.txt - path: python-coverage.txt + path: python/python-coverage.txt overwrite: true retention-days: 1 - name: Upload pytest.xml uses: actions/upload-artifact@v4 with: name: pytest-$FILE_ID.xml - path: pytest.xml + path: python/pytest.xml overwrite: true retention-days: 1 From 1a960d4b6c99dd8e7881de01b1e3de03c8f8fcd7 Mon Sep 17 00:00:00 2001 From: edvan_microsoft Date: Thu, 11 Jul 2024 14:52:33 +0200 Subject: [PATCH 9/9] updated env syntax --- .github/workflows/python-test-coverage.yml | 4 ++-- .github/workflows/python-unit-tests.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-test-coverage.yml b/.github/workflows/python-test-coverage.yml index c8b27f83f3ef..1caef440be85 100644 --- a/.github/workflows/python-test-coverage.yml +++ b/.github/workflows/python-test-coverage.yml @@ -40,7 +40,7 @@ jobs: continue-on-error: true uses: dawidd6/action-download-artifact@v3 with: - name: python-coverage-$FILE_ID.txt + name: python-coverage-${{ env.FILE_ID }}.txt github_token: ${{ secrets.GH_ACTIONS_PR_WRITE }} workflow: python-unit-tests.yml search_artifacts: true @@ -49,7 +49,7 @@ jobs: continue-on-error: true uses: dawidd6/action-download-artifact@v3 with: - name: pytest-$FILE_ID.xml + name: pytest-${{ env.FILE_ID }}.xml github_token: ${{ secrets.GH_ACTIONS_PR_WRITE }} workflow: python-unit-tests.yml search_artifacts: true diff --git a/.github/workflows/python-unit-tests.yml b/.github/workflows/python-unit-tests.yml index 3e7678d5a3df..d3afc9e7a96e 100644 --- a/.github/workflows/python-unit-tests.yml +++ b/.github/workflows/python-unit-tests.yml @@ -44,14 +44,14 @@ jobs: - name: Upload coverage uses: actions/upload-artifact@v4 with: - name: python-coverage-$FILE_ID.txt + name: python-coverage-${{ env.FILE_ID }}.txt path: python/python-coverage.txt overwrite: true - retention-days: 1 + retention-days: 1 - name: Upload pytest.xml uses: actions/upload-artifact@v4 with: - name: pytest-$FILE_ID.xml + name: pytest-${{ env.FILE_ID }}.xml path: python/pytest.xml overwrite: true retention-days: 1