- Code of Conduct
- Setting Up Your Development Environment
- Running Linters and Formatters
- Running Tests
- Coding Style
- Commit Message Guidelines
- Submitting Changes (Pull Requests)
- Reporting Bugs
- Suggesting Enhancements
This project adheres to a Code of Conduct (You might want to add a separate CODE_OF_CONDUCT.md file later if the project grows, perhaps based on the Contributor Covenant). Please be respectful and constructive in all interactions.
-
Clone the repository:
git clone <your-repository-url> cd <repository-directory>
-
(Optional) Set Python Version with
pyenv: If you usepyenvto manage Python versions, ensure you have the required version installed (e.g., specified inpyproject.tomlorREADME.md) and set it for this project directory:# Example: If the project requires Python 3.9.x pyenv install 3.9.18 # If not already installed pyenv local 3.9.18 # Set the version for this directory
-
Create a virtual environment: It's highly recommended to use a virtual environment (like
venv) to manage dependencies. Using the Python version set in the previous step (or your system's default if not usingpyenv):python -m venv .venv # Activate the environment # On Windows (Git Bash or cmd.exe) # .venv\Scripts\activate # On macOS/Linux (bash/zsh) source .venv/bin/activate
Note: Some tools like
pyenv-virtualenvcan combine steps 2 and 3. -
Install dependencies: Install the required Python packages into the active virtual environment.
pip install -r requirements.txt
-
Install development tools: Install tools used for formatting, linting, testing, and pre-commit hooks.
pip install ruff mypy pre-commit pytest pytest-cov # Add other dev tools if needed (e.g., black if not using ruff format) -
Install pre-commit hooks: This step configures Git to run checks automatically before each commit, based on the
.pre-commit-config.yamlfile.pre-commit install
We use ruff for linting and formatting, and mypy for type checking. These are configured in pyproject.toml.
Automatic Checks (Recommended):
If you followed step 6 in the setup (pre-commit install), the necessary checks (formatting, linting, type checking) will run automatically on staged files whenever you run git commit. If any check fails, the commit will be aborted. Some tools (like ruff format and ruff --fix) may automatically modify files to fix issues; simply git add the modified files and try committing again.
Manual Checks:
You can also run the checks manually:
-
Run all pre-commit hooks on staged files:
pre-commit run
-
Run all pre-commit hooks on all files:
pre-commit run --all-files
-
Check for linting errors with Ruff:
ruff check . -
Format code with Ruff:
ruff format . -
Run type checking with Mypy:
mypy src tests # Adjust paths as needed, ensure it uses pyproject.toml config
We use pytest for running tests. Ensure all tests pass before submitting changes.
-
Run all tests:
pytest
-
Run tests with coverage report: (This uses the configuration in
pyproject.toml)pytest --cov
- Follow PEP 8 guidelines.
- Use
ruff format(via pre-commit or manually) for automatic code formatting. - Use
ruff check(via pre-commit or manually) for linting. Adhere to the rules defined inpyproject.toml. - Write clear and concise comments where necessary, explaining the why behind complex logic.
- Use type hints for function signatures and variables where appropriate, and ensure
mypypasses.
Please follow conventional commit guidelines for clear and automated changelog generation (optional but good practice):
- Format:
<type>[optional scope]: <description> - Examples:
feat: Add KMeans clustering for stage labelingfix: Correct calculation for time-to-next-stagedocs: Update README with setup instructionsstyle: Format code using ruff formatrefactor: Improve data loading efficiencytest: Add unit tests for risk score calculationchore: Configure pre-commit hooks
Common types: feat, fix, build, chore, ci, docs, style, refactor, perf, test.
(This section is more relevant if collaborating, but good to define the process)
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b <type>/<short-description>(e.g.,feat/add-xgboost-model,fix/stage-label-off-by-one). - Make your changes. Ensure pre-commit checks pass when you commit. Ensure all tests pass (
pytest). - Commit your changes using clear commit messages.
- Push your branch to your fork:
git push origin <branch-name>. - Open a Pull Request (PR) against the
main(ordevelop) branch of the original repository. - Provide a clear description of the changes in the PR. Link to any relevant issues.
- Respond to any feedback or requested changes during the review process.
If you find a bug, please open an issue on the project's issue tracker (e.g., GitHub Issues). Include:
- A clear and descriptive title.
- Steps to reproduce the bug.
- What you expected to happen.
- What actually happened (including error messages or tracebacks).
- Your environment details (OS, Python version, library versions).
If you have an idea for an improvement or a new feature:
- Check the issue tracker to see if a similar suggestion already exists.
- If not, open a new issue.
- Provide a clear description of the enhancement and why it would be beneficial.
- Explain the proposed solution or workflow if possible.
Thank you for contributing!