|
1 | | -# robinson-group-python-template |
| 1 | +## Robinson Group Python Template |
| 2 | +This repo serves as a template for python projects in the [Robinson Group](https://robinsongroup.github.io/) of the BIH. |
| 3 | +To get started copy or fork this project and follow the steps below. |
| 4 | +### Install conda |
| 5 | +If you not already have conda, miniconda or Anaconda installed. Check out the [miniconda installation guide](https://www.anaconda.com/docs/getting-started/miniconda/install#quickstart-install-instructions). |
| 6 | + |
| 7 | +#### Setup env |
| 8 | +Open `requirements/environment.yml` and adjust `<Project-Name>`. |
| 9 | + |
| 10 | +To create and activate the env execute: |
| 11 | + |
| 12 | +``` |
| 13 | +conda env create -f requirements/environment.yml |
| 14 | +conda activate <Project-Name> |
| 15 | +``` |
| 16 | + |
| 17 | +### Renaming |
| 18 | +As this is a template project, some of the directories and setting have generic names. To ensure the project is set up, that it aligns with your intended name please: |
| 19 | + |
| 20 | +1. Rename the folder inside of src |
| 21 | +2. Open the pyproject.toml |
| 22 | + - Rename all variables in the sections ``[project]`` and ``[project.urls]`` |
| 23 | + |
| 24 | +### Ruff Linting and Formatting |
| 25 | +Ruff helps to maintain the same code style and prevent the most common bugs in our code base. Keeping the code style uniform simplifies the collaboration - it is much easier to review a pull request without hundreds of whitespace changes. |
| 26 | + |
| 27 | +Please take a moment to learn how to use the IDE plugins. In PyCharm, the formatting action can be invoked with right-clicking at any code location and the same applies for VS Code. The keyboard shortcuts are also available. However, it is recommended to format and lint on saving a file. |
| 28 | + |
| 29 | +Besides the IDE, Ruff can also be run as a command line tool. Assuming that the virtual environment is active, the following command will format/lint the entire project: |
| 30 | + |
| 31 | +**Formatting** |
| 32 | +```bash |
| 33 | +ruff format |
| 34 | +``` |
| 35 | +**Linting** |
| 36 | +```bash |
| 37 | +ruff check |
| 38 | +``` |
| 39 | +We recommend to run commit the resulting changes before opening a PR, because the unformatted code will fail the Continuous Integration (CI) pipeline. A PR cannot be merged until the code passes the CI. |
| 40 | + |
| 41 | +#### Ruff Plugins |
| 42 | +- [Pycharm - Ruff Plugin](https://plugins.jetbrains.com/plugin/20574-ruff) |
| 43 | +- [VSCode - Ruff Plugin](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) |
| 44 | + |
| 45 | +### Continuous Delivery |
| 46 | +You've done it, your package is at a state, where you want other to use it. Luckily, this repository features a CD-Pipeline, |
| 47 | +that will build and upload your packages to Pypi for you. To get the CD running you need to first follow these [instructions](https://docs.pypi.org/trusted-publishers/adding-a-publisher/). The pipeline uses [OIDC](https://openid.net/developers/how-connect-works/) to authenticate on Pypi. Make sure your [pyproject.toml](pyproject.toml) is set up correctly. |
| 48 | + |
| 49 | +Then open your repository page on Github. To the right you should find **Create new Release**. Press it! |
| 50 | + |
| 51 | +You will find this page: |
| 52 | + |
| 53 | + |
| 54 | +Create a new Tag for your release, add a title and a description. Press **Publish release**, watch the CD launch in the **Actions Tab** and enjoy your well deserved coffee. ☕ |
0 commit comments