diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5bc831913ae4..d0077b870b5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,7 @@ jobs: - name: Coverage if: matrix.python-version == '3.10' run: | - pip install -e .[mathchat,test] + pip install -e .[test] pip uninstall -y openai coverage run -a -m pytest test coverage xml diff --git a/.github/workflows/contrib-openai.yml b/.github/workflows/contrib-openai.yml index c4f19b78f526..78129563c2be 100644 --- a/.github/workflows/contrib-openai.yml +++ b/.github/workflows/contrib-openai.yml @@ -13,7 +13,7 @@ on: - 'setup.py' jobs: - RetrieveChatTest: + OpenAI4ContribTests: strategy: matrix: os: [ubuntu-latest] @@ -37,12 +37,12 @@ jobs: pip install -e . python -c "import autogen" pip install coverage pytest-asyncio - - name: Install packages for test when needed + - name: Install packages for Retrievechat run: | pip install docker pip install qdrant_client[fastembed] pip install -e .[retrievechat] - - name: Coverage + - name: Coverage Retrievechat env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} @@ -50,6 +50,25 @@ jobs: OAI_CONFIG_LIST: ${{ secrets.OAI_CONFIG_LIST }} run: | coverage run -a -m pytest test/agentchat/contrib/test_retrievechat.py test/agentchat/contrib/test_qdrant_retrievechat.py + + - name: Install packages for MathChat + id: install_mathchat + if: ${{ always() }} + run: | + pip install docker + pip install -e .[mathchat] + - name: Coverage MathChat + if: ${{ always() && steps.install_mathchat.outcome == 'success' }} + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} + AZURE_OPENAI_API_BASE: ${{ secrets.AZURE_OPENAI_API_BASE }} + OAI_CONFIG_LIST: ${{ secrets.OAI_CONFIG_LIST }} + run: | + coverage run -a -m pytest test/agentchat/contrib/test_math_user_proxy_agent.py + + - name: convert coverage to xml + run: | coverage xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 diff --git a/.github/workflows/contrib-tests.yml b/.github/workflows/contrib-tests.yml index 70d41de30c27..9fa3b6dacfde 100644 --- a/.github/workflows/contrib-tests.yml +++ b/.github/workflows/contrib-tests.yml @@ -5,7 +5,7 @@ name: ContribTests on: pull_request: - branches: ['main', 'dev/v0.2'] + branches: ['main'] paths: - 'autogen/**' - 'test/agentchat/contrib/**' @@ -17,7 +17,7 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: - RetrieveChatTest: + ContribTests: runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -34,6 +34,7 @@ jobs: run: | python -m pip install --upgrade pip wheel pip install pytest + # RetrieveChat - name: Install qdrant_client when python-version is 3.10 if: matrix.python-version == '3.10' || matrix.python-version == '3.8' run: | @@ -43,8 +44,23 @@ jobs: pip install -e .[retrievechat] pip uninstall -y openai - name: Test RetrieveChat + if: matrix.python-version != '3.10' run: | pytest test/test_retrieve_utils.py test/agentchat/contrib/test_retrievechat.py test/agentchat/contrib/test_qdrant_retrievechat.py + + # MathChat + - name: Install packages and dependencies for MathChat + id: install_mathchat + if: ${{ always() }} + run: | + pip install -e .[mathchat] + pip uninstall -y openai + - name: test MathChat + if: ${{ always() && steps.install_mathchat.outcome == 'success' && matrix.python-version != '3.10'}} + run: | + pytest test/agentchat/contrib/test_math_user_proxy_agent.py + + # Coverage - name: Coverage if: matrix.python-version == '3.10' run: | diff --git a/test/agentchat/test_math_user_proxy_agent.py b/test/agentchat/contrib/test_math_user_proxy_agent.py similarity index 88% rename from test/agentchat/test_math_user_proxy_agent.py rename to test/agentchat/contrib/test_math_user_proxy_agent.py index 565aa80eb36c..d442da06d353 100644 --- a/test/agentchat/test_math_user_proxy_agent.py +++ b/test/agentchat/contrib/test_math_user_proxy_agent.py @@ -6,19 +6,22 @@ _remove_print, _add_print_to_last_line, ) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST +import os + +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 try: - from openai import OpenAI + import openai + + OPENAI_INSTALLED = True except ImportError: - skip = True -else: - skip = False + OPENAI_INSTALLED = False @pytest.mark.skipif( - skip or sys.platform in ["darwin", "win32"], - reason="do not run on MacOS or windows", + not OPENAI_INSTALLED or sys.platform in ["darwin", "win32"], + reason="do not run on MacOS or windows or dependency is not installed", ) def test_math_user_proxy_agent(): from autogen.agentchat.assistant_agent import AssistantAgent @@ -119,7 +122,7 @@ def test_generate_prompt(): if __name__ == "__main__": - # test_add_remove_print() - # test_execute_one_python_code() - # test_generate_prompt() + test_add_remove_print() + test_execute_one_python_code() + test_generate_prompt() test_math_user_proxy_agent()