Development Set-up

To create a development environment follow the steps outlined below.

Setting Up Your Fork

When working with a fork, follow these steps to set up your local development environment:

  1. Fork the repository: Create your own copy of the repository on GitHub, following this GitHub tutorial.

  2. Clone your fork: Download your forked repository to your local machine as outlined in this section of the tutorial.

  3. Add the upstream remote: Connect your local repository to the original repository to fetch updates as described in this section.

  4. Prevent accidental pushes to upstream: After setting up your fork and configuring the original repository as an upstream remote, it’s a good practice to prevent accidental pushes to the upstream repository. You can do this by explicitly setting the push URL of the upstream remote to no_push. To do this, navigate to your local repository and run:

    git remote set-url --push upstream no_push
    

    Verify the change with:

    git remote -v
    

    You should see something like this:

    origin    https://github.com/your-username/repository.git (fetch)
    origin    https://github.com/your-username/repository.git (push)
    upstream  https://github.com/original-owner/repository.git (fetch)
    upstream  no_push (push)
    

    With this configuration, you can still fetch updates from the upstream repository but won’t be able to accidentally push changes to it.

Creating Your Virtual Environment

  1. Create and activate a virtual environment with a python version >=3.9, and <3.13.

  2. Navigate to the repository you cloned and for which you want to install the dependencies.

    For packages in anemoi-core, i.e. anemoi-training, anemoi-models, or anemoi-graphs, navigate to the relevant package directory

    cd anemoi-core/{package}
    

    where {package} is the package name, e.g. training.

    For all other packages:

    cd anemoi-{package}
    

    where {package} is the package name, e.g. datasets.

  3. Install dependencies:

    # For all dependencies
    pip install -e .
    
    # For development dependencies
    pip install -e '.[dev]'
    
  4. (macOS only) Install pandoc for documentation building:

    brew install pandoc
    

Pre-Commit Hooks

We use pre-commit hooks to ensure code quality and consistency. To set them up:

  1. Install pre-commit hooks:

    pre-commit install
    
  2. Run hooks on all files to verify installation:

    pre-commit run --all-files
    

These pre-commit hooks will run for each commit.