Skip to content

Commit

Permalink
Add CITATION.cff file with main contributors (#159)
Browse files Browse the repository at this point in the history
* Add CITATION.cff file with main contributors
* Add script to bump version in README.md and CITATION.cff
  • Loading branch information
YoniSchirris authored Oct 11, 2023
1 parent c330a36 commit f5ff67d
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .dev/bump_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from datetime import datetime
from typing import Callable, Dict
import re

citation_regex = lambda new_date, content: re.sub(
r"date-released: \d{4}-\d{2}-\d{2}", f"date-released: {new_date}", content
)

readme_regexes = {
"bibtex_year": lambda year, content: re.sub(r"\{\d{4}\}", str(year), content), # {2023} in bibtex
"bibtex_month": lambda month, content: re.sub(r"\{\d{1,2}\}", str(month), content), # {5} or {12} in bibtex
"plain_bib_year": lambda year, content: re.sub(r"(\d{4})", str(year), content), # (2023) in the plain bibliography
}


def bump_citation_file(
new_date: str,
filename: str = "CITATION.cff",
regex_function: Callable = citation_regex,
) -> None:
"""
Runs a specific regex function on the defined citation file
"""
with open(filename, "r") as f:
content = f.read()

with open(filename, "w") as f:
content = regex_function(new_date, content)
f.write(content)


def bump_readme_file(
year: str,
month: str,
regex_functions: Dict[str, Callable] = readme_regexes,
filename: str = "README.md",
) -> None:
"""
Runs the required regex functions on the README file
"""
with open(filename, "r") as f:
content = f.read()

with open(filename, "w") as f:
content = regex_functions["bibtex_year"](year, content)
content = regex_functions["bibtex_month"](month, content)
content = regex_functions["plain_bib_year"](year, content)
f.write(content)


def bump_date() -> None:
"""
A developer function to bump the date when a version is bumped.
Run after bump2version is run, since bump2version doesn't allow updating
the date in e.g. README.md and CITATION.cff.
"""
new_date = datetime.now().strftime("%Y-%m-%d")
year = str(datetime.now().year)
month = str(datetime.now().month)

bump_citation_file(new_date=new_date)
bump_readme_file(year=year, month=month)


if __name__ == "__main__":
bump_date()
21 changes: 21 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Teuwen"
given-names: "Jonas"
orcid: "https://orcid.org/0000-0002-1825-1428"
- family-names: "Romor"
given-names: "Leonardo"
- family-names: "Pai"
given-names: "Ajey"
orcid: "https://orcid.org/0009-0003-3970-9236"
- family-names: "Schirris"
given-names: "Yoni"
orcid: "https://orcid.org/0000-0003-0217-8737"
- family-names: "Marcus"
given-names: "Eric"
orchid: "https://orcid.org/0000-0002-3375-6248"
title: "DLUP: Deep Learning Utilities for Pathology"
version: 0.3.29
date-released: 2023-10-10
url: "https://github.com/nki-ai/dlup"
1 change: 1 addition & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Make sure all your changes are committed. Then run:
.. code-block:: console
$ bump2version patch # possible: major / minor / patch
$ python .dev/bump_date.py
$ git push
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,23 @@ The package can be installed using `python -m pip install dlup`.

## Used by
- [ahcore](https://github.com/NKI-AI/ahcore.git): a pytorch lightning based-library for computational pathology

## Citing DLUP
If you use DLUP in your own research, please use the following BiBTeX entry:

```
@software{dlup,
author = {Teuwen, J., Romor, L., Pai, A., Schirris, Y., Marcus, E.},
month = {5},
title = {{DLUP: Deep Learning Utilities for Pathology}},
url = {https://github.com/nki-ai/dlup},
version = {0.3.29},
year = {2023}
}
```

or the following plain bibliography:

```
Teuwen, J., Romor, L., Pai, A., Schirris, Y., Marcus E. (2023). DLUP: Deep Learning Utilities for Pathology (Version 0.3.29) [Computer software]. https://github.com/nki-ai/dlup
```
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ values =
search = {current_version}
replace = {new_version}

[bumpversion:file:README.md]
search = {current_version}
replace = {new_version}

[bumpversion:file:CITATION.cff]
search = {current_version}
replace = {new_version}

[aliases]
test = pytest

Expand Down

0 comments on commit f5ff67d

Please sign in to comment.