Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ipython_config.py
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# NOTE: We DO NOT ignore poetry.lock - it should be committed

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
Expand Down Expand Up @@ -160,4 +160,45 @@ dmypy.json
.pytype/

# Cython debug symbols
cython_debug/
cython_debug/

# Claude settings
.claude/*

# Testing artifacts
.pytest_cache/
.coverage
.coverage.*
htmlcov/
coverage.xml
*.cover
*.py,cover
pytest_cache/
.tox/
.nox/

# Virtual environments
.venv/
venv/
ENV/
env/
.python-version

# Build artifacts
build/
dist/
*.egg-info/
*.egg
.eggs/
wheels/
*.whl

# IDE files
.idea/
.vscode/
*.swp
*.swo
*~
.project
.pydevproject
.settings/
134 changes: 134 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
[tool.poetry]
name = "cogagent"
version = "0.1.0"
description = "CogAgent: A Visual Language Model for GUI Agents"
authors = ["CogAgent Team"]
readme = "README.md"
packages = [{include = "app"}, {include = "inference"}, {include = "finetune"}]

[tool.poetry.dependencies]
python = "^3.10"
transformers = ">=4.47.0"
torch = ">=2.5.1"
torchvision = ">=0.20.0"
huggingface-hub = ">=0.25.1"
sentencepiece = ">=0.2.0"
jinja2 = ">=3.1.4"
pydantic = ">=2.9.2"
timm = ">=1.0.9"
tiktoken = ">=0.8.0"
numpy = "1.26.4"
accelerate = ">=1.1.1"
sentence-transformers = ">=3.1.1"
gradio = ">=5.23.2"
openai = ">=1.70.0"
einops = ">=0.8.0"
pillow = ">=10.4.0"
sse-starlette = ">=2.1.3"
bitsandbytes = ">=0.43.2"
spaces = ">=0.31.1"
pyautogui = ">=0.9.54"
pyperclip = ">=1.9.0"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
pytest-cov = "^4.1.0"
pytest-mock = "^3.11.0"

[tool.poetry.group.finetune]
optional = true

[tool.poetry.group.finetune.dependencies]
nltk = ">=3.9.1"
jieba = ">=0.42.1"
"ruamel.yaml" = ">=0.18.10"
datasets = "*"
peft = ">0.15.1"
rouge-chinese = ">=1.0.3"

[tool.poetry.group.vllm]
optional = true

[tool.poetry.group.vllm.dependencies]
vllm = ">=0.6.6"

[tool.poetry.scripts]
test = "pytest"
tests = "pytest"

[tool.pytest.ini_options]
minversion = "7.0"
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = [
"-ra",
"--strict-markers",
"--strict-config",
"--cov=app",
"--cov=inference",
"--cov=finetune",
"--cov-branch",
"--cov-report=term-missing:skip-covered",
"--cov-report=html:htmlcov",
"--cov-report=xml:coverage.xml",
"--cov-fail-under=80",
"-v",
]
markers = [
"unit: Unit tests",
"integration: Integration tests",
"slow: Slow running tests",
]
console_output_style = "progress"
filterwarnings = [
"error",
"ignore::UserWarning",
"ignore::DeprecationWarning",
]

[tool.coverage.run]
source = ["app", "inference", "finetune"]
branch = true
parallel = true
omit = [
"*/tests/*",
"*/test_*",
"*/__pycache__/*",
"*/venv/*",
"*/.venv/*",
"*/dist/*",
"*/build/*",
"*.egg-info/*",
]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"def __str__",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"if typing.TYPE_CHECKING:",
"@abstractmethod",
"@abc.abstractmethod",
]
precision = 2
show_missing = true
skip_covered = false
skip_empty = true
sort = "Cover"

[tool.coverage.html]
directory = "htmlcov"
title = "CogAgent Coverage Report"

[tool.coverage.xml]
output = "coverage.xml"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
103 changes: 103 additions & 0 deletions run_validation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env python3
"""
Simple validation script to check testing infrastructure setup.
This can be run without Poetry installation to verify the structure.
"""

import os
import sys
from pathlib import Path

def check_file_exists(filepath, description):
"""Check if a file exists and print result."""
exists = Path(filepath).exists()
status = "✓" if exists else "✗"
print(f"{status} {description}: {filepath}")
return exists

