Skip to content

Latest commit

 

History

History
266 lines (197 loc) · 6.22 KB

contributing.md

File metadata and controls

266 lines (197 loc) · 6.22 KB

Contributing to DRE

Contributions Welcome Rye Pre-commit

Thank you for your interest in contributing to the Decentralized Reliability Engineering (DRE) project. This guide will help you set up your development environment and understand our contribution process.

📚 Table of Contents

  1. Development Environment Setup
  2. Project Structure
  3. Code Style Guidelines
  4. Development Workflow
  5. Pull Request Process
  6. Running Tests
  7. Common Issues
  8. Getting Help

🛠 Development Environment Setup

1. Python Environment (Rye)

Rye is our preferred Python environment manager. It provides a unified experience for managing Python installations, dependencies, and virtual environments.

Installation

curl -sSf https://rye.astral.sh/get | bash
source "$HOME/.rye/env"  # Add to your shell's RC file

Project Setup

rye sync  # Install all dependencies

Common Rye Commands

rye run <command>  # Run a command with project dependencies
rye show           # Show current environment info
rye toolchain list --include-downloadable  # List available Python versions

2. IDE Configuration

Configure your IDE to use the Python interpreter from .venv/bin/python. This ensures consistent development settings across the team.

Troubleshooting Rye

If you encounter issues:

  1. Update Rye: rye self update
  2. Verify Python path: which python3
  3. Check environment: rye show
  4. List toolchains: rye toolchain list --include-downloadable

3. Pre-commit Hooks

We use pre-commit hooks to ensure code quality and consistency.

rye run pre-commit install

For more information, visit the pre-commit documentation.

4. Rust Development Setup (Optional)

If you plan to work on Rust components:

Install Rust Toolchain

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

System Dependencies

For Linux:

sudo apt install -y clang mold protobuf-compiler

For macOS:

brew install mold protobuf

Add Cargo to your PATH:

export PATH="$HOME/.cargo/bin:$PATH"  # Add to your shell's RC file

Verify Rust Setup

cd rs
cargo check

5. Node.js and Yarn

Required for frontend development:

  1. Install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
  1. Install Node.js:
nvm install 14
nvm use 14
  1. Install Yarn:
npm install --global yarn

📂 Project Structure

The DRE repository is organized into several key components:

  • /dashboard - Internal DRE dashboard (frontend and backend)
  • /rs - Rust implementations
  • /pylib - Python libraries
  • /docs - Project documentation
  • /k8s - Kubernetes configurations
  • /scripts - Utility scripts

📝 Code Style Guidelines

Python

  • Follow PEP 8 style guide
  • Use type hints for function arguments and return values
  • Document functions and classes using docstrings
  • Maximum line length: 100 characters

Rust

  • Follow the official Rust Style Guide
  • Use rustfmt for code formatting
  • Run clippy for linting

JavaScript/TypeScript

🔄 Development Workflow

  1. Fork the repository and create your branch from main:

    git checkout -b feature/your-feature-name
  2. Set up development environment:

    rye sync
    rye run pre-commit install
  3. Make your changes:

    • Write tests for new functionality
    • Update documentation as needed
    • Follow code style guidelines
  4. Commit your changes:

    git commit -m "feat: add new feature"

    Follow the conventional commits specification

  5. Push to your fork and create a pull request

🔍 Pull Request Process

  1. Ensure all tests pass locally
  2. Update documentation if needed
  3. Add a clear description of the changes
  4. Link any related issues
  5. Request review from maintainers
  6. Address review feedback
  7. Ensure CI checks pass

PR Title Format

  • feat: Add new feature
  • fix: Fix bug
  • docs: Update documentation
  • test: Add tests
  • refactor: Code refactoring
  • chore: Maintenance tasks

⚡ Running Tests

Backend Tests

rye run pytest

Frontend Tests

cd dashboard
yarn test

🖥 IC Network Internal Dashboard

Setup

cd dashboard
yarn install

Development

yarn dev  # Starts development server

Using DRE CLI with Local Dashboard

dre --dev subnet replace --id <subnet-id> -o1

❗ Common Issues

Linux: "No disk space left" with Bazel

If you encounter inotify issues:

sudo sysctl -w fs.inotify.max_user_watches=1048576

Other Common Issues

  1. Permission Denied Errors

    sudo chown -R $(whoami) .
  2. Node Version Mismatch

    nvm use 14  # Ensure correct Node version
  3. Bazel Cache Issues

    bazel clean --expunge

🤝 Getting Help

Before Asking for Help

  1. Search existing issues
  2. Check the documentation
  3. Try troubleshooting steps
  4. Provide relevant details when asking

Remember: Good code is not just about functionality—it's about maintainability, readability, and collaboration. Thank you for contributing to DRE! 🚀