Skip to content

Commit 4619d7a

Browse files
committed
add a section about example code
1 parent 7126a76 commit 4619d7a

File tree

1 file changed

+58
-24
lines changed

1 file changed

+58
-24
lines changed

README.md

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ An opinionated cookiecutter template to kickstart a modern best-practice Python
2020

2121
<!-- NOTE: For technical reasons, it is much easier to use GitHub
2222
for hosting the mindmap than adding it to the repository -->
23+
2324
![FAIR Software Mindmap](https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter/assets/371708/ef566ee1-8965-4d58-9ede-18eeb49a476e)
2425

25-
*Check out the
26+
_Check out the
2627
[demo repository](https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter-demo)
27-
generated from this template!*
28+
generated from this template!_
2829

2930
## Overview
3031

@@ -57,25 +58,25 @@ You can use it as is, adapt it, or at least get some inspiration for your projec
5758

5859
This template sets up a skeleton for a Python project that:
5960

60-
* uses modern state-of-the-art development tools
61-
* provides a baseline for professional development and maintenance
62-
* helps following best practices for code and metadata quality
63-
* contains detailed documentation on how to work with it
61+
- uses modern state-of-the-art development tools
62+
- provides a baseline for professional development and maintenance
63+
- helps following best practices for code and metadata quality
64+
- contains detailed documentation on how to work with it
6465

6566
It is built to help you adopting good practices
6667
and follow recommendations such as:
6768

68-
* [DLR Software Engineering Guidelines](https://rse.dlr.de/guidelines/00_dlr-se-guidelines_en.html)
69-
* [OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/en/criteria/0)
70-
* [Netherlands eScience Center](https://fair-software.eu)
71-
* innumerable other resources that can be found online
69+
- [DLR Software Engineering Guidelines](https://rse.dlr.de/guidelines/00_dlr-se-guidelines_en.html)
70+
- [OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/en/criteria/0)
71+
- [Netherlands eScience Center](https://fair-software.eu)
72+
- innumerable other resources that can be found online
7273

7374
Furthermore, it implements emerging standards with the goal to improve
7475
software metadata and make it more [FAIR](https://www.go-fair.org/fair-principles/):
7576

76-
* [REUSE](https://reuse.software/)
77-
* [CITATION.cff](https://citation-file-format.github.io/)
78-
* [CodeMeta](https://codemeta.github.io/)
77+
- [REUSE](https://reuse.software/)
78+
- [CITATION.cff](https://citation-file-format.github.io/)
79+
- [CodeMeta](https://codemeta.github.io/)
7980

8081
Also see [this paper](https://doi.org/10.48550/arXiv.1905.08674) for an overview and
8182
recommendations on the state of software citation in academic practice.
@@ -123,6 +124,39 @@ project contributors.
123124

124125
You can find a demo repository generated from this template [here](https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter-demo).
125126

127+
### Example Code
128+
129+
When you are creating your project, you are asked for several inputs. You can have an example CLI(Command Line Interface) and/or API(Application Programming interface) code within your new project.
130+
131+
Lets assume your project name is `my-awesome-project`.
132+
133+
You can run the CLI App with below command. For further usage, please check typer documentation.
134+
135+
```bash
136+
poetry shell
137+
138+
# Run your CLI App
139+
my-awesome-project-cli calculate add 5 2
140+
```
141+
142+
You can run the API App with below command.
143+
144+
```bash
145+
poetry shell
146+
147+
# Run the API program, it will be open for connection
148+
my-awesome-project-api
149+
```
150+
151+
Now, you can a tool to send a HTTP request for the API. You can open another terminal and run this command
152+
153+
```
154+
# send a request that does the same thing as the CLI
155+
curl 'http://localhost:8000/calculate/add?x=5&y=2'
156+
```
157+
158+
For further usage of the API, please check fastAPI documentation.
159+
126160
## Configuring the Template
127161

128162
If you intend to use the template a lot, e.g. if you want to use (an adaptation of)
@@ -132,14 +166,14 @@ Here is an example cookiecutter configuration:
132166

133167
```yaml
134168
fair_python_cookiecutter:
135-
last_name: "Carberry"
136-
first_name: "Josiah"
137-
project_keywords: "psychoceramics analytics"
138-
email: "josiah.carberry@brown.edu"
139-
orcid: "0000-0002-1825-0097"
140-
affiliation: "Brown University"
141-
copyright_holder: "Brown University"
142-
license: "MIT"
169+
last_name: 'Carberry'
170+
first_name: 'Josiah'
171+
project_keywords: 'psychoceramics analytics'
172+
email: 'josiah.carberry@brown.edu'
173+
orcid: '0000-0002-1825-0097'
174+
affiliation: 'Brown University'
175+
copyright_holder: 'Brown University'
176+
license: 'MIT'
143177
```
144178
145179
This information will be already pre-filled when you use the template,
@@ -176,9 +210,9 @@ moved into the `YOUR_PROJECT/src/YOUR_PACKAGE` subdirectory.
176210
On the other hand, if you already have a working setup that you do not wish to replace
177211
completely, you can take a look at
178212

179-
* the `.pre-commit-config.yaml` file to adopt some of the quality assurance tools listed there
180-
* the CI pipelines defined in `.github/workflows` or `.gitlab-ci.yml` for automated tests and releases
181-
* the `mkdocs.yml` and `docs/` subdirectory to see how the project website works
213+
- the `.pre-commit-config.yaml` file to adopt some of the quality assurance tools listed there
214+
- the CI pipelines defined in `.github/workflows` or `.gitlab-ci.yml` for automated tests and releases
215+
- the `mkdocs.yml` and `docs/` subdirectory to see how the project website works
182216

183217
<!-- --8<-- [end:quickstart] -->
184218

0 commit comments

Comments
 (0)