Skip to content

Commit ea16806

Browse files
author
a.pirogov
committed
minor tweaks, some improvement of dev guide
1 parent c2b8c20 commit ea16806

File tree

9 files changed

+141
-78
lines changed

9 files changed

+141
-78
lines changed

.somesy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fair-python-cookiecutter"
3-
version = "0.1.1"
3+
version = "0.1.0"
44
description = "An opinionated cookiecutter template to kickstart a modern best-practice Python project with FAIR metadata. "
55

66
license = "MIT"

CHANGELOG.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ Here we provide notes that summarize the most important changes in each released
44

55
Please consult the changelog to inform yourself about breaking changes and security issues.
66

7-
## [v0.1.1](https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter/tree/v0.1.0) <small>(2023-05-11)</small> { id="0.1.1" }
8-
9-
* Add [somesy](https:///Materials-Data-Science-and-Informatics/somesy) to manage and synchronize project metadata
10-
* Various minor fixes
11-
12-
## [v0.1.0](https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter/tree/v0.1.0) <small>(2023-05-11)</small> { id="0.1.0" }
7+
## [v0.1.0](https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter/tree/v0.1.0) <small>(2023-07-24)</small> { id="0.1.0" }
138

149
* First release
1510

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type: software
33
message: If you use this software, please cite it using this metadata.
44

55
title: "fair-python-cookiecutter"
6-
version: "0.1.1"
6+
version: "0.1.0"
77
abstract: "An opinionated cookiecutter template to kickstart a modern best-practice
88
Python project with FAIR metadata."
99
repository-code: "https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter"

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,40 @@ default_context:
117117
This information will be already pre-filled when you use the template,
118118
saving you some time and possibly avoiding possible mistakes from manual typing.
119119
120+
## Modifying the Template
121+
122+
If you want to adjust it to your needs and likings (e.g. add, remove or substitute certain
123+
tools), you probably want to
124+
[fork](https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter/fork)
125+
it to get your own copy. Then you can do the desired changes and use the URL of your
126+
template repository instead of this one to kickstart your projects.
127+
128+
However, if you think that your changes are of general interest and would improve this
129+
template, consider to get in touch
130+
and [contribute](https://materials-data-science-and-informatics.github.io/fair-python-cookiecutter/main/contributing/)!
131+
132+
In any case we are very happy to know about any similar or derivative templates, e.g. for
133+
more specific use-cases or based on other tool preferences.
134+
135+
## Reusing Parts of the Template
136+
137+
If you already have an existing project where you would like to introduce things you like
138+
from this template, there are two main ways to do so:
139+
140+
1. move your code into a fresh repository based on this template
141+
2. use parts of the template in your existing project structure
142+
143+
If your project currently has no sophisticated setup of tools or strong preferences about
144+
them, option 1 might be the simplest way to adopt the template. Your code then needs to be
145+
moved into the `YOUR_PROJECT/src` subdirectory.
146+
147+
On the other hand, if you already have a working setup that you do not wish to replace
148+
completely, you can take a look at
149+
150+
* the `.pre-commit-config.yaml` file to adopt some of the quality assurance tools listed there
151+
* the CI pipelines defined in `.github/workflows` or `.gitlab-ci.yml` for automated tests and releases
152+
* the `mkdocs.yml` and `docs/` subdirectory to see how the project website works
153+
120154
<!-- --8<-- [end:quickstart] -->
121155

122156
<!-- --8<-- [start:citation] -->

codemeta.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"audience": [
1111
{
1212
"@type": "Audience",
13-
"audienceType": "Developers"
13+
"audienceType": "Science/Research"
1414
},
1515
{
1616
"@type": "Audience",
17-
"audienceType": "Science/Research"
17+
"audienceType": "Developers"
1818
}
1919
],
2020
"author": [
@@ -59,5 +59,5 @@
5959
}
6060
],
6161
"url": "https://materials-data-science-and-informatics.github.io/fair-python-cookiecutter",
62-
"version": "0.1.1"
62+
"version": "0.1.0"
6363
}

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ repo_url: "https://github.com/Materials-Data-Science-and-Informatics/fair-python
66
edit_uri: "blob/main/docs/"
77
repo_name: "Materials-Data-Science-and-Informatics/fair-python-cookiecutter"
88
docs_dir: "{{ cookiecutter.__project_slug }}/docs"
9+
watch: ["README.md"]
910

