From a2428be82b7fb69dd34d87e762232afa969f8d60 Mon Sep 17 00:00:00 2001 From: Maxim Saplin Date: Wed, 3 Jan 2024 00:25:23 +0300 Subject: [PATCH 1/3] Fixing RetrieveChat part --- .github/workflows/contrib-tests.yml | 3 +-- .../agentchat/contrib/test_qdrant_retrievechat.py | 11 ++++++----- test/agentchat/contrib/test_retrievechat.py | 15 ++++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/contrib-tests.yml b/.github/workflows/contrib-tests.yml index 7e1eaa7d85b..aa96237400b 100644 --- a/.github/workflows/contrib-tests.yml +++ b/.github/workflows/contrib-tests.yml @@ -45,10 +45,9 @@ jobs: - name: Install packages and dependencies for RetrieveChat run: | pip install -e .[retrievechat] - pip uninstall -y openai - name: Test RetrieveChat run: | - pytest test/test_retrieve_utils.py test/agentchat/contrib/test_retrievechat.py test/agentchat/contrib/test_qdrant_retrievechat.py + pytest test/test_retrieve_utils.py test/agentchat/contrib/test_qdrant_retrievechat.py --skip-openai - name: Coverage if: matrix.python-version == '3.10' run: | diff --git a/test/agentchat/contrib/test_qdrant_retrievechat.py b/test/agentchat/contrib/test_qdrant_retrievechat.py index 1d3c5afd6af..d8228ed68d4 100644 --- a/test/agentchat/contrib/test_qdrant_retrievechat.py +++ b/test/agentchat/contrib/test_qdrant_retrievechat.py @@ -3,6 +3,7 @@ import pytest from autogen.agentchat.contrib.retrieve_assistant_agent import RetrieveAssistantAgent from autogen import config_list_from_json +from conftest import skip_openai sys.path.append(os.path.join(os.path.dirname(__file__), "..")) from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 @@ -22,17 +23,17 @@ try: import openai - - OPENAI_INSTALLED = True except ImportError: - OPENAI_INSTALLED = False + skip = True +else: + skip = False or skip_openai test_dir = os.path.join(os.path.dirname(__file__), "../..", "test_files") @pytest.mark.skipif( - sys.platform in ["darwin", "win32"] or not QDRANT_INSTALLED or not OPENAI_INSTALLED, - reason="do not run on MacOS or windows or dependency is not installed", + sys.platform in ["darwin", "win32"] or not QDRANT_INSTALLED or skip, + reason="do not run on MacOS or windows OR dependency is not installed OR requested to skip", ) def test_retrievechat(): conversations = {} diff --git a/test/agentchat/contrib/test_retrievechat.py b/test/agentchat/contrib/test_retrievechat.py index 574e3571b62..16e054db8d7 100644 --- a/test/agentchat/contrib/test_retrievechat.py +++ b/test/agentchat/contrib/test_retrievechat.py @@ -2,6 +2,7 @@ import os import sys import autogen +from conftest import skip_openai sys.path.append(os.path.join(os.path.dirname(__file__), "..")) from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 @@ -16,15 +17,15 @@ ) import chromadb from chromadb.utils import embedding_functions as ef - - skip_test = False except ImportError: - skip_test = True + skip = True +else: + skip = False or skip_openai @pytest.mark.skipif( - sys.platform in ["darwin", "win32"] or skip_test, - reason="do not run on MacOS or windows or dependency is not installed", + sys.platform in ["darwin", "win32"] or skip, + reason="do not run on MacOS or windows OR dependency is not installed OR requested to skip", ) def test_retrievechat(): conversations = {} @@ -69,8 +70,8 @@ def test_retrievechat(): @pytest.mark.skipif( - sys.platform in ["darwin", "win32"] or skip_test, - reason="do not run on MacOS or windows or dependency is not installed", + sys.platform in ["darwin", "win32"] or skip, + reason="do not run on MacOS or windows OR dependency is not installed OR requested to skip", ) def test_retrieve_config(caplog): # test warning message when no docs_path is provided From 8e6dfcbaf6c877813496941e20ae1fbbf7db17aa Mon Sep 17 00:00:00 2001 From: Maxim Saplin Date: Wed, 3 Jan 2024 12:48:33 +0300 Subject: [PATCH 2/3] All 5 test groups are updated to --skip-openai --- .github/workflows/contrib-tests.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/contrib-tests.yml b/.github/workflows/contrib-tests.yml index aa96237400b..8eb26c0cceb 100644 --- a/.github/workflows/contrib-tests.yml +++ b/.github/workflows/contrib-tests.yml @@ -47,12 +47,12 @@ jobs: pip install -e .[retrievechat] - name: Test RetrieveChat run: | - pytest test/test_retrieve_utils.py test/agentchat/contrib/test_qdrant_retrievechat.py --skip-openai + pytest test/test_retrieve_utils.py test/agentchat/contrib/test_retrievechat.py test/agentchat/contrib/test_qdrant_retrievechat.py --skip-openai - name: Coverage if: matrix.python-version == '3.10' run: | pip install coverage>=5.3 - coverage run -a -m pytest test/test_retrieve_utils.py test/agentchat/contrib + coverage run -a -m pytest test/test_retrieve_utils.py test/agentchat/contrib/test_retrievechat.py test/agentchat/contrib/test_qdrant_retrievechat.py --skip-openai coverage xml - name: Upload coverage to Codecov if: matrix.python-version == '3.10' @@ -81,16 +81,15 @@ jobs: - name: Install packages and dependencies for Compression run: | pip install -e . - pip uninstall -y openai - name: Test Compression if: matrix.python-version != '3.10' # diversify the python versions run: | - pytest test/agentchat/contrib/test_compressible_agent.py + pytest test/agentchat/contrib/test_compressible_agent.py --skip-openai - name: Coverage if: matrix.python-version == '3.10' run: | pip install coverage>=5.3 - coverage run -a -m pytest test/agentchat/contrib/test_compressible_agent.py + coverage run -a -m pytest test/agentchat/contrib/test_compressible_agent.py --skip-openai coverage xml - name: Upload coverage to Codecov if: matrix.python-version == '3.10' @@ -119,16 +118,15 @@ jobs: - name: Install packages and dependencies for GPTAssistantAgent run: | pip install -e . - pip uninstall -y openai - name: Test GPTAssistantAgent if: matrix.python-version != '3.11' # diversify the python versions run: | - pytest test/agentchat/contrib/test_gpt_assistant.py + pytest test/agentchat/contrib/test_gpt_assistant.py --skip-openai - name: Coverage if: matrix.python-version == '3.11' run: | pip install coverage>=5.3 - coverage run -a -m pytest test/agentchat/contrib/test_gpt_assistant.py + coverage run -a -m pytest test/agentchat/contrib/test_gpt_assistant.py --skip-openai coverage xml - name: Upload coverage to Codecov if: matrix.python-version == '3.11' @@ -157,16 +155,15 @@ jobs: - name: Install packages and dependencies for TeachableAgent run: | pip install -e .[teachable] - pip uninstall -y openai - name: Test TeachableAgent if: matrix.python-version != '3.9' # diversify the python versions run: | - pytest test/agentchat/contrib/test_teachable_agent.py + pytest test/agentchat/contrib/test_teachable_agent.py --skip-openai - name: Coverage if: matrix.python-version == '3.9' run: | pip install coverage>=5.3 - coverage run -a -m pytest test/agentchat/contrib/test_teachable_agent.py + coverage run -a -m pytest test/agentchat/contrib/test_teachable_agent.py --skip-openai coverage xml - name: Upload coverage to Codecov if: matrix.python-version == '3.9' @@ -195,15 +192,14 @@ jobs: - name: Install packages and dependencies for LMM run: | pip install -e .[lmm] - pip uninstall -y openai - name: Test LMM and LLaVA run: | - pytest test/agentchat/contrib/test_img_utils.py test/agentchat/contrib/test_lmm.py test/agentchat/contrib/test_llava.py + pytest test/agentchat/contrib/test_img_utils.py test/agentchat/contrib/test_lmm.py test/agentchat/contrib/test_llava.py --skip-openai - name: Coverage if: matrix.python-version == '3.10' run: | pip install coverage>=5.3 - coverage run -a -m pytest test/agentchat/contrib/test_img_utils.py test/agentchat/contrib/test_lmm.py test/agentchat/contrib/test_llava.py + coverage run -a -m pytest test/agentchat/contrib/test_img_utils.py test/agentchat/contrib/test_lmm.py test/agentchat/contrib/test_llava.py --skip-openai coverage xml - name: Upload coverage to Codecov if: matrix.python-version == '3.10' From 29d110f38e5d9bf5ef313d32bbd0f33e452b8e63 Mon Sep 17 00:00:00 2001 From: Maxim Saplin Date: Mon, 8 Jan 2024 19:50:26 +0300 Subject: [PATCH 3/3] sys.path.append() fix --- test/agentchat/contrib/test_qdrant_retrievechat.py | 4 +++- test/agentchat/contrib/test_retrievechat.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/agentchat/contrib/test_qdrant_retrievechat.py b/test/agentchat/contrib/test_qdrant_retrievechat.py index d8228ed68d4..1a18e78a4de 100644 --- a/test/agentchat/contrib/test_qdrant_retrievechat.py +++ b/test/agentchat/contrib/test_qdrant_retrievechat.py @@ -3,7 +3,9 @@ import pytest from autogen.agentchat.contrib.retrieve_assistant_agent import RetrieveAssistantAgent from autogen import config_list_from_json -from conftest import skip_openai + +sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) +from conftest import skip_openai # noqa: E402 sys.path.append(os.path.join(os.path.dirname(__file__), "..")) from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 diff --git a/test/agentchat/contrib/test_retrievechat.py b/test/agentchat/contrib/test_retrievechat.py index 16e054db8d7..eeda1dc4891 100644 --- a/test/agentchat/contrib/test_retrievechat.py +++ b/test/agentchat/contrib/test_retrievechat.py @@ -2,7 +2,9 @@ import os import sys import autogen -from conftest import skip_openai + +sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) +from conftest import skip_openai # noqa: E402 sys.path.append(os.path.join(os.path.dirname(__file__), "..")) from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402