Skip to content

Commit

Permalink
处理冲突
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiDBK committed Aug 6, 2024
2 parents a771112 + ec2c1dc commit 015212d
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
source =
./metagpt/
omit =
*/metagpt/environment/android/*
*/metagpt/ext/android_assistant/*
*/metagpt/ext/werewolf/*
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*.ico binary
*.jpeg binary
*.mp3 binary
*.mp4 binary
*.zip binary
*.bin binary

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/fulltest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ jobs:
cache: 'pip'
- name: Install dependencies
run: |
sh tests/scripts/run_install_deps.sh
python -m pip install --upgrade pip
pip install -e .[test]
npm install -g @mermaid-js/mermaid-cli
playwright install --with-deps
- name: Run reverse proxy script for ssh service
if: contains(github.ref, '-debugger')
continue-on-error: true
Expand Down
45 changes: 41 additions & 4 deletions .github/workflows/unittest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,57 @@ jobs:
cache: 'pip'
- name: Install dependencies
run: |
sh tests/scripts/run_install_deps.sh
python -m pip install --upgrade pip
pip install -e .[test]
npm install -g @mermaid-js/mermaid-cli
playwright install --with-deps
- name: Test with pytest
run: |
export ALLOW_OPENAI_API_CALL=0
mkdir -p ~/.metagpt && cp tests/config2.yaml ~/.metagpt/config2.yaml
pytest tests/ --ignore=tests/metagpt/environment/android_env --ignore=tests/metagpt/ext/android_assistant --doctest-modules --cov=./metagpt/ --cov-report=xml:cov.xml --cov-report=html:htmlcov --durations=20 | tee unittest.txt
pytest --continue-on-collection-errors tests/ \
--ignore=tests/metagpt/environment/android_env \
--ignore=tests/metagpt/ext/android_assistant \
--ignore=tests/metagpt/ext/stanford_town \
--ignore=tests/metagpt/provider/test_bedrock_api.py \
--ignore=tests/metagpt/rag/factories/test_embedding.py \
--ignore=tests/metagpt/ext/werewolf/actions/test_experience_operation.py \
--ignore=tests/metagpt/provider/test_openai.py \
--ignore=tests/metagpt/planner/test_action_planner.py \
--ignore=tests/metagpt/planner/test_basic_planner.py \
--ignore=tests/metagpt/actions/test_project_management.py \
--ignore=tests/metagpt/actions/test_write_code.py \
--ignore=tests/metagpt/actions/test_write_code_review.py \
--ignore=tests/metagpt/actions/test_write_prd.py \
--ignore=tests/metagpt/environment/werewolf_env/test_werewolf_ext_env.py \
--ignore=tests/metagpt/memory/test_brain_memory.py \
--ignore=tests/metagpt/roles/test_assistant.py \
--ignore=tests/metagpt/roles/test_engineer.py \
--ignore=tests/metagpt/serialize_deserialize/test_write_code_review.py \
--ignore=tests/metagpt/test_environment.py \
--ignore=tests/metagpt/test_llm.py \
--ignore=tests/metagpt/tools/test_metagpt_oas3_api_svc.py \
--ignore=tests/metagpt/tools/test_moderation.py \
--ignore=tests/metagpt/tools/test_search_engine.py \
--ignore=tests/metagpt/tools/test_tool_convert.py \
--ignore=tests/metagpt/tools/test_web_browser_engine_playwright.py \
--ignore=tests/metagpt/utils/test_mermaid.py \
--ignore=tests/metagpt/utils/test_redis.py \
--ignore=tests/metagpt/utils/test_tree.py \
--ignore=tests/metagpt/serialize_deserialize/test_sk_agent.py \
--ignore=tests/metagpt/utils/test_text.py \
--ignore=tests/metagpt/actions/di/test_write_analysis_code.py \
--ignore=tests/metagpt/provider/test_ark.py \
--doctest-modules --cov=./metagpt/ --cov-report=xml:cov.xml --cov-report=html:htmlcov \
--durations=20 | tee unittest.txt
- name: Show coverage report
run: |
coverage report -m
- name: Show failed tests and overall summary
run: |
grep -E "FAILED tests|ERROR tests|[0-9]+ passed," unittest.txt
failed_count=$(grep -E "FAILED|ERROR" unittest.txt | wc -l)
if [[ "$failed_count" -gt 0 ]]; then
failed_count=$(grep -E "FAILED tests|ERROR tests" unittest.txt | wc -l | tr -d '[:space:]')
if [[ $failed_count -gt 0 ]]; then
echo "$failed_count failed lines found! Task failed."
exit 1
fi
Expand Down
2 changes: 2 additions & 0 deletions config/config2.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,5 @@ models:
# # timeout: 600 # Optional. If set to 0, default value is 300.
# # Details: https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/
# pricing_plan: "" # Optional. Use for Azure LLM when its model name is not the same as OpenAI's

agentops_api_key: "YOUR_AGENTOPS_API_KEY" # get key from https://app.agentops.ai/settings/projects
7 changes: 4 additions & 3 deletions metagpt/actions/design_api_an.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@Author : alexanderwu
@File : design_api_an.py
"""
from typing import List
from typing import List,Optional

from metagpt.actions.action_node import ActionNode
from metagpt.utils.mermaid import MMC1, MMC2
Expand Down Expand Up @@ -45,9 +45,10 @@
example=["main.py", "game.py", "new_feature.py"],
)

#optional,because low success reproduction of class diagram in non py project.
DATA_STRUCTURES_AND_INTERFACES = ActionNode(
key="Data structures and interfaces",
expected_type=str,
expected_type=Optional[str],
instruction="Use mermaid classDiagram code syntax, including classes, method(__init__ etc.) and functions with type"
" annotations, CLEARLY MARK the RELATIONSHIPS between classes, and comply with PEP8 standards. "
"The data structures SHOULD BE VERY DETAILED and the API should be comprehensive with a complete design.",
Expand All @@ -66,7 +67,7 @@

PROGRAM_CALL_FLOW = ActionNode(
key="Program call flow",
expected_type=str,
expected_type=Optional[str],
instruction="Use sequenceDiagram code syntax, COMPLETE and VERY DETAILED, using CLASSES AND API DEFINED ABOVE "
"accurately, covering the CRUD AND INIT of each object, SYNTAX MUST BE CORRECT.",
example=MMC2,
Expand Down
4 changes: 2 additions & 2 deletions metagpt/actions/project_management_an.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
@Author : alexanderwu
@File : project_management_an.py
"""
from typing import List
from typing import List, Optional

from metagpt.actions.action_node import ActionNode

REQUIRED_PACKAGES = ActionNode(
key="Required packages",
expected_type=List[str],
expected_type=Optional[List[str]],
instruction="Provide required packages in requirements.txt format.",
example=["flask==1.1.2", "bcrypt==3.2.0"],
)
Expand Down
1 change: 1 addition & 0 deletions metagpt/config2.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Config(CLIParams, YamlModel):
workspace: WorkspaceConfig = WorkspaceConfig()
enable_longterm_memory: bool = False
code_review_k_times: int = 2
agentops_api_key: str = ""

# Will be removed in the future
metagpt_tti_url: str = ""
Expand Down
1 change: 1 addition & 0 deletions metagpt/roles/architect.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@File : architect.py
"""


from metagpt.actions import WritePRD
from metagpt.actions.design_api import WriteDesign
from metagpt.roles.role import Role
Expand Down
1 change: 1 addition & 0 deletions metagpt/roles/product_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@Modified By: mashenquan, 2023/11/27. Add `PrepareDocuments` action according to Section 2.2.3.5.1 of RFC 135.
"""


from metagpt.actions import UserRequirement, WritePRD
from metagpt.actions.prepare_documents import PrepareDocuments
from metagpt.roles.role import Role, RoleReactMode
Expand Down
1 change: 1 addition & 0 deletions metagpt/roles/project_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@File : project_manager.py
"""


from metagpt.actions import WriteTasks
from metagpt.actions.design_api import WriteDesign
from metagpt.roles.role import Role
Expand Down
1 change: 1 addition & 0 deletions metagpt/roles/qa_engineer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
of SummarizeCode.
"""


from metagpt.actions import DebugError, RunCode, WriteTest
from metagpt.actions.summarize_code import SummarizeCode
from metagpt.const import MESSAGE_ROUTE_TO_NONE
Expand Down
7 changes: 7 additions & 0 deletions metagpt/software_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import asyncio
from pathlib import Path

import agentops
import typer

from metagpt.const import CONFIG_ROOT
Expand Down Expand Up @@ -38,6 +39,9 @@ def generate_repo(
)
from metagpt.team import Team

if config.agentops_api_key != "":
agentops.init(config.agentops_api_key, tags=["software_company"])

config.update_via_cli(project_path, project_name, inc, reqa_file, max_auto_summarize_code)
ctx = Context(config=config)

Expand Down Expand Up @@ -68,6 +72,9 @@ def generate_repo(
company.run_project(idea)
asyncio.run(company.run(n_round=n_round))

if config.agentops_api_key != "":
agentops.end_session("Success")

return ctx.repo


Expand Down
3 changes: 3 additions & 0 deletions metagpt/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ async def run(self, n_round=3, idea="", send_to="", auto_archive=True):
self.run_project(idea=idea, send_to=send_to)

while n_round > 0:
if self.env.is_idle:
logger.debug("All roles are idle.")
break
n_round -= 1
self._check_balance()
await self.env.run()
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ rank-bm25==0.2.2 # for tool recommendation
gymnasium==0.29.1
boto3~=1.34.69
spark_ai_python~=0.3.30
agentops
2 changes: 1 addition & 1 deletion tests/metagpt/provider/test_bedrock_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def is_subset(subset, superset) -> bool:
superset = {"prompt": "hello", "kwargs": {"temperature": 0.0, "top-p": 0.0}}
is_subset(subset, superset)
```
>>>False
"""
for key, value in subset.items():
if key not in superset:
Expand Down
1 change: 0 additions & 1 deletion tests/mock/mock_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ async def _mock_rsp(self, msg_key, ask_func, *args, **kwargs):
raise ValueError(
"In current test setting, api call is not allowed, you should properly mock your tests, "
"or add expected api response in tests/data/rsp_cache.json. "
f"The prompt you want for api call: {msg_key}"
)
# Call the original unmocked method
rsp = await ask_func(*args, **kwargs)
Expand Down

0 comments on commit 015212d

Please sign in to comment.