Contributing Guidelines

This page explains how you can contribute to the development of scikit-survival. There are a lot of ways you can contribute:

  • Writing new code, e.g. implementations of new algorithms, or examples.

  • Fixing bugs.

  • Improving documentation.

  • Reviewing open pull requests.

scikit-survival is developed on GitHub using the Git version control system. The preferred way to contribute to scikit-survival is to fork the main repository on GitHub, then submit a pull request (PR).

Creating a fork

These are the steps you need to take to create a copy of the scikit-survival repository on your computer.

  1. Create an account on GitHub if you do not already have one.

  2. Fork the scikit-survival repository.

  3. Clone your fork of the scikit-survival repository from your GitHub account to your local disk. You have to execute from the command line:

    git clone --recurse-submodules git@github.com:YourLogin/scikit-survival.git
    cd scikit-survival
    

Setting up a Development Environment

After you created a copy of our main repository on GitHub, your need to setup a local development environment. We strongly recommend to use conda to create a separate virtual environment containing all dependencies. These are the steps you need to take.

  1. Install conda for your operating system if you haven’t already.

  2. Create a new environment, named sksurv:

    python ci/list-requirements.py requirements/dev.txt > dev-requirements.txt
    conda create -n sksurv -c sebp python=3 --file dev-requirements.txt
    
  3. Activate the newly created environment:

    conda activate sksurv
    
  4. Compile the C/C++ extensions and install scikit-survival in development mode:

    pip install --no-build-isolation -e .
    

Making Changes to the Code

For a pull request to be accepted, your changes must meet the below requirements.

  1. All changes related to one feature must belong to one branch. Each branch must be self-contained, with a single new feature or bugfix. Create a new feature branch by executing:

    git checkout -b my-new-feature
    
  2. All code must follow the standard Python guidelines for code style, PEP8. To check that your code conforms to PEP8, you can install tox and run:

    tox -e py38-flake8
    
  3. Each function, class, method, and attribute needs to be documented using docstrings. scikit-survival conforms to the numpy docstring standard.

  4. Code submissions must always include unit tests. We are using pytest. All tests must be part of the tests directory. You can run the test suite locally by executing:

    py.test tests/
    

    Tests will also be executed automatically once you submit a pull request.

  5. The contributed code will be licensed under the GNU General Public License v3.0. If you did not write the code yourself, you must ensure the existing license is compatible and include the license information in the contributed files, or obtain a permission from the original author to relicense the contributed code.

Submitting a Pull Request

  1. When you are done coding in your feature branch, add changed or new files:

    git add path/to/modified_file
    
  2. Create a commit message describing what you changed. Commit messages should be clear and concise. The first line should contain the subject of the commit and not exceed 80 characters in length. If necessary, add a blank line after the subject followed by a commit message body with more details:

    git commit
    
  3. Push the changes to GitHub:

    git push -u origin my_feature
    
  4. Create a pull request.

Building the Documentation

The documentation resides in the doc/ folder and is written in reStructuredText. HTML files of the documentation can be generated using Sphinx. The easiest way to build the documentation is to install tox and run:

tox -e py38-docs

Generated files will be located in doc/_build/html. To open the main page of the documentation, run:

xdg-open _build/html/index.html