From ce20de9afbf7974bb964e6f19845f0841d5c18fb Mon Sep 17 00:00:00 2001 From: Eric Zhu Date: Fri, 17 Jan 2025 06:10:06 -0800 Subject: [PATCH 1/2] fix: normalize finish reason in CreateResult response (#5085) Co-authored-by: Jack Gerrits --- .../autogen-ext/src/autogen_ext/models/openai/_openai_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py b/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py index 04512d7ce9b2..3cfcb1c1b923 100644 --- a/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py +++ b/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py @@ -575,7 +575,7 @@ async def create( for x in choice.logprobs.content ] response = CreateResult( - finish_reason=finish_reason, # type: ignore + finish_reason=normalize_stop_reason(finish_reason), content=content, usage=usage, cached=False, From a1fdbd96922b89c2383fce16deda483712e1624f Mon Sep 17 00:00:00 2001 From: Leonardo Pinheiro Date: Sat, 18 Jan 2025 00:32:18 +1000 Subject: [PATCH 2/2] Use caching to run tests and report coverage (#5086) * use caching to run tests and report coverage * fix test step dep name * try to fix cov fname * add working dir to mv step * update artifact download * fmt * reduce concurrency on ext test --------- Co-authored-by: Leonardo Pinheiro --- .github/workflows/checks.yml | 48 ++++++++++--------- .../packages/autogen-agentchat/pyproject.toml | 3 +- python/packages/autogen-core/pyproject.toml | 3 +- python/packages/autogen-ext/pyproject.toml | 7 +-- .../autogen-magentic-one/pyproject.toml | 7 +-- python/packages/autogen-studio/pyproject.toml | 3 +- .../autogen-test-utils/pyproject.toml | 1 - .../component-schema-gen/pyproject.toml | 1 - .../packages/magentic-one-cli/pyproject.toml | 1 - python/pyproject.toml | 3 +- 10 files changed, 31 insertions(+), 46 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0a1e8024ce1f..1ea805d93263 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -132,6 +132,7 @@ jobs: - name: Run uv sync run: | uv sync --locked --all-extras + echo "PKG_NAME=$(basename '${{ matrix.package }}')" >> $GITHUB_ENV working-directory: ./python - name: Run task @@ -140,8 +141,20 @@ jobs: poe --directory ${{ matrix.package }} test working-directory: ./python + - name: Move coverage file + run: | + mv ${{ matrix.package }}/coverage.xml coverage_${{ env.PKG_NAME }}.xml + working-directory: ./python + + - name: Upload coverage artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-${{ env.PKG_NAME }} + path: ./python/coverage_${{ env.PKG_NAME }}.xml + codecov: runs-on: ubuntu-latest + needs: [test] strategy: matrix: package: @@ -153,31 +166,20 @@ jobs: ] steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v5 - with: - enable-cache: true - version: "0.5.18" - - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - name: Run uv sync + - name: Set up environment run: | - uv sync --locked --all-extras - - working-directory: ./python - - name: Run task - run: | - source ${{ github.workspace }}/python/.venv/bin/activate - poe --directory ${{ matrix.package }} coverage - working-directory: ./python - - name: Upload coverage - uses: codecov/codecov-action@v5 + echo "PKG_NAME=$(basename '${{ matrix.package }}')" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: coverage-${{ env.PKG_NAME }} + path: ./ + - uses: codecov/codecov-action@v5 with: - fail_ci_if_error: true # optional (default = false) - files: ${{ matrix.package }}/coverage.xml # optional - flags: unittests # optional - name: codecov-umbrella # optional - verbose: true # optional (default = false) + files: coverage_${{ env.PKG_NAME }}.xml + flags: unittests + name: codecov-umbrella + fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} docs: diff --git a/python/packages/autogen-agentchat/pyproject.toml b/python/packages/autogen-agentchat/pyproject.toml index e84b70bcef07..b0b49d6231cc 100644 --- a/python/packages/autogen-agentchat/pyproject.toml +++ b/python/packages/autogen-agentchat/pyproject.toml @@ -35,5 +35,4 @@ testpaths = ["tests"] include = "../../shared_tasks.toml" [tool.poe.tasks] -test = "pytest -n auto" -coverage = "pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml" +test = "pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml" diff --git a/python/packages/autogen-core/pyproject.toml b/python/packages/autogen-core/pyproject.toml index 78eb2bef3b4f..39bece3b0639 100644 --- a/python/packages/autogen-core/pyproject.toml +++ b/python/packages/autogen-core/pyproject.toml @@ -106,8 +106,7 @@ mypy = [ include = "../../shared_tasks.toml" [tool.poe.tasks] -test = "pytest -n auto" -coverage = "pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml" +test = "pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml" mypy.default_item_type = "cmd" mypy.sequence = [ "mypy --config-file ../../pyproject.toml --exclude src/autogen_core/application/protos --exclude tests/protos src tests", diff --git a/python/packages/autogen-ext/pyproject.toml b/python/packages/autogen-ext/pyproject.toml index e0f05425b487..8f87bfa00e40 100644 --- a/python/packages/autogen-ext/pyproject.toml +++ b/python/packages/autogen-ext/pyproject.toml @@ -87,14 +87,9 @@ include = "../../shared_tasks.toml" [tool.poe.tasks] test.sequence = [ "playwright install", - "pytest -n auto", + "pytest -n 1 --cov=src --cov-report=term-missing --cov-report=xml", ] test.default_item_type = "cmd" -coverage.sequence = [ - "playwright install", - "pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml", -] -coverage.default_item_type = "cmd" mypy = "mypy --config-file ../../pyproject.toml --exclude src/autogen_ext/runtimes/grpc/protos --exclude tests/protos src tests" [tool.mypy] diff --git a/python/packages/autogen-magentic-one/pyproject.toml b/python/packages/autogen-magentic-one/pyproject.toml index a778c390be6f..b6e333f7906d 100644 --- a/python/packages/autogen-magentic-one/pyproject.toml +++ b/python/packages/autogen-magentic-one/pyproject.toml @@ -54,15 +54,10 @@ include = "../../shared_tasks.toml" [tool.poe.tasks] test.sequence = [ - "playwright install", - "pytest -n auto", -] -test.default_item_type = "cmd" -coverage.sequence = [ "playwright install", "pytest -n auto --cov=src --cov-report=term-missing --cov-report=xml", ] -coverage.default_item_type = "cmd" +test.default_item_type = "cmd" [tool.ruff] extend = "../../pyproject.toml" diff --git a/python/packages/autogen-studio/pyproject.toml b/python/packages/autogen-studio/pyproject.toml index cfc7c9302e99..598a58d4e3f3 100644 --- a/python/packages/autogen-studio/pyproject.toml +++ b/python/packages/autogen-studio/pyproject.toml @@ -88,5 +88,4 @@ ignore = ["B008"] fmt = "ruff format" format.ref = "fmt" lint = "ruff check" -test = "pytest -n 0" -coverage = "pytest -n 0 --cov=autogenstudio --cov-report=term-missing" +test = "pytest -n 0 --cov=autogenstudio --cov-report=term-missing" diff --git a/python/packages/autogen-test-utils/pyproject.toml b/python/packages/autogen-test-utils/pyproject.toml index 0bbda61651ce..76877e5a9c42 100644 --- a/python/packages/autogen-test-utils/pyproject.toml +++ b/python/packages/autogen-test-utils/pyproject.toml @@ -27,4 +27,3 @@ include = "../../shared_tasks.toml" [tool.poe.tasks] mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src" test = "true" -coverage = "true" diff --git a/python/packages/component-schema-gen/pyproject.toml b/python/packages/component-schema-gen/pyproject.toml index eef5fc40588a..272142601eed 100644 --- a/python/packages/component-schema-gen/pyproject.toml +++ b/python/packages/component-schema-gen/pyproject.toml @@ -39,4 +39,3 @@ include = "../../shared_tasks.toml" [tool.poe.tasks] mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src" test = "true" -coverage = "true" diff --git a/python/packages/magentic-one-cli/pyproject.toml b/python/packages/magentic-one-cli/pyproject.toml index 20960d2eaf98..240d78e2f3d8 100644 --- a/python/packages/magentic-one-cli/pyproject.toml +++ b/python/packages/magentic-one-cli/pyproject.toml @@ -44,4 +44,3 @@ include = "../../shared_tasks.toml" [tool.poe.tasks] mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src" test = "true" -coverage = "true" diff --git a/python/pyproject.toml b/python/pyproject.toml index 27a40d135c86..c2c5c84bbfb1 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -90,11 +90,10 @@ lint = "python run_task_in_pkgs_if_exist.py lint" pyright = "python run_task_in_pkgs_if_exist.py pyright" mypy = "python run_task_in_pkgs_if_exist.py mypy" test = "python run_task_in_pkgs_if_exist.py test" -coverage = "python run_task_in_pkgs_if_exist.py coverage" markdown-code-lint = """python check_md_code_blocks.py ../README.md ./packages/autogen-core/docs/src/**/*.md""" samples-code-check = """pyright ./samples""" -check = ["fmt", "lint", "pyright", "mypy", "coverage", "markdown-code-lint", "samples-code-check"] +check = ["fmt", "lint", "pyright", "mypy", "test", "markdown-code-lint", "samples-code-check"] gen-proto = "python -m grpc_tools.protoc --python_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --grpc_python_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --mypy_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --mypy_grpc_out=./packages/autogen-ext/src/autogen_ext/runtimes/grpc/protos --proto_path ../protos/ agent_worker.proto --proto_path ../protos/ cloudevent.proto"