Skip to content

Latest commit

 

History

History
252 lines (176 loc) · 5.84 KB

File metadata and controls

252 lines (176 loc) · 5.84 KB

Crash Course in Contributing to Scikit-learn: Workflow

PR = Pull Request
Important Note: Please include (#DataUmbrella) in your PR commit message so we can track them.


PART A: Set-up work environment

Set up virtual environment

conda create -n sklearndev numpy scipy matplotlib pytest sphinx cython ipykernel

Helpful virtual environment commands to know

  • To view a list of your virtual environments: conda env list
  • To activate a virtual environment: conda activate sklearndev
  • To deactivate a virtual environment: conda deactivate
  • To remove a virtual environment: conda env remove --name myenv

Activate virtual environment:

source activate sklearndev

Additional installs

conda install -c conda-forge sphinx-gallery

PART B: Set-up repository

Set up local repo

git clone your forked repo url. (Use HTTPS url over SSH if you do not have ssh keys set up.)

git clone https://github.com/reshamas/scikit-learn.git

cd scikit-learn into your folder

cd scikit-learn

Build from source

pip install -e .

Note: this will overwrite existing installations Reference: "Editable" Installs

Add upstream remote

git remote add upstream https://github.com/scikit-learn/scikit-learn.git

Check remotes are there using git remote -v

my example

origin	https://github.com/reshamas/scikit-learn.git (fetch)
origin	https://github.com/reshamas/scikit-learn.git (push)
upstream	https://github.com/scikit-learn/scikit-learn.git (fetch)
upstream	https://github.com/scikit-learn/scikit-learn.git (push)

Update local repo

git pull upstream main

To fetch (someone else's) PR:

git fetch https://github.com/theirusername/reponame.git theirbranch:ourbranch

PART C: Select issue


PART D: Fixing issue

  • Explore and fix issue. This will take the majority of time (!)
  • Make updates to file <file_name>

PART E: Committing change

Create feature branch

git checkout -b <feature_branch>

Commit changes to branch

Please include (#DataUmbrella) in your PR so we can track them.

git add <file_name>
git commit -m 'description for fix'

PART F: Run tests

flake8 formatting test

  • flake8 tests for formatting errors
flake8 <file_name>

pytest sklearn tests

pytest sklearn

This is an example of the output of a successful pytest sklearn: pytest_sklearn_output

Create test file

Run tests on individual test files

  • Create test file under tests directory
  • Run test file
pytest <test_file>

example

pytest /Users/reshamashaikh/scikit-learn/sklearn/metrics/tests/test_classifier.py
pytest /Users/reshamashaikh/scikit-learn/sklearn/metrics/tests/test_mixture.py

This is an example of the output of a successful pytest test_classification.py:

(sklearndev) % pytest sklearn/metrics/tests/test_classification.py
============================================================ test session starts ============================================================
platform darwin -- Python 3.7.1, pytest-4.0.0, py-1.7.0, pluggy-0.8.0
rootdir: /Users/reshamashaikh/scikit-learn, inifile: setup.cfg
collected 75 items                                                                                                                          

sklearn/metrics/tests/test_classification.py ...........................................................................              [100%]

=================================================== 75 passed, 3 warnings in 9.49 seconds ===================================================
(sklearndev) %

PART G: Submit Pull Request

After all tests have passed, push update file(s) to feature branch

  • test_file should be committed to feature branch as well
git add <test_file>
git commit -m 'description for test file'
git push origin <feature_branch>

Submit PR

Do this on GitHub.

REMINDER: Under Conversation [description] include references to which Issues and other PRs that your PR is related to.


Part H: Regression Tests on GitHub

These tests happen automatically after a PR has been submitted:

This is what it looks like when all the checks have passed!


Part I: Next Steps

  • Wait for reviews (be patient)
  • Address review comments in the same branch
  • Pushing to your fork will update the PR
  • Reviewers will "approve" the PR or change title to [MRG + 1]
  • You need 2 approvals for a merge

This is what a merged icon looks like:

Returning to work: reminder to sync repo before beginning work

git pull upstream main
git push origin main

Switch to working branch

git checkout feature_branch
git pull upstream main
git push origin feature_branch