diff --git a/.github/workflows/python-test-coverage.yml b/.github/workflows/python-test-coverage.yml index b6609ea232ea..1caef440be85 100644 --- a/.github/workflows/python-test-coverage.yml +++ b/.github/workflows/python-test-coverage.yml @@ -34,11 +34,13 @@ 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 with: - name: python-coverage-${{ matrix.os }}-${{ matrix.python-version }}.txt + name: python-coverage-${{ env.FILE_ID }}.txt github_token: ${{ secrets.GH_ACTIONS_PR_WRITE }} workflow: python-unit-tests.yml search_artifacts: true @@ -47,7 +49,7 @@ jobs: continue-on-error: true uses: dawidd6/action-download-artifact@v3 with: - name: pytest-${{ matrix.os }}-${{ matrix.python-version }}.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 da9eef81eeb2..d3afc9e7a96e 100644 --- a/.github/workflows/python-unit-tests.yml +++ b/.github/workflows/python-unit-tests.yml @@ -10,18 +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.0-beta.3" + os: "ubuntu-latest" + experimental: true permissions: contents: write defaults: run: - working-directory: ./python + working-directory: python steps: - 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 }} @@ -32,19 +40,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.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-${{ matrix.os }}-${{ matrix.python-version }}.txt - path: python/python-coverage-${{ matrix.os }}-${{ matrix.python-version }}.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-${{ matrix.os }}-${{ matrix.python-version }}.xml - path: python/pytest-${{ matrix.os }}-${{ matrix.python-version }}.xml + name: pytest-${{ env.FILE_ID }}.xml + path: python/pytest.xml overwrite: true retention-days: 1 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"