1011
# navigation structure (TOC + respective markdown files):
1112
nav:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
# ---- managed by somesy, see .somesy.toml ----
33
name = "fair-python-cookiecutter"
4-
version = "0.1.1"
4+
version = "0.1.0"
55
description = "An opinionated cookiecutter template to kickstart a modern best-practice Python project with FAIR metadata."
66
authors = ["Anton Pirogov <[email protected]>"]
77
maintainers = ["Anton Pirogov <[email protected]>"]

{{ cookiecutter.__project_slug }}/docs/dev_guide.md

Lines changed: 98 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,75 @@ and provides more information on how to work with this repository.
99

1010
Here is a *non-exhaustive* list of the most important files and directories in the repository.
1111

12-
*General:*
13-
14-
* `AUTHORS.md`: acknowledges and lists all contributors
15-
* `CHANGELOG.md`: summarizes the changes for each version of the software for users
16-
* `CODE_OF_CONDUCT.md`: defines the social standards that must be followed by contributors
17-
* `CONTRIBUTING.md`: explains how others can contribute to the project
18-
* `README.md`: provides an overview and points to other resources
19-
20-
*Metadata:*
21-
22-
* `CITATION.cff`: metadata stating how to cite the project
23-
* `codemeta.json`: metadata for harvesting by other tools and services
24-
* `LICENSE`: the (main) license of the project
25-
* `LICENSES`: copies of all licenses that apply to files in the project
26-
* `.reuse/dep5`: granular license and copyright information for all files and directories
27-
28-
*Development:*
29-
30-
* `pyproject.toml`: project metadata, dependencies, development tool configurations
31-
* `poetry.lock`: needed for reproducible installation of the project
32-
* `src`: actual code provided by the project
33-
* `tests`: all tests for the code in the project
34-
* `mkdocs.yml`: configuration of the project website
35-
* `docs`: most contents used for the project website
36-
37-
*Automation and Quality Control:*
38-
39-
* `.pre-commit-config.yaml`: quality assurance tools used in the project
40-
* `.github/workflows`: CI scripts for GitHub (QA, documentation and package deployment)
41-
* `.github/ISSUE_TEMPLATE`: templates for the GitHub issue tracker
42-
* `.gitlab-ci.yml`: mostly equivalent CI scripts, but for GitLab
43-
* `.gitlab/issue_templates`: The same issues templates, but for GitLab
12+
=== "General"
13+
* `AUTHORS.md`: acknowledges and lists all contributors
14+
* `CHANGELOG.md`: summarizes the changes for each version of the software for users
15+
* `CODE_OF_CONDUCT.md`: defines the social standards that must be followed by contributors
16+
* `CONTRIBUTING.md`: explains how others can contribute to the project
17+
* `README.md`: provides an overview and points to other resources
18+
19+
=== "Metadata"
20+
* `CITATION.cff`: metadata stating how to cite the project
21+
* `codemeta.json`: metadata for harvesting by other tools and services
22+
* `LICENSE`: the (main) license of the project
23+
* `LICENSES`: copies of all licenses that apply to files in the project
24+
* `.reuse/dep5`: granular license and copyright information for all files and directories
25+
26+
=== "Development"
27+
* `pyproject.toml`: project metadata, dependencies, development tool configurations
28+
* `poetry.lock`: needed for reproducible installation of the project
29+
* `src`: actual code provided by the project
30+
* `tests`: all tests for the code in the project
31+
* `mkdocs.yml`: configuration of the project website
32+
* `docs`: most contents used for the project website
33+
34+
=== "CI / QA"
35+
* `.pre-commit-config.yaml`: quality assurance tools used in the project
36+
* `.github/workflows`: CI scripts for GitHub (QA, documentation and package deployment)
37+
* `.github/ISSUE_TEMPLATE`: templates for the GitHub issue tracker
38+
* `.gitlab-ci.yml`: mostly equivalent CI scripts, but for GitLab
39+
* `.gitlab/issue_templates`: The same issues templates, but for GitLab
40+
41+
!!! tip
42+
You might find various other files popping up which are generated by different tools.
43+
Most of these should not be committed into the repository, so they are excluded
44+
in the `.gitignore` file. Everything listed there is safe to delete.
4445

