|
| 1 | +# Developer Guide |
| 2 | + |
| 3 | +Welcome. We are so happy you've decided to contribute. |
| 4 | + |
| 5 | +## Setting up a development environment |
| 6 | + |
| 7 | +This guide describes how to install and configure development environments. |
| 8 | + |
| 9 | +If you have any problems with the steps here, please reach out in the `dev` channel on [Discord](https://discord.gg/rb6gPXbdAr) or on [Discourse](https://discourse.holoviz.org/). |
| 10 | + |
| 11 | +## Preliminaries |
| 12 | + |
| 13 | +### Basic understanding of how to contribute to Open Source |
| 14 | + |
| 15 | +If this is your first open-source contribution, please study one or more of the below resources. |
| 16 | + |
| 17 | +- [How to Get Started with Contributing to Open Source | Video](https://youtu.be/RGd5cOXpCQw) |
| 18 | +- [Contributing to Open-Source Projects as a New Python Developer | Video](https://youtu.be/jTTf4oLkvaM) |
| 19 | +- [How to Contribute to an Open Source Python Project | Blog post](https://www.educative.io/blog/contribue-open-source-python-project) |
| 20 | + |
| 21 | +### Git |
| 22 | + |
| 23 | +The Param source code is stored in a [Git](https://git-scm.com) source control repository. The first step to working on Param is to install Git onto your system. There are different ways to do this, depending on whether you use Windows, Mac, or Linux. |
| 24 | + |
| 25 | +To install Git on any platform, refer to the [Installing Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) section of the [Pro Git Book](https://git-scm.com/book/en/v2). |
| 26 | + |
| 27 | +To contribute to Param, you will also need [Github account](https://github.com/join) and knowledge of the [_fork and pull request workflow_](https://docs.github.com/en/get-started/quickstart/contributing-to-projects). |
| 28 | + |
| 29 | +### Pixi |
| 30 | + |
| 31 | +Developing all aspects of Param requires a wide range of packages in different environments. To make this more manageable, Pixi manages the developer experience. To install Pixi, follow [this guide](https://pixi.sh/latest/#installation). |
| 32 | + |
| 33 | +#### Glossary |
| 34 | + |
| 35 | +- Tasks: A task is what can be run with `pixi run <task-name>`. Tasks can be anything from installing packages to running tests. |
| 36 | +- Environments: An environment is a set of packages installed in a virtual environment. Each environment has a name; you can run tasks in a specific environment with the `-e` flag. |
| 37 | + For example, `pixi run -e test-core test-unit` will run the `test-unit` task in the `test-core` environment. |
| 38 | +- Lock-file: A lock-file is a file that contains all the information about the environments. |
| 39 | + |
| 40 | +For more information, see the [Pixi documentation](https://pixi.sh/latest/). |
| 41 | + |
| 42 | +:::{admonition} Note |
| 43 | +:class: info |
| 44 | + |
| 45 | +The first time you run `pixi`, it will create a `.pixi` directory in the source directory. |
| 46 | +This directory will contain all the files needed for the virtual environments. |
| 47 | +The `.pixi` directory can be large, so it is advised not to put the source directory into a cloud-synced directory. |
| 48 | +::: |
| 49 | + |
| 50 | +## Installing the Project |
| 51 | + |
| 52 | +### Cloning the Project |
| 53 | + |
| 54 | +The source code for the Param project is hosted on [GitHub](https://github.com/holoviz/param). The first thing you need to do is clone the repository. |
| 55 | + |
| 56 | +1. Go to [github.com/holoviz/param](https://github.com/holoviz/param) |
| 57 | +2. [Fork the repository](https://docs.github.com/en/get-started/quickstart/contributing-to-projects#forking-a-repository) |
| 58 | +3. Run in your terminal: `git clone https://github.com/<Your Username Here>/param` |
| 59 | + |
| 60 | +The instructions for cloning above created a `param` directory at your file system location. |
| 61 | +This `param` directory is the _source checkout_ for the remainder of this document, and your current working directory is this directory. |
| 62 | + |
| 63 | +### Fetch tags from upstream |
| 64 | + |
| 65 | +The version number of the package depends on [`git tags`](https://git-scm.com/book/en/v2/Git-Basics-Tagging), so you need to fetch the tags from the upstream repository: |
| 66 | + |
| 67 | +```bash |
| 68 | +git remote add upstream https://github.com/holoviz/param.git |
| 69 | +git fetch --tags upstream |
| 70 | +git push --tags |
| 71 | +``` |
| 72 | + |
| 73 | +## Start developing |
| 74 | + |
| 75 | +To start developing, run the following command |
| 76 | + |
| 77 | +```bash |
| 78 | +pixi install |
| 79 | +``` |
| 80 | + |
| 81 | +The first time you run it, it will create a `pixi.lock` file with information for all available environments. This command will take a minute or so to run. |
| 82 | + |
| 83 | +All available tasks can be found by running `pixi task list`, the following sections will give a brief introduction to the most common tasks. |
| 84 | + |
| 85 | +### Editable install |
| 86 | + |
| 87 | +It can be advantageous to install Param in [editable mode](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs): |
| 88 | + |
| 89 | +```bash |
| 90 | +pixi run install |
| 91 | +``` |
| 92 | + |
| 93 | +:::{admonition} Note |
| 94 | +:class: info |
| 95 | + |
| 96 | +Currently, this needs to be run for each environment. So, if you want to install in the `test-312` environment, you can add `--environment` / `-e` to the command: |
| 97 | + |
| 98 | +```bash |
| 99 | +pixi run -e test-313 install |
| 100 | +``` |
| 101 | + |
| 102 | +You can find the list of environments in the **pixi.toml** file or via the command `pixi info`. |
| 103 | + |
| 104 | +::: |
| 105 | + |
| 106 | +## Linting |
| 107 | + |
| 108 | +Param uses [pre-commit](https://pre-commit.com/) to apply linting to Param code. Linting can be run for all the files with: |
| 109 | + |
| 110 | +```bash |
| 111 | +pixi run lint |
| 112 | +``` |
| 113 | + |
| 114 | +Linting can also be set up to run automatically with each commit; this is the recommended way because if linting is not passing, the [Continuous Integration](https://en.wikipedia.org/wiki/Continuous_integration) (CI) will also fail. |
| 115 | + |
| 116 | +```bash |
| 117 | +pixi run lint-install |
| 118 | +``` |
| 119 | + |
| 120 | +## Testing |
| 121 | + |
| 122 | +To help keep Param maintainable, all Pull Requests (PR) with code changes should typically be accompanied by relevant tests. While exceptions may be made for specific circumstances, the default assumption should be that a Pull Request without tests will not be merged. |
| 123 | + |
| 124 | +There are three types of tasks and five environments related to tests. |
| 125 | + |
| 126 | +### Unit tests |
| 127 | + |
| 128 | +Unit tests are usually small tests executed with [pytest](https://docs.pytest.org). They can be found in `param/tests/`. |
| 129 | +Unit tests can be run with the `test-unit` task: |
| 130 | + |
| 131 | +```bash |
| 132 | +pixi run test-unit |
| 133 | +``` |
| 134 | + |
| 135 | +The task is available in the following environments: |
| 136 | + |
| 137 | +1. `test-39`, `test-310`, `test-311`, `test-312`, and `test-313`. |
| 138 | +1. `test-core` and `test-pypy` |
| 139 | + |
| 140 | +Where the first ones have the same environments except for different Python versions. `test-core` only has a core set of dependencies, and `test-pypy` is for testing on PyPy. |
| 141 | + |
| 142 | +If you haven't set the environment flag in the command, a menu will help you select which one of the environments to use. |
| 143 | + |
| 144 | +### Example tests |
| 145 | + |
| 146 | +Param's documentation consists mainly of Jupyter Notebooks. The example tests execute all the notebooks and fail if an error is raised. Example tests are possible thanks to [nbval](https://nbval.readthedocs.io/) and can be found in the `doc/` folder. |
| 147 | +Example tests can be run with the following command: |
| 148 | + |
| 149 | +```bash |
| 150 | +pixi run test-example |
| 151 | +``` |
| 152 | + |
| 153 | +This task has the same environments as the unit tests except for `test-core` and `test-pypy`. |
| 154 | + |
| 155 | +## Documentation |
| 156 | + |
| 157 | +The documentation can be built with the command: |
| 158 | + |
| 159 | +```bash |
| 160 | +pixi run docs-build |
| 161 | +``` |
| 162 | + |
| 163 | +## Build |
| 164 | + |
| 165 | +Param has two build tasks, for building packages for Pip and Conda. |
| 166 | + |
| 167 | +```bash |
| 168 | +pixi run build-pip |
| 169 | +pixi run build-conda |
| 170 | +``` |
| 171 | + |
| 172 | +## Continuous Integration |
| 173 | + |
| 174 | +Every push to the `main` branch or any PR branch on GitHub automatically triggers a test build with [GitHub Actions](https://github.com/features/actions). |
| 175 | + |
| 176 | +You can see the list of all current and previous builds at [this URL](https://github.com/holoviz/param/actions) |
| 177 | + |
| 178 | +### Etiquette |
| 179 | + |
| 180 | +GitHub Actions provides free build workers for open-source projects. A few considerations will help you be considerate of others needing these limited resources: |
| 181 | + |
| 182 | +- Run the tests locally before opening or pushing to an opened PR. |
| 183 | + |
| 184 | +- Group commits to meaningful chunks of work before pushing to GitHub (i.e., don't push on every commit). |
| 185 | + |
| 186 | +## Useful Links |
| 187 | + |
| 188 | +- [Dev version of Param Site](https://holoviz-dev.github.io/param) |
| 189 | + - Use this to explore new, not yet released features and docs |
0 commit comments