Skip to content

6. Python Workflow

Ali Heydari edited this page Oct 5, 2023 · 1 revision

Python Version and Development Environment

We highly recommend developers code in the newer version of Python (Python >= 3.9) with managed Conda environments. In order to ensure the reproducibility of your code and to avoid any installation issues, we require a full package skeleton (described below) for every project with the appropriate requirements listed in a requirements.txt or in the setup.py file. Additionally, we also encourage sharing the Conda environment yaml file or creating a docker image of the computational environment (both are optional).

The Skeleton of a Python Project

A major aim of PCR is to ensure that our research code is reproducible and robust. As part of this, it is crucial for our research software to be packaged, which allows for much easier shipment and installation of the dependencies. Thus, we require all submitted python codes to be shipped as a package. Algorithms and methods must not be implemented in a notebook environment, and any PR with a notebook as the primary review source will be rejected. For more information on creating a python package, please visit
https://packaging.python.org/en/latest/tutorials/packaging-projects/. Alternatively, you can check out existing packages to learn about the directory logic (e.g. see this python package).

Python Unit Testing

Unit testing is a crucial component of any software. Therefore, we request the developer to design appropriate unit tests within the package so that the reviewer can evaluate as part of the PCR. Though any unit testing packages will be accepted, we recommend utilizing the native unittest package to perform unit testing. A complete guide for unit testing can be found at https://docs.python.org/3/library/unittest.html

Linting Your Code

As mentioned earlier, code reviewers should be able to primarily focus on coding logic and implementation details. Having too many linting bugs and warnings can distract a reviewer from focusing on your code, which can be time-consuming (and frustrating). Therefore, we request that all submitted codes be thoroughly linted prior to submitting a PR. Information about linters that work with Google's style guide can be found at: https://google.github.io/styleguide/pyguide.html

Clone this wiki locally