Skip to content

Commit

Permalink
Change contrib-tests.yml tests to use --skip-openai (#1132)
Browse files Browse the repository at this point in the history
* Fixing RetrieveChat part

* All 5 test groups are updated to --skip-openai

* sys.path.append() fix
  • Loading branch information
maxim-saplin committed Jan 10, 2024
1 parent 78fe8f9 commit 083ba32
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
27 changes: 11 additions & 16 deletions .github/workflows/contrib-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
13 changes: 8 additions & 5 deletions test/agentchat/contrib/test_qdrant_retrievechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = {}
Expand Down
17 changes: 10 additions & 7 deletions test/agentchat/contrib/test_retrievechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = {}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 083ba32

Please sign in to comment.