MetaGPT
MetaGPT copied to clipboard
Instructions to run unit test locally
Feature description
Instructions and simple setup to run all unit tests locally
Your Feature
You can refer to unittest.yaml and run_install_deps.sh.
Can you comment on how to set these variables for a local setup, please? https://github.com/geekan/MetaGPT/blob/main/.github/workflows/unittest.yaml#L35-L39
Note: having instructions in the ReadMe or a Contributing page would be useful
OK, I will add it to the docs soon.
- Install unittest dependencies
bash run_install_deps.sh
- Prepare config file
key.yaml
OPENAI_API_KEY: "sk-xxx"
OPENAI_BASE_URL: "https://api.openai.com/v1"
OPENAI_API_MODEL: "gpt-3.5-turbo-16k"
MAX_TOKENS: 4096
RPM: 10
OPENAI_API_VERSION: "2023-09-01-preview"
DEPLOYMENT_NAME: "gpt-4-32k"
### browser path for pyppeteer engine, support Chrome, Chromium,MS Edge
# linux
PYPPETEER_EXECUTABLE_PATH: "/usr/bin/chromium"
# macos
# PYPPETEER_EXECUTABLE_PATH: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
SEARCH_ENGINE: ddg
SERPAPI_API_KEY: "xxx"
GOOGLE_API_KEY: "xxx"
GOOGLE_CSE_ID: "xxx"
SERPER_API_KEY: "xxx"
AZURE_TTS_SUBSCRIPTION_KEY: "xxx"
AZURE_TTS_REGION: "eastus"
IFLYTEK_APP_ID: "xxx"
IFLYTEK_API_KEY: "xxx"
IFLYTEK_API_SECRET: "xxx"
S3_ACCESS_KEY: "MOCK_S3_ACCESS_KEY"
S3_SECRET_KEY: "MOCK_S3_SECRET_KEY"
S3_ENDPOINT_URL: "http://mock:9000"
S3_SECURE: false # true/false
S3_BUCKET: "mock"
METAGPT_TEXT_TO_IMAGE_MODEL_URL: "http://mock.com"
- Run the unittest
pytest tests/ --doctest-modules --cov=./metagpt/ --cov-report=xml:cov.xml --cov-report=html:htmlcov --durations=20
coverage report -m
@voidking Thanks! I have tried following the above instructions, but it hangs indefinitely with an opened window showing a graph.
OK, I will add it to the docs soon.
- Install unittest dependencies
bash run_install_deps.sh
- Prepare config file
key.yaml
OPENAI_API_KEY: "sk-xxx" OPENAI_BASE_URL: "https://api.openai.com/v1" OPENAI_API_MODEL: "gpt-3.5-turbo-16k" MAX_TOKENS: 4096 RPM: 10 OPENAI_API_VERSION: "2023-09-01-preview" DEPLOYMENT_NAME: "gpt-4-32k" ### browser path for pyppeteer engine, support Chrome, Chromium,MS Edge # linux PYPPETEER_EXECUTABLE_PATH: "/usr/bin/chromium" # macos # PYPPETEER_EXECUTABLE_PATH: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" SEARCH_ENGINE: ddg SERPAPI_API_KEY: "xxx" GOOGLE_API_KEY: "xxx" GOOGLE_CSE_ID: "xxx" SERPER_API_KEY: "xxx" AZURE_TTS_SUBSCRIPTION_KEY: "xxx" AZURE_TTS_REGION: "eastus" IFLYTEK_APP_ID: "xxx" IFLYTEK_API_KEY: "xxx" IFLYTEK_API_SECRET: "xxx" S3_ACCESS_KEY: "MOCK_S3_ACCESS_KEY" S3_SECRET_KEY: "MOCK_S3_SECRET_KEY" S3_ENDPOINT_URL: "http://mock:9000" S3_SECURE: false # true/false S3_BUCKET: "mock" METAGPT_TEXT_TO_IMAGE_MODEL_URL: "http://mock.com"
- Run the unittest
pytest tests/ --doctest-modules --cov=./metagpt/ --cov-report=xml:cov.xml --cov-report=html:htmlcov --durations=20 coverage report -m
Hello,did anyone successfully run the test? Where should I put this key.yaml? My running tests keep showing
` rsp_cache = {'\n\nExtract relevant information from every preceding sentence and use it to succinctly supplement or rewrite the fo...nship between sepal length and sepal width, color-coded by species.",\n "task_type": "eda"\n }\n]\n```', ...} mocker = <pytest_mock.plugin.MockerFixture object at 0x7fc8049b4410>, request = <SubRequest 'llm_mock' for <Function test_product_manager>>
@pytest.fixture(scope="function", autouse=True)
def llm_mock(rsp_cache, mocker, request):
llm = MockLLM(allow_open_api_call=ALLOW_OPENAI_API_CALL)
tests/conftest.py:67:
tests/mock/mock_llm.py:20: in init super().init(original_llm_config) metagpt/provider/openai_api.py:60: in init self._init_client() metagpt/provider/azure_openai_api.py:24: in _init_client kwargs = self._make_client_kwargs()
self = <tests.mock.mock_llm.MockLLM object at 0x7fc8049b7990>
def _make_client_kwargs(self) -> dict:
kwargs = dict(
api_key=self.config.api_key,
api_version=self.config.api_version,
azure_endpoint=self.config.base_url,
)
E AttributeError: 'NoneType' object has no attribute 'api_key'
metagpt/provider/azure_openai_api.py:32: AttributeError`