4546
### Used Tools
4647

4748
Here is a *non-exhaustive* list of the most important tools used in the project.
4849

49-
Best practices for modern Python development are implemented by using:
50-
51-
* `poetry` for dependency management and packaging
52-
* `pytest` for unit testing
53-
* `hypothesis` for property-based testing
54-
* `pre-commit` for orchestrating linters, formatters and other utilities
55-
* `black` for source-code formatting
56-
* `autoflake` for automatically removing unused imports
57-
* `flake8` for general linting (using various linter plugins)
58-
* `pydocstyle` for checking docstring conventions
59-
* `interrogate` for computing docstring coverage
60-
* `mypy` for editor-independent type-checking
61-
* `mkdocs` for generating the project documentation website
62-
* `bandit` for checking security issues in the code
63-
* `safety` for checking security issues in the current dependencies
64-
65-
Metadata best practices for FAIR software are implemented using:
66-
67-
* `cffconvert` to check the `CITATION.cff` (citation metadata)
68-
* `codemetapy` to generate a `codemeta.json` (general software metadata)
69-
* `somesy` to keep all important metadata continuously synchronized
70-
* `reuse` to check [REUSE-compliance](https://reuse.software/spec/) (granular copyright and license metadata)
71-
* `licensecheck` to scan for possible license incompatibilities in the dependencies
50+
=== "General"
51+
* `poetry` for dependency management and packaging
52+
* `poethepoet` tool for running common tasks
53+
* `pre-commit` for orchestrating linters, formatters and other utilities
54+
* `mkdocs` for generating the project documentation website
55+
* `mike` for managing the `mkdocs`-generated documentation website
56+
57+
=== "Code Quality"
58+
* `flake8` for general linting (using various linter plugins)
59+
* `mypy` for editor-independent type-checking
60+
* `pytest` for unit testing
61+
* `pytest-cov` for computing code coverage by tests
62+
* `hypothesis` for property-based testing
63+
* `bandit` for checking security issues in the code
64+
* `safety` for checking security issues in the current dependencies
65+
66+
=== "Formatting and Style"
67+
* `black` for source-code formatting
68+
* `autoflake` for automatically removing unused imports
69+
* `pydocstyle` for checking docstring conventions
70+
71+
=== "FAIR metadata"
72+
* `cffconvert` to check the `CITATION.cff` (citation metadata)
73+
* `codemetapy` to generate a `codemeta.json` (general software metadata)
74+
* `somesy` to keep all important metadata continuously synchronized
75+
* `reuse` to check [REUSE-compliance](https://reuse.software/spec/) (granular copyright and license metadata)
76+
* `licensecheck` to scan for possible license incompatibilities in the dependencies
77+
78+
!!! tip
79+
Most tools installed and used by this project are listed in the
80+
`pyproject.toml` and `.pre-commit-config.yaml` files.
7281

7382
## Basics
7483

@@ -85,8 +94,9 @@ In older software, most of this information is often scattered over many little
8594
tool-specific configuration files and a `setup.py`, `setup.cfg` and/or `requirements.txt`
8695
file.
8796

88-
In this project, `pyproject.toml` is the first place that should be checked
89-
when looking for the configuration of some development tool.
97+
!!! tip
98+
`pyproject.toml` is the first place your should check
99+
when looking for the configuration of some development tool.
90100

91101
### Configuration
92102

@@ -109,8 +119,10 @@ Note that `poetry` is only needed for development of the repository.
109119
The *end-users* who just want to *install and use* this project
110120
do **not need** to set up or know anything about poetry.
111121

112-
Note that if you use `poetry shell` and the project is installed with `poetry install`,
113-
in the following you do not have to prepend `poetry run` to commands you will see below.
122+
!!! tip
123+
If you use `poetry shell` to activate the virtual environment of the project,
124+
and the project is already installed with `poetry install`, in the following you do not
125+
have to prepend `poetry run` in the commands you will see below.
114126

115127
### Task Runner
116128

@@ -123,7 +135,7 @@ Often projects use a shell script or `Makefile` for this purpose. This project u
123135
[poethepoet](https://github.com/nat-n/poethepoet), as it integrates nicely with `poetry`.
124136
The tasks are defined in `pyproject.toml` and can be launched using:
125137

126-
```
138+
```bash
127139
poetry run poe TASK_NAME
128140
```
129141

@@ -153,7 +165,7 @@ be activated. This is usually done using `pre-commit install`, which also requir
153165

154166
In this project, you can run:
155167

156-
```
168+
```bash
157169
poetry run poe init-dev
158170
```
159171

@@ -182,7 +194,7 @@ After doing that, you can retry to `git commit` your changes.
182194
To avoid having to deal with many issues at once, it is a good habit to run
183195
`pre-commit` by hand from time to time. In this project, this can be done with:
184196

185-
```
197+
```bash
186198
poetry run poe lint --all-files
187199
```
188200

@@ -204,10 +216,14 @@ Such randomized tests can be a good addition to hand-crafted tests and inputs.
204216

205217
To run all tests, either invoke `pytest` directly, or use the provided task:
206218

207-
```
219+
```bash
208220
poetry run poe test
209221
```
210222

223+
!!! tip
224+
Add the flag `--cov` to enable the test coverage tracking and get a table with
225+
results after the tests are completed.
226+
211227
## Documentation
212228

213229
The project uses [`mkdocs`](https://www.mkdocs.org/) with the popular and excellent
@@ -234,6 +250,11 @@ To make this both possible as well as convenient, this project uses
234250
[`mike`](https://github.com/jimporter/mike) to generate and manage the `mkdocs`
235251
**documentation for different versions** of the software.
236252

253+
!!! tip
254+
You can easily add new pages (e.g. extended tutorials or topic-specific guides) to
255+
your documentation website by creating markdown files in the `docs/` directory and
256+
adding them to the `nav` section in `mkdocs.yml`.
257+
237258
### Online Documentation
238259

239260
To avoid dependence on additional services such as [readthedocs](https://readthedocs.org/),
@@ -243,19 +264,31 @@ The provided CI pipeline automatically generates the documentation for the lates
243264
development version (i.e., current state of the `main` branch) as well as every released
244265
version (i.e., marked by a version tag `vX.Y.Z`).
245266

267+
268+
!!! tip
269+
Should anything go wrong and you need to manually access the data of the deployed
270+
website, you can find it in the `gh-pages` branch of the repository. Normally you
271+
should not need to use that branch directly, though.
272+
273+
246274
### Offline Documentation
247275

248276
You can manually generate a local and fully offline copy of the documentation, which
249277
can be useful for e.g. previewing the results during active work on the documentation:
250278

251-
```
279+
```bash
252280
poetry install --with docs
253281
poetry run poe docs
254282
```
255283

256284
Once the documentation site is built, run `mkdocs serve` and
257285
open `https://localhost:8000` in your browser to see the local copy of the website.
258286

287+
!!! tip
288+
You probably should always check bigger website updates locally before it is publicly
289+
deployed. The automatic pipelines can only catch technical problems, but you still
290+
e.g. might want to do some proof-reading.
291+
259292
## Releases
260293

261294
From time to time the project is ready for a new **release** for users.
@@ -315,4 +348,4 @@ in the `publish` job in `ci.yml` to enable the corresponding publication target.
315348

316349
If the old and less secure token-based authentication method is needed or
317350
the package should be published to a different PyPI-compatible package index, please
318-
adapt `release.yml` [accordingly](https://github.com/pypa/gh-action-pypi-publish)).
351+
adapt `release.yml` [accordingly](https://github.com/pypa/gh-action-pypi-publish).

{{ cookiecutter.__project_slug }}/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ build-backend = "poetry.core.masonry.api"
126126

127127
# NOTE: You can run the following with "poetry poe TASK"
128128
[tool.poe.tasks]
129-
init-dev = { shell = "pre-commit install" }
129+
init-dev = "pre-commit install" # run once after clone to enable various tools
130130
lint = "pre-commit run" # pass --all-files to check everything
131131
test = "pytest" # pass --cov to also collect coverage info
132132
docs = "mkdocs build" # run this to generate local documentation

0 commit comments

Comments
 (0)