Skip to content

feat: Add comprehensive Python testing infrastructure with Poetry #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,41 @@ data/molecules/zinc-full/*.pkl

dataset/

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

# Claude
.claude/*

# Build artifacts
dist/
build/
*.egg-info/
*.egg

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

# IDE files
.idea/
.vscode/
*.swp
*.swo
*~

# Poetry
poetry.lock

23 changes: 23 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Claude Working Memory

## Project Overview
Python machine learning project focused on graph neural networks and molecular modeling.

## Important Commands
- Testing: `poetry run test` or `poetry run tests`
- Linting: `poetry run flake8`
- Type checking: `poetry run mypy`
- Code formatting: `poetry run black .`

## Recent Changes
- Set up comprehensive testing infrastructure with Poetry
- Added pytest, pytest-cov, and pytest-mock for testing
- Created test directory structure with unit and integration subdirectories
- Configured pytest and coverage settings in pyproject.toml
- Added comprehensive shared fixtures in conftest.py
- Updated .gitignore with testing and Claude-specific entries

## Notes
- This project originally uses Conda for dependency management (see environment_cpu.yml and environment_gpu.yml)
- DGL (Deep Graph Library) needs to be installed separately via conda as it's not available on PyPI
- Poetry has been set up alongside Conda for managing testing dependencies
149 changes: 149 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
[tool.poetry]
name = "graph-transformer"
version = "0.1.0"
description = "Graph Transformer for molecular modeling and node classification"
authors = ["Your Name <you@example.com>"]
readme = "README.md"
packages = [{include = "layers"}, {include = "nets"}, {include = "train"}]

[tool.poetry.dependencies]
python = "^3.7"
torch = ">=1.6.0"
torchvision = ">=0.7.0"
numpy = ">=1.19.0"
matplotlib = ">=3.1.0"
tensorboard = ">=2.1.0"
tensorboardx = ">=1.8"
future = ">=0.18.2"
absl-py = "*"
networkx = ">=2.3"
scikit-learn = ">=0.21.2"
scipy = ">=1.3.0"
h5py = ">=2.9.0"
scikit-image = ">=0.15.0"
requests = ">=2.22.0"
tqdm = ">=4.43.0"
pillow = ">=6.1"
python-dateutil = ">=2.8.0"
# Note: DGL needs to be installed separately via conda

[tool.poetry.group.dev.dependencies]
pytest = ">=7.0.0"
pytest-cov = ">=4.0.0"
pytest-mock = ">=3.10.0"
black = ">=22.0.0"
flake8 = ">=5.0.0"
mypy = ">=0.990"
isort = ">=5.10.0"
pre-commit = ">=2.20.0"

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

[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",
"--cov=layers",
"--cov=nets",
"--cov=train",
"--cov-branch",
"--cov-report=term-missing:skip-covered",
"--cov-report=html",
"--cov-report=xml",
"--cov-fail-under=80",
"-vv",
"--tb=short",
"--maxfail=1",
]
markers = [
"unit: Unit tests",
"integration: Integration tests",
"slow: Slow tests",
]
filterwarnings = [
"ignore::DeprecationWarning",
"ignore::PendingDeprecationWarning",
]

[tool.coverage.run]
branch = true
source = ["layers", "nets", "train"]
omit = [
"*/tests/*",
"*/__init__.py",
"*/conftest.py",
"*/setup.py",
]

[tool.coverage.report]
precision = 2
show_missing = true
skip_covered = true
skip_empty = true
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if __name__ == .__main__.:",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if False:",
"pass",
]

[tool.coverage.html]
directory = "htmlcov"

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

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
profile = "black"
line_length = 100
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true

[tool.black]
line-length = 100
target-version = ['py37']
include = '\.pyi?$'
extend-exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/'''

[tool.mypy]
python_version = "3.7"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = false
ignore_missing_imports = true
exclude = [
"tests/",
"build/",
"dist/",
]
Empty file added tests/__init__.py
Empty file.
Loading