Thank you for your interest in contributing to LuckyLab! This document provides guidelines and instructions for contributing.
- Python 3.10+
- uv package manager
- Git
-
Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/luckylab.git cd luckylab -
Install dependencies with uv
uv sync --all-groups
-
Install pre-commit hooks
uv run pre-commit install
-
Verify setup by running tests
uv run pytest tests -v
We use Ruff for linting and formatting. The pre-commit hooks will automatically check and fix issues, but you can also run them manually:
# Check for issues
uv run ruff check src tests
# Fix auto-fixable issues
uv run ruff check --fix src tests
# Format code
uv run ruff format src tests# Run all tests
uv run pytest tests -v
# Run specific test file
uv run pytest tests/test_env.py -v
# Run with coverage
uv run pytest tests -v --cov=src/luckylabPre-commit hooks run automatically on git commit. To run them manually:
# Run on all files
uv run pre-commit run --all-files
# Run on staged files only
uv run pre-commit runluckylab/
├── src/luckylab/
│ ├── configs/ # Configuration dataclasses
│ ├── envs/ # Environment implementations
│ │ └── mdp/ # MDP functions (rewards, terminations, etc.)
│ ├── managers/ # Manager classes (reward, termination, etc.)
│ ├── rl/ # RL training utilities (skrl integration)
│ ├── scripts/ # CLI scripts (train, play, etc.)
│ ├── tasks/ # Task definitions
│ │ └── velocity/ # Velocity tracking task
│ └── utils/ # Utility functions and helpers
├── tests/ # Test suite
└── examples/ # Example scripts
-
Create a new directory under
src/luckylab/tasks/:src/luckylab/tasks/my_task/ ├── __init__.py ├── my_task_env_cfg.py └── mdp/ ├── __init__.py ├── rewards.py ├── terminations.py └── observations.py -
Define your environment config following the pattern in
velocity_env_cfg.py -
Register the task in
src/luckylab/tasks/__init__.py -
Add tests in
tests/
- Add your function to the appropriate
mdp/module - The function signature should match existing patterns:
def my_reward(env, **params) -> float: """Compute reward based on some criteria.""" ...
- Reference it in your task config using
RewardTermCfgorTerminationTermCfg
The RL module uses a builder pattern. To add a new algorithm:
- Add algorithm-specific config in
src/luckylab/rl/config.py - Add builder function in
src/luckylab/rl/trainer.py - Register in the
_BUILDERSdict
-
Create a feature branch
git checkout -b feature/my-feature
-
Make your changes and ensure:
- All tests pass:
uv run pytest tests -v - Code is formatted:
uv run ruff format src tests - No lint errors:
uv run ruff check src tests - Pre-commit passes:
uv run pre-commit run --all-files
- All tests pass:
-
Write meaningful commit messages
- Use present tense ("Add feature" not "Added feature")
- Keep the first line under 72 characters
- Reference issues when applicable
-
Push and create a PR
git push origin feature/my-feature
-
PR Requirements:
- Clear description of changes
- Tests for new functionality
- Documentation updates if needed
- All CI checks passing
When reporting issues, please include:
- Python version (
python --version) - LuckyLab version (
uv pip show luckylab) - Operating system
- Minimal reproducible example
- Full error traceback
- Be respectful and inclusive
- Focus on constructive feedback
- Help others learn and grow
Feel free to open an issue for questions or join our community discussions.
Thank you for contributing!