Skip to content

Commit

Permalink
Merge pull request #342 from ag2ai/add-init-to-root-test-folder
Browse files Browse the repository at this point in the history
Add missing __init__.py files in test folders and fix imports
  • Loading branch information
davorrunje authored Jan 3, 2025
2 parents 4d84d42 + e8f5851 commit c3ad347
Show file tree
Hide file tree
Showing 65 changed files with 187 additions and 217 deletions.
3 changes: 3 additions & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
#
# SPDX-License-Identifier: Apache-2.0
3 changes: 3 additions & 0 deletions test/agentchat/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
#
# SPDX-License-Identifier: Apache-2.0
3 changes: 3 additions & 0 deletions test/agentchat/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
#
# SPDX-License-Identifier: Apache-2.0
3 changes: 3 additions & 0 deletions test/agentchat/contrib/agent_eval/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
#
# SPDX-License-Identifier: Apache-2.0
3 changes: 2 additions & 1 deletion test/agentchat/contrib/agent_eval/test_agent_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import json

import pytest
from conftest import reason, skip_openai # noqa: E402

import autogen
from autogen.agentchat.contrib.agent_eval.agent_eval import generate_criteria, quantify_criteria
from autogen.agentchat.contrib.agent_eval.criterion import Criterion
from autogen.agentchat.contrib.agent_eval.task import Task

from ....conftest import reason, skip_openai # noqa: E402

KEY_LOC = "notebook"
OAI_CONFIG_LIST = "OAI_CONFIG_LIST"

Expand Down
3 changes: 3 additions & 0 deletions test/agentchat/contrib/capabilities/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
#
# SPDX-License-Identifier: Apache-2.0
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
# SPDX-License-Identifier: MIT
#!/usr/bin/env python3 -m pytest

import os
import sys

from autogen import ConversableAgent, UserProxyAgent, config_list_from_json
from autogen.agentchat.contrib.capabilities.teachability import Teachability
from autogen.formatting_utils import colored

sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402
from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

