Welcome to the chemeleon2 project! This guide will help you set up your development environment and understand our workflow.
Table of Contents¶
1. Prerequisites¶
Before starting, ensure you have:
Python 3.11+ installed
Git installed
uv package manager (recommended)
Installing uv¶
If you don’t have uv installed:
curl -LsSf https://astral.sh/uv/install.sh | sh2. Setup Instructions¶
Step 1: Clone the Repository¶
git clone https://github.com/hspark1212/chemeleon2.git
cd chemeleon2Step 2: Install Dependencies¶
# Install all dependencies with dev dependencies (pytest, ruff, pyright, etc.)
uv sync --extra dev
# Optional install torch with your cuda version (e.g., for CUDA 12.8)
uv pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu128Step 3: Install Pre-commit Hooks¶
Install pre-commit hooks to ensure code quality on every commit:
# activate the virtual environment
source .venv/bin/activate
# Install pre-commit hooks
pre-commit installStep 4: Verify Installation¶
Test that everything works:
# Run pre-commit hooks on all files to ensure code quality
pre-commit run --all-files
# Run pytest to ensure tests pass
pytest -v3. Git Workflow¶
Key Concepts¶
Repository (repo): Folder with your project code and its entire history
Branch: Independent workspace for changes.
maincontains stable codeCommit: Saved snapshot of your code changes
Push: Upload local changes to GitHub
Pull Request (PR): Request to merge your changes into
main
Workflow Steps¶
Create a new branch for your work
Make your changes and commit them
Push your branch to GitHub
Create a Pull Request
Wait for review - maintainers will review and merge
Common Git Commands¶
# Check what branch you're on
git branch
# Create and switch to a new branch
git checkout -b feature/my-feature
# Check what files changed
git status
# Stage all changes
git add .
# Commit (pre-commit hooks run automatically)
git commit -m "feat: add new feature"
# Push to GitHub (first time)
git push -u origin feature/my-feature
# Push to GitHub (subsequent times)
git pushBranch Naming Convention¶
Features:
feature/descriptionBug fixes:
fix/descriptionDocumentation:
docs/descriptionExamples:
feature/add-model,fix/training-bug,docs/update-readme
4. Development Workflow¶
Making Changes¶
Activate the virtual environment (if not already activated):
source .venv/bin/activateCreate a branch (see Git Workflow above)
Make your changes in your code editor
Test your changes locally:
# Run relevant tests pytest tests/ # Or run specific test files pytest tests/unit/test_your_feature.pyCommit your changes:
git add . git commit -m "feat: descriptive commit message"Pre-commit hooks will automatically run. If they fail:
Fix the issues shown
Stage changes again:
git add .Commit again:
git commit -m "your message"
Push to GitHub:
git push -u origin your-branch-nameCreate a Pull Request:
Go to GitHub
Click “Compare & pull request”
Describe your changes
Submit for review
Commit Message Format¶
Use conventional commit format:
feat: add new feature- New functionalityfix: resolve bug in training- Bug fixesdocs: update README- Documentationtest: add unit tests- Testsrefactor: reorganize code- Code restructuringchore: update dependencies- Maintenance
5. Testing¶
Running Tests¶
# Run all tests
pytest tests/
# Run specific test categories
pytest tests/ -m baseline # Baseline validation
pytest tests/ -m unit # Unit tests
pytest tests/ -m integration # Integration tests
# Run specific test file
pytest tests/unit/test_featurizer.py -vRunning Linters¶
# Check code style
ruff check .
# Auto-fix issues
ruff check . --fix
# Format code
ruff format .Pre-commit Hooks¶
Hooks run automatically on git commit. To run manually:
# Run on all files
.venv/bin/pre-commit run --all-files
# Run on staged files only
.venv/bin/pre-commit run6. Troubleshooting¶
Pre-commit Hooks Not Running¶
# Reinstall hooks
.venv/bin/pre-commit uninstall
.venv/bin/pre-commit installImport Errors¶
If you encounter import errors, reinstall the package in editable mode:
# Using uv sync (recommended)
uv sync --extra dev
# Or using uv pip
source .venv/bin/activate
uv pip install -e ".[dev]"Dependency Issues¶
If you have dependency conflicts or installation issues:
Option 1: Using uv sync (recommended)
# Clear and reinstall with uv sync
rm -rf .venv
uv sync --extra dev
.venv/bin/pre-commit installOption 2: Using uv pip
# Clear and reinstall with uv pip
rm -rf .venv
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
.venv/bin/pre-commit installPython Version Issues¶
Ensure you’re using Python 3.11+:
python --version
# or
.venv/bin/python --versionThank you for contributing to chemeleon2!