Contributing to Seldon Core

Before opening a pull request consider:

  • Is the change important and ready enough to ask the community to spend time reviewing?
  • Have you searched for existing, related issues and pull requests?
  • Is the change being proposed clearly explained and motivated?

When you contribute code, you affirm that the contribution is your original work and that you license the work to the project under the project’s open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project’s open source license and warrant that you have the legal authority to do so.

Coding conventions

We use pre-commit to handle a number of Git hooks which ensure that all changes to the codebase follow Seldon’s code conventions. It is recommended to set these up before making any change to the codebase. Extra checks down the line will stop the build if the code is not compliant to the style guide of each language in the repository.

To install it, follow the official instructions. Once installed, run:

$ pre-commit install

This will read the hooks defined in .pre-commit-config.yaml and install them accordingly on your local repository.

Java

To format our Java code we follow Google’s Java style guide. To make sure that the codebase remains consistent, we use checkstyle as part of the mvn validate lifecycle.

To integrate these on your local editor, you can follow the official instructions to configure checkstyle locally and to set-up google-java-format.

Python

To format our Python code we use black, the heavily opinionated formatter.

To integrate it on your local editor, you can follow the official instructions to set-up black.

Tests

Regardless of the package you are working on, we abstract the main tasks to a Makefile. Therefore, in order to run the tests, you should be able to just do:

$ make test

Python

We use pytest as our main test runner. However, to ensure that tests run on the same version of the package that final users will download from pip and pypi.org, we use tox on top of it. To install both (plus other required plugins), just run:

$ make install_dev

Using tox we can run the entire test suite over different environments, isolated between them. You can see the different ones we currently use on the setup.cfg file. You can run your tests across all these environments using the standard make test mentioned above. Alternatively, if you want to pass any extra parameters, you can also run tox directly as:

$ tox

One of the caveats of tox is that, as the number of environments grows, so does the time it takes to finish running the tests. As a solution, during local development it may be recommended to run pytest directly on your own environment. You can do so as:

$ pytest

End to End Tests

As part of Seldon Core’s test suite, we also run end to end tests. These spin up an actual Kubernetes cluster using Kind and deploy different SeldonDeployment and resources.

You can learn more about how to run them and how to add new test cases on their dedicated documentation.