diff --git a/.github/workflows/contrib-tests.yml b/.github/workflows/contrib-tests.yml index 25bcef05b71..27a616b7719 100644 --- a/.github/workflows/contrib-tests.yml +++ b/.github/workflows/contrib-tests.yml @@ -45,15 +45,14 @@ 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_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' @@ -82,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' @@ -120,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' @@ -158,16 +155,15 @@ jobs: - name: Install packages and dependencies for Teachability run: | pip install -e .[teachable] - pip uninstall -y openai - - name: Test Teachability + - 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' @@ -196,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' diff --git a/test/agentchat/contrib/test_qdrant_retrievechat.py b/test/agentchat/contrib/test_qdrant_retrievechat.py index 1d3c5afd6af..1a18e78a4de 100644 --- a/test/agentchat/contrib/test_qdrant_retrievechat.py +++ b/test/agentchat/contrib/test_qdrant_retrievechat.py @@ -4,6 +4,9 @@ from autogen.agentchat.contrib.retrieve_assistant_agent import RetrieveAssistantAgent from autogen import config_list_from_json +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 @@ -22,17 +25,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..eeda1dc4891 100644 --- a/test/agentchat/contrib/test_retrievechat.py +++ b/test/agentchat/contrib/test_retrievechat.py @@ -3,6 +3,9 @@ import sys import autogen +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 @@ -16,15 +19,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 +72,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