# Specify the model to use. GPT-3.5 is less reliable than GPT-4 at learning from user input.
filter_dict = {"model": ["gpt-4o-mini"]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import sys
import tempfile
from typing import Any, Dict, Tuple
from typing import Any

import pytest

Expand All @@ -28,9 +28,7 @@
else:
skip_requirement = False

sys.path.append(os.path.join(os.path.dirname(__file__), "../../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
from conftest import MOCK_OPEN_AI_API_KEY, skip_openai # noqa: E402
from ....conftest import MOCK_OPEN_AI_API_KEY, skip_openai # noqa: E402

filter_dict = {"model": ["gpt-4o-mini"]}

Expand Down
10 changes: 2 additions & 8 deletions test/agentchat/contrib/capabilities/test_teachable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@
# SPDX-License-Identifier: MIT
#!/usr/bin/env python3 -m pytest

import os
import sys

import pytest

from autogen import ConversableAgent, config_list_from_json
from autogen.formatting_utils import colored

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
from ....conftest import skip_openai # noqa: E402
from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

try:
from autogen.agentchat.contrib.capabilities.teachability import Teachability
Expand Down
10 changes: 2 additions & 8 deletions test/agentchat/contrib/capabilities/test_transform_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@
#
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
# SPDX-License-Identifier: MIT
import os
import sys
import tempfile
from typing import Any, Dict, List, Union

import pytest

import autogen
from autogen.agentchat.contrib.capabilities.transform_messages import TransformMessages
from autogen.agentchat.contrib.capabilities.transforms import MessageHistoryLimiter, MessageTokenLimiter

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
from ....conftest import skip_openai # noqa: E402
from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402


@pytest.mark.skipif(skip_openai, reason="Requested to skip openai test.")
Expand Down
3 changes: 3 additions & 0 deletions test/agentchat/contrib/graph_rag/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
#
# SPDX-License-Identifier: Apache-2.0
3 changes: 2 additions & 1 deletion test/agentchat/contrib/graph_rag/test_falkor_graph_rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import sys

import pytest
from conftest import reason, skip_openai # noqa: E402
from graphrag_sdk import Attribute, AttributeType, Entity, Ontology, Relation

from ....conftest import reason, skip_openai # noqa: E402

try:
from autogen.agentchat.contrib.graph_rag.document import Document, DocumentType
from autogen.agentchat.contrib.graph_rag.falkor_graph_query_engine import (
Expand Down
3 changes: 2 additions & 1 deletion test/agentchat/contrib/graph_rag/test_neo4j_graph_rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from typing import Literal

import pytest
from conftest import reason, skip_openai # noqa: E402

from ....conftest import reason, skip_openai # noqa: E402

try:
from autogen.agentchat.contrib.graph_rag.document import Document, DocumentType
Expand Down
3 changes: 3 additions & 0 deletions test/agentchat/contrib/retrievechat/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
#
# SPDX-License-Identifier: Apache-2.0
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@
#!/usr/bin/env python3 -m pytest

import os
import sys

import pytest
from sentence_transformers import SentenceTransformer

from autogen import AssistantAgent, 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
from ....conftest import skip_openai # noqa: E402
from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

try:
import pgvector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@

from autogen import AssistantAgent, 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
from ....conftest import skip_openai # noqa: E402
from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

try:
import fastembed
Expand Down
8 changes: 2 additions & 6 deletions test/agentchat/contrib/retrievechat/test_retrievechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@
# SPDX-License-Identifier: MIT
#!/usr/bin/env python3 -m pytest

import os
import sys

import pytest

import autogen

sys.path.append(os.path.join(os.path.dirname(__file__), "../../.."))
from conftest import reason, 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
from ....conftest import reason, skip_openai # noqa: E402
from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

try:
import chromadb
Expand Down
7 changes: 2 additions & 5 deletions test/agentchat/contrib/test_agent_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@

import json
import os
import sys

import pytest

from autogen.agentchat.contrib.agent_builder import AgentBuilder

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
from conftest import reason, skip_openai # noqa: E402
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402
from ...conftest import reason, skip_openai # noqa: E402
from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

try:
import chromadb
Expand Down
7 changes: 2 additions & 5 deletions test/agentchat/contrib/test_agent_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
# SPDX-License-Identifier: MIT
import os
import sys

import pytest

import autogen
from autogen import AssistantAgent, UserProxyAgent
from autogen.agentchat.contrib.agent_optimizer import AgentOptimizer

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
from conftest import reason, skip_openai
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST
from ...conftest import reason, skip_openai
from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST

here = os.path.abspath(os.path.dirname(__file__))

Expand Down
12 changes: 3 additions & 9 deletions test/agentchat/contrib/test_captainagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@
#
# SPDX-License-Identifier: Apache-2.0
import os
import re
import sys

import pytest

from autogen import AssistantAgent, UserProxyAgent, config_list_from_json
from autogen import UserProxyAgent, config_list_from_json
from autogen.agentchat.contrib.captainagent import CaptainAgent
from autogen.agentchat.contrib.tool_retriever import ToolBuilder

sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
from conftest import MOCK_OPEN_AI_API_KEY, reason, 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
from ...conftest import reason, skip_openai # noqa: E402
from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

try:
import chromadb
Expand Down
7 changes: 2 additions & 5 deletions test/agentchat/contrib/test_gpt_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
from autogen.agentchat.contrib.gpt_assistant_agent import GPTAssistantAgent
from autogen.oai.openai_utils import detect_gpt_assistant_api_version, retrieve_assistants_by_name

sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
from conftest import reason, 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
from ...conftest import reason, skip_openai # noqa: E402
from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

if not skip_openai:
openai_config_list = autogen.config_list_from_json(
Expand Down
8 changes: 1 addition & 7 deletions test/agentchat/contrib/test_llamaindex_conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@
# SPDX-License-Identifier: MIT
#!/usr/bin/env python3 -m pytest

import os
import sys
import unittest
from unittest.mock import MagicMock, patch

import pytest
from conftest import MOCK_OPEN_AI_API_KEY

from autogen import GroupChat, GroupChatManager
from autogen.agentchat.contrib.llamaindex_conversable_agent import LLamaIndexConversableAgent
from autogen.agentchat.conversable_agent import ConversableAgent

sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from conftest import reason, skip_openai
from ...conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai

skip_reasons = [reason]
try:
Expand Down
3 changes: 2 additions & 1 deletion test/agentchat/contrib/test_llava.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
from unittest.mock import MagicMock, patch

import pytest
from conftest import MOCK_OPEN_AI_API_KEY

import autogen

from ...conftest import MOCK_OPEN_AI_API_KEY

try:
from autogen.agentchat.contrib.llava_agent import LLaVAAgent, _llava_call_binary_with_config, llava_call
except ImportError:
Expand Down
3 changes: 2 additions & 1 deletion test/agentchat/contrib/test_lmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from unittest.mock import MagicMock

import pytest
from conftest import MOCK_OPEN_AI_API_KEY

import autogen
from autogen.agentchat.conversable_agent import ConversableAgent

from ...conftest import MOCK_OPEN_AI_API_KEY

try:
from autogen.agentchat.contrib.img_utils import get_pil_image
from autogen.agentchat.contrib.multimodal_conversable_agent import MultimodalConversableAgent
Expand Down
3 changes: 1 addition & 2 deletions test/agentchat/contrib/test_reasoning_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@

import autogen
from autogen.agentchat.contrib.reasoning_agent import ReasoningAgent, ThinkNode, visualize_tree
from autogen.agentchat.user_proxy_agent import UserProxyAgent

sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
from conftest import reason, skip_openai # noqa: E402
from ...conftest import reason, skip_openai # noqa: E402

skip_reasons = [reason]
try:
Expand Down
7 changes: 2 additions & 5 deletions test/agentchat/contrib/test_society_of_mind_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
import autogen
from autogen.agentchat.contrib.society_of_mind_agent import SocietyOfMindAgent

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
from conftest import skip_openai # noqa: E402
from ...conftest import skip_openai # noqa: E402
from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

if not skip_openai:
config_list = autogen.config_list_from_json(env_or_file=OAI_CONFIG_LIST, file_location=KEY_LOC)
Expand Down
8 changes: 2 additions & 6 deletions test/agentchat/contrib/test_web_surfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@

import os
import re
import sys

import pytest

from autogen import UserProxyAgent, config_list_from_json
from autogen.oai.openai_utils import filter_config

sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
from conftest import MOCK_OPEN_AI_API_KEY, reason, 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
from ...conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402
from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402

BLOG_POST_URL = "https://docs.ag2.ai/blog/2023-04-21-LLM-tuning-math"
BLOG_POST_TITLE = "Does Model and Inference Parameter Matter in LLM Applications? - A Case Study for MATH - AG2"
Expand Down
3 changes: 3 additions & 0 deletions test/agentchat/contrib/vectordb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
#
# SPDX-License-Identifier: Apache-2.0
3 changes: 1 addition & 2 deletions test/agentchat/contrib/vectordb/test_pgvectordb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
import urllib.parse

import pytest
from conftest import reason

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from ....conftest import reason

try:
import pgvector
Expand Down
3 changes: 3 additions & 0 deletions test/agentchat/extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
#
# SPDX-License-Identifier: Apache-2.0
Loading

0 comments on commit c3ad347

Please sign in to comment.