You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: episodes/42-software-reuse.md
+60-16Lines changed: 60 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,9 +78,10 @@ In this episode we will work on improving the reusability of our code.
78
78
It would be a good idea to create a new branch for this work,
79
79
and merge it back into `main` once we are done.
80
80
81
-
For example, you could create a branch called `improve-reusability`:
81
+
For example, you could create a branch called `improve-reusability` from the `develop` branch:
82
82
83
83
```bash
84
+
$ git switch develop
84
85
$ git switch -c improve-reusability
85
86
```
86
87
@@ -324,6 +325,8 @@ For simplicity, we can borrow the content from our `README.md` file.
324
325
325
326
::::::::::::::::::::::::::::::::: challenge
326
327
328
+
### Exercise: Update Documentation Content
329
+
327
330
Modify `docs/index.md` with the same content as your `README.md` file.
328
331
Render the documentation site locally again with `mkdocs serve`.
329
332
Check how it looks like in your web browser.
@@ -391,6 +394,7 @@ Once you are happy with the documentation site, you can deploy it to GitHub Page
391
394
392
395
```bash
393
396
git add inflammation/models.py mkdocs.yml docs/
397
+
git commit -m "Add documentation with MKDocs"
394
398
```
395
399
396
400
To deploy the documentation to GitHub Pages, you can use the following command:
@@ -458,6 +462,47 @@ dependencies = [
458
462
459
463
This is an alternative way to specify the dependencies than the `requirements.txt` file we created before. The advantage of specifying dependencies in `pyproject.toml`, is that it centralizes this information in one place, and better integrates with modern Python packaging tools like [`uv`](https://docs.astral.sh/uv/), which we will see in the next section about releasing our Python project.
460
464
465
+
Do not forget to commit the changes we made to `pyproject.toml` file.
466
+
467
+
```bash
468
+
git add pyproject.toml
469
+
git commit -m "Update pyproject.toml with dependencies"
470
+
```
471
+
472
+
## Make Your Code Citable by adding a CITATION File
473
+
474
+
It is easy to correctly cite a paper: all the necessary information (metadata) can be found on the title page or the article website.
475
+
476
+
Software and datasets have no title page, the relevant information is often less obvious. To get credit for your work, you should provide citation information for your software.
477
+
478
+
A good way to add citation information is by including a [CITATION.cff](https://citation-file-format.github.io/) file (Citation File Format) in the root of your repository. This plain text file, written in YAML format, contains all the necessary citation details in a structured manner.
479
+
480
+
Platforms like GitHub, Zenodo, and Zotero reuse the citation metadata you provide. GitHub, for example, automatically renders the file on the repository landing page and provides a BibTeX snippet which users can simply copy!
481
+
482
+
#### Minimal example for a CITATION.cff file
483
+
484
+
```yaml
485
+
authors:
486
+
- family-names: Doe
487
+
given-names: John
488
+
cff-version: 1.2.0
489
+
message: "If you use this software, please cite it using the metadata from this file."
490
+
title: "Inflam"
491
+
```
492
+
We can also include other important information of software such as version, release date, DOI, license, keywords.
493
+
494
+
#### How to create a CITATION.cff file?
495
+
496
+
You can use the [cffinit](https://citation-file-format.github.io/cff-initializer-javascript/) tool to create a citation file.
497
+
498
+
:::challenge
499
+
### Exercise: Create a CITATION.cff using cffinit
500
+
1. Follow [these steps to create a CITATION file with cffinit](https://book.the-turing-way.org/communication/citable/citable-cffinit).
501
+
1. Rename the created file to `CITATION.cff` and add it to the root folder of your repository.
502
+
1. Push your changes to feature branch and check your repository in GitHub. What has happened?
503
+
:::
504
+
505
+
461
506
## Choosing an Open Source Licence
462
507
463
508
Software licensing is a whole topic in itself, so we'll just summarise here.
@@ -512,27 +557,18 @@ If you want more information, or help choosing a licence,
512
557
the [Choose An Open-Source Licence](https://choosealicense.com/)
513
558
or [tl;dr Legal](https://tldrlegal.com/) sites can help.
514
559
515
-
::::::::::::::::::::::::::::::::::::::: challenge
516
-
517
-
## Exercise: Preparing for Release
518
560
519
-
In a (hopefully) highly unlikely and thoroughly unrecommended scenario,
520
-
your project leader has informed you of the need to release your software
521
-
within the next half hour,
522
-
so it can be assessed for use by another team.
523
-
You'll need to consider finishing the README,
524
-
choosing a licence,
525
-
and fixing any remaining problems you are aware of in your codebase.
526
-
Ensure you prioritise and work on the most pressing issues first!
Select a licence for your code using the tool above, save it as a file called `LICENSE` in the root of your repository.
563
+
Push your changes to your feature branch and check your repository in GitHub. What has happened?
564
+
:::
529
565
530
566
531
567
## Conforming to Data Policy and Regulation
532
568
533
569
We may also wish to make data available to either
534
570
be used with the software or as generated results.
535
-
This may be via GitHubor some other means.
571
+
This may be via some other means other than GitHub, such as Zenodo, Figshare, or an institutional repository.
536
572
An important aspect to remember with sharing data on such systems is that
537
573
they may reside in other countries,
538
574
and we must be careful depending on the nature of the data.
@@ -546,11 +582,19 @@ and even international policies and laws.
546
582
Within Europe, for example, there is the need to conform to things like [GDPR][gdpr].
547
583
it is a very good idea to make yourself aware of these aspects.
548
584
585
+
## Merge Your Changes to the Main Branch
586
+
587
+
After completing all the changes to improve the reusability of your code, you can first merge your feature branch to the `devlop` branch. Then merge the `develop` branch to the `main` branch.
549
588
589
+
In the next Section, we will look at how to release your Python project from the `main` branch
0 commit comments