def check_directory_exists(dirpath, description):
"""Check if a directory exists and print result."""
exists = Path(dirpath).exists() and Path(dirpath).is_dir()
status = "✓" if exists else "✗"
print(f"{status} {description}: {dirpath}")
return exists

def check_file_contains(filepath, search_text, description):
"""Check if a file contains specific text."""
try:
content = Path(filepath).read_text()
contains = search_text in content
status = "✓" if contains else "✗"
print(f"{status} {description}")
return contains
except:
print(f"✗ {description} (file not readable)")
return False

def main():
"""Run validation checks."""
print("Testing Infrastructure Validation")
print("=" * 50)

all_checks_passed = True

# Check project structure
print("\n1. Project Structure:")
all_checks_passed &= check_file_exists("pyproject.toml", "Poetry configuration file")
all_checks_passed &= check_directory_exists("tests", "Tests directory")
all_checks_passed &= check_directory_exists("tests/unit", "Unit tests directory")
all_checks_passed &= check_directory_exists("tests/integration", "Integration tests directory")
all_checks_passed &= check_file_exists("tests/__init__.py", "Tests package init")
all_checks_passed &= check_file_exists("tests/unit/__init__.py", "Unit tests init")
all_checks_passed &= check_file_exists("tests/integration/__init__.py", "Integration tests init")
all_checks_passed &= check_file_exists("tests/conftest.py", "Pytest configuration")
all_checks_passed &= check_file_exists("tests/test_setup_validation.py", "Validation tests")

# Check pyproject.toml contents
print("\n2. Poetry Configuration:")
all_checks_passed &= check_file_contains("pyproject.toml", "[tool.poetry]", "Poetry section")
all_checks_passed &= check_file_contains("pyproject.toml", "[tool.poetry.dependencies]", "Dependencies section")
all_checks_passed &= check_file_contains("pyproject.toml", "[tool.poetry.group.dev.dependencies]", "Dev dependencies")
all_checks_passed &= check_file_contains("pyproject.toml", "pytest", "Pytest dependency")
all_checks_passed &= check_file_contains("pyproject.toml", "pytest-cov", "Coverage dependency")
all_checks_passed &= check_file_contains("pyproject.toml", "pytest-mock", "Mock dependency")

# Check pytest configuration
print("\n3. Pytest Configuration:")
all_checks_passed &= check_file_contains("pyproject.toml", "[tool.pytest.ini_options]", "Pytest config section")
all_checks_passed &= check_file_contains("pyproject.toml", "[tool.coverage", "Coverage config section")
all_checks_passed &= check_file_contains("pyproject.toml", 'test = "pytest"', "Test script command")
all_checks_passed &= check_file_contains("pyproject.toml", 'tests = "pytest"', "Tests script command")

# Check test markers
print("\n4. Test Markers:")
all_checks_passed &= check_file_contains("pyproject.toml", '"unit: Unit tests"', "Unit test marker")
all_checks_passed &= check_file_contains("pyproject.toml", '"integration: Integration tests"', "Integration test marker")
all_checks_passed &= check_file_contains("pyproject.toml", '"slow: Slow running tests"', "Slow test marker")

# Check fixtures
print("\n5. Test Fixtures:")
all_checks_passed &= check_file_contains("tests/conftest.py", "def temp_dir", "Temp directory fixture")
all_checks_passed &= check_file_contains("tests/conftest.py", "def mock_model_config", "Model config fixture")
all_checks_passed &= check_file_contains("tests/conftest.py", "def mock_tokenizer", "Tokenizer fixture")

# Check .gitignore updates
print("\n6. Git Configuration:")
all_checks_passed &= check_file_contains(".gitignore", ".claude/*", "Claude settings ignored")
all_checks_passed &= check_file_contains(".gitignore", "# NOTE: We DO NOT ignore poetry.lock", "Poetry lock note")

# Summary
print("\n" + "=" * 50)
if all_checks_passed:
print("✓ All validation checks passed!")
print("\nNext steps:")
print("1. Run: poetry install --with dev")
print("2. Run: poetry run test")
print("3. Run: poetry run tests")
return 0
else:
print("✗ Some validation checks failed!")
return 1

if __name__ == "__main__":
sys.exit(main())
Empty file added tests/__init__.py
Empty file.
Loading