oe-python-template-example 0.2.6__tar.gz → 0.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {oe_python_template_example-0.2.6 → oe_python_template_example-0.2.7}/PKG-INFO +80 -57
- {oe_python_template_example-0.2.6 → oe_python_template_example-0.2.7}/README.md +79 -56
- {oe_python_template_example-0.2.6 → oe_python_template_example-0.2.7}/pyproject.toml +15 -4
- {oe_python_template_example-0.2.6 → oe_python_template_example-0.2.7}/src/oe_python_template_example/__init__.py +5 -0
- {oe_python_template_example-0.2.6 → oe_python_template_example-0.2.7}/src/oe_python_template_example/api.py +17 -75
- {oe_python_template_example-0.2.6 → oe_python_template_example-0.2.7}/src/oe_python_template_example/cli.py +4 -3
- oe_python_template_example-0.2.7/src/oe_python_template_example/models.py +44 -0
- {oe_python_template_example-0.2.6 → oe_python_template_example-0.2.7}/src/oe_python_template_example/service.py +19 -1
- oe_python_template_example-0.2.6/.act-env-public +0 -1
- oe_python_template_example-0.2.6/.copier-answers.yml +0 -23
- oe_python_template_example-0.2.6/.devcontainer/Dockerfile +0 -7
- oe_python_template_example-0.2.6/.devcontainer/devcontainer.json +0 -51
- oe_python_template_example-0.2.6/.devcontainer/onCreateCommand +0 -9
- oe_python_template_example-0.2.6/.devcontainer/postAttachCommand +0 -4
- oe_python_template_example-0.2.6/.devcontainer/postCreateCommand +0 -4
- oe_python_template_example-0.2.6/.env.example +0 -1
- oe_python_template_example-0.2.6/.github/copilot-instructions.md +0 -5
- oe_python_template_example-0.2.6/.github/dependabot.yml +0 -13
- oe_python_template_example-0.2.6/.github/workflows/codeql.yml +0 -100
- oe_python_template_example-0.2.6/.github/workflows/docker-image-build-publish.yml +0 -93
- oe_python_template_example-0.2.6/.github/workflows/package-build-publish-release.yml +0 -63
- oe_python_template_example-0.2.6/.github/workflows/test-and-report.yml +0 -113
- oe_python_template_example-0.2.6/.pre-commit-config.yaml +0 -76
- oe_python_template_example-0.2.6/.python-version +0 -1
- oe_python_template_example-0.2.6/.readthedocs.yml +0 -36
- oe_python_template_example-0.2.6/.secrets.baseline +0 -127
- oe_python_template_example-0.2.6/.vscode/extensions.json +0 -27
- oe_python_template_example-0.2.6/.vscode/settings.json +0 -76
- oe_python_template_example-0.2.6/CHANGELOG.md +0 -67
- oe_python_template_example-0.2.6/CODEOWNERS +0 -3
- oe_python_template_example-0.2.6/CODE_STYLE.md +0 -284
- oe_python_template_example-0.2.6/CONTRIBUTING.md +0 -155
- oe_python_template_example-0.2.6/Dockerfile +0 -42
- oe_python_template_example-0.2.6/RELEASE_NOTES.md +0 -1
- oe_python_template_example-0.2.6/SECURITY.md +0 -59
- oe_python_template_example-0.2.6/SERVICE_CONNECTIONS.md +0 -85
- oe_python_template_example-0.2.6/VERSION +0 -1
- oe_python_template_example-0.2.6/bin/git-cliff +0 -0
- oe_python_template_example-0.2.6/codecov.yml +0 -11
- oe_python_template_example-0.2.6/compose.yaml +0 -35
- oe_python_template_example-0.2.6/docs/Makefile +0 -20
- oe_python_template_example-0.2.6/docs/make.bat +0 -35
- oe_python_template_example-0.2.6/docs/partials/README_footer.md +0 -15
- oe_python_template_example-0.2.6/docs/partials/README_header.md +0 -40
- oe_python_template_example-0.2.6/docs/partials/README_main.md +0 -313
- oe_python_template_example-0.2.6/docs/source/_static/.keep +0 -0
- oe_python_template_example-0.2.6/docs/source/_static/openapi.json +0 -262
- oe_python_template_example-0.2.6/docs/source/_static/openapi.yaml +0 -210
- oe_python_template_example-0.2.6/docs/source/_static/openapi_v1.json +0 -262
- oe_python_template_example-0.2.6/docs/source/_static/openapi_v1.yaml +0 -204
- oe_python_template_example-0.2.6/docs/source/_static/openapi_v2.json +0 -262
- oe_python_template_example-0.2.6/docs/source/_static/openapi_v2.yaml +0 -204
- oe_python_template_example-0.2.6/docs/source/api_v1.rst +0 -9
- oe_python_template_example-0.2.6/docs/source/api_v2.rst +0 -9
- oe_python_template_example-0.2.6/docs/source/code-style.rst +0 -1
- oe_python_template_example-0.2.6/docs/source/conf.py +0 -128
- oe_python_template_example-0.2.6/docs/source/contributing.rst +0 -1
- oe_python_template_example-0.2.6/docs/source/index.rst +0 -40
- oe_python_template_example-0.2.6/docs/source/main.rst +0 -1
- oe_python_template_example-0.2.6/docs/source/reference.rst +0 -5
- oe_python_template_example-0.2.6/docs/source/release-notes.rst +0 -4
- oe_python_template_example-0.2.6/docs/source/security.rst +0 -1
- oe_python_template_example-0.2.6/examples/__init__.py +0 -1
- oe_python_template_example-0.2.6/examples/notebook.ipynb +0 -46
- oe_python_template_example-0.2.6/examples/notebook.py +0 -18
- oe_python_template_example-0.2.6/examples/script.py +0 -13
- oe_python_template_example-0.2.6/examples/streamlit.py +0 -30
- oe_python_template_example-0.2.6/git-cliff-2.7.0/CHANGELOG.md +0 -1513
- oe_python_template_example-0.2.6/git-cliff-2.7.0/LICENSE-APACHE +0 -176
- oe_python_template_example-0.2.6/git-cliff-2.7.0/LICENSE-MIT +0 -22
- oe_python_template_example-0.2.6/git-cliff-2.7.0/README.md +0 -95
- oe_python_template_example-0.2.6/git-cliff-2.7.0/completions/_git-cliff +0 -86
- oe_python_template_example-0.2.6/git-cliff-2.7.0/completions/_git-cliff.ps1 +0 -84
- oe_python_template_example-0.2.6/git-cliff-2.7.0/completions/git-cliff.bash +0 -190
- oe_python_template_example-0.2.6/git-cliff-2.7.0/completions/git-cliff.elv +0 -78
- oe_python_template_example-0.2.6/git-cliff-2.7.0/completions/git-cliff.fish +0 -39
- oe_python_template_example-0.2.6/git-cliff-2.7.0/git-cliff-completions +0 -0
- oe_python_template_example-0.2.6/git-cliff-2.7.0/git-cliff-mangen +0 -0
- oe_python_template_example-0.2.6/git-cliff-2.7.0/man/git-cliff.1 +0 -214
- oe_python_template_example-0.2.6/git-cliff-2.7.0-x86_64-unknown-linux-gnu.tar.gz +0 -0
- oe_python_template_example-0.2.6/github-action-run +0 -5
- oe_python_template_example-0.2.6/logo.png +0 -0
- oe_python_template_example-0.2.6/n +0 -28
- oe_python_template_example-0.2.6/noxfile.py +0 -235
- oe_python_template_example-0.2.6/renovate.json +0 -9
- oe_python_template_example-0.2.6/reports/.keep +0 -0
- oe_python_template_example-0.2.6/sonar-project.properties +0 -12
- oe_python_template_example-0.2.6/tests/__init__.py +0 -1
- oe_python_template_example-0.2.6/tests/api_test.py +0 -132
- oe_python_template_example-0.2.6/tests/cli_test.py +0 -86
- oe_python_template_example-0.2.6/tests/fixtures/.keep +0 -0
- oe_python_template_example-0.2.6/uv.lock +0 -4296
- {oe_python_template_example-0.2.6 → oe_python_template_example-0.2.7}/.gitignore +0 -0
- {oe_python_template_example-0.2.6 → oe_python_template_example-0.2.7}/LICENSE +0 -0
- {oe_python_template_example-0.2.6 → oe_python_template_example-0.2.7}/src/oe_python_template_example/constants.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: oe-python-template-example
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.7
|
4
4
|
Summary: 🧠 Example project scaffolded and kept up to date with OE Python Template (oe-python-template).
|
5
5
|
Project-URL: Homepage, https://oe-python-template-example.readthedocs.io/en/latest/
|
6
6
|
Project-URL: Documentation, https://oe-python-template-example.readthedocs.io/en/latest/
|
@@ -106,36 +106,44 @@ Description-Content-Type: text/markdown
|
|
106
106
|
|
107
107
|
Example project scaffolded and kept up to date with OE Python Template (oe-python-template).
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
1.
|
114
|
-
2.
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
109
|
+
### Scaffolding
|
110
|
+
|
111
|
+
This [Copier](https://copier.readthedocs.io/en/stable/) template enables you to quickly generate (scaffold) a Python package with fully functioning build and test automation:
|
112
|
+
|
113
|
+
1. Projects generated from this template can be [easily updated](https://copier.readthedocs.io/en/stable/updating/) to benefit from improvements and new features of the template.
|
114
|
+
2. During project generation, you can flexibly configure naming of the Python distribution, import package, main author, GitHub repository, organization, and many other aspects to match your specific requirements (see [copier.yml](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template/blob/main/copier.yml) for all available options).
|
115
|
+
|
116
|
+
### Development Infrastructure
|
117
|
+
|
118
|
+
Projects generated with this template come with a comprehensive development toolchain and quality assurance framework that supports the entire software development lifecycle - from coding and testing to documentation, release management, and compliance auditing. This infrastructure automates routine tasks, enforces code quality standards, and streamlines the path to production:
|
119
|
+
|
120
|
+
1. Linting with [Ruff](https://github.com/astral-sh/ruff)
|
121
|
+
2. Static type checking with [mypy](https://mypy.readthedocs.io/en/stable/)
|
122
|
+
3. Complete set of [pre-commit](https://pre-commit.com/) hooks including [detect-secrets](https://github.com/Yelp/detect-secrets) and [pygrep](https://github.com/pre-commit/pygrep-hooks)
|
123
|
+
4. Unit and E2E testing with [pytest](https://docs.pytest.org/en/stable/) including parallel test execution
|
124
|
+
5. Matrix testing in multiple environments with [nox](https://nox.thea.codes/en/stable/)
|
125
|
+
6. Test coverage reported with [Codecov](https://codecov.io/) and published as release artifact
|
126
|
+
7. CI/CD pipeline automated with [GitHub Actions](https://github.com/features/actions)
|
127
|
+
8. CI/CD pipeline can be run locally with [act](https://github.com/nektos/act)
|
128
|
+
9. Code quality and security checks with [SonarQube](https://www.sonarsource.com/products/sonarcloud) and [GitHub CodeQL](https://codeql.github.com/)
|
129
|
+
10. Dependency monitoring with [pip-audit](https://pypi.org/project/pip-audit/), [Renovate](https://github.com/renovatebot/renovate), and [GitHub Dependabot](https://docs.github.com/en/code-security/getting-started/dependabot-quickstart-guide)
|
130
|
+
11. Licenses of dependencies extracted with [pip-licenses](https://pypi.org/project/pip-licenses/) and published as release artifacts in CSV and JSON format for compliance checks
|
131
|
+
12. Software Bill of Materials (SBOM) generated with [cyclonedx-python](https://github.com/CycloneDX/cyclonedx-python) and published as release artifact
|
132
|
+
13. Version and release management with [bump-my-version](https://callowayproject.github.io/bump-my-version/)
|
133
|
+
14. Changelog and release notes generated with [git-cliff](https://git-cliff.org/)
|
134
|
+
15. Documentation generated with [Sphinx](https://www.sphinx-doc.org/en/master/) including reference documentation and PDF export
|
135
|
+
16. Documentation published to [Read The Docs](https://readthedocs.org/)
|
136
|
+
17. Interactive OpenAPI specification with [Swagger](https://swagger.io/)
|
137
|
+
18. Python package published to [PyPI](https://pypi.org/)
|
138
|
+
19. Docker images published to [Docker.io](https://hub.docker.com/) and [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) with [artifact attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds)
|
139
|
+
20. One-click development environments with [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) and [GitHub Codespaces](https://github.com/features/codespaces)
|
140
|
+
21. Settings for use with [VSCode](https://code.visualstudio.com/)
|
141
|
+
22. Settings and custom instructions for use with [GitHub Copilot](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot)
|
142
|
+
|
143
|
+
### Application Features
|
144
|
+
|
145
|
+
Beyond development tooling, projects generated with this template include the code, documentation, and configuration of a fully functioning demo application and service. This reference implementation serves as a starting point for your own business logic with modern patterns and practices already in place:
|
146
|
+
|
139
147
|
1. Service architecture suitable for use as shared library
|
140
148
|
2. Validation with [pydantic](https://docs.pydantic.dev/)
|
141
149
|
3. Command-line interface (CLI) with [Typer](https://typer.tiangolo.com/)
|
@@ -149,52 +157,48 @@ Explore [here](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-templ
|
|
149
157
|
|
150
158
|
## Generate a new project
|
151
159
|
|
152
|
-
|
153
|
-
To generate a new project, follow these steps:
|
160
|
+
To generate, build and release a fully functioning project in a few minutes, follow these 5 steps:
|
154
161
|
|
155
|
-
**Step 1**:
|
162
|
+
**Step 1**: Execute the following command to install or update tooling.
|
156
163
|
```shell
|
157
|
-
|
158
|
-
|
159
|
-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
160
|
-
fi
|
161
|
-
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then # Install dependencies for Linux
|
162
|
-
sudo apt-get update -y && sudo apt-get install curl -y # Install curl
|
163
|
-
fi
|
164
|
-
if ! command -v uvx &> /dev/null; then # Install uv package manager if not present
|
165
|
-
curl -LsSf https://astral.sh/uv/install.sh | sh
|
166
|
-
source $HOME/.local/bin/env
|
167
|
-
fi
|
168
|
-
uv tool install copier # Install copier as global tool
|
164
|
+
# Install Homebrew, uv package manager, copier and further dev tools
|
165
|
+
curl -LsSf https://raw.githubusercontent.com/helmut-hoffer-von-ankershoffen/oe-python-template/HEAD/install.sh | sh
|
169
166
|
```
|
170
167
|
|
171
|
-
**Step 2**: [Create
|
168
|
+
**Step 2**: [Create a repository on GitHub](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-new-repository), clone to your local machine, and change into it's directory.
|
172
169
|
|
173
|
-
**Step 3**:
|
170
|
+
**Step 3**: Execute the following command to generate a new project based on this template.
|
174
171
|
```shell
|
172
|
+
# Ensure to stand in your freshly created git repository before executing this command
|
175
173
|
copier copy --trust gh:helmut-hoffer-von-ankershoffen/oe-python-template .
|
176
174
|
```
|
177
175
|
|
178
|
-
**Step 4**:
|
176
|
+
**Step 4**: Execute the following commands to push your initial commit to GitHub.
|
179
177
|
```shell
|
180
178
|
git add .
|
181
|
-
git commit -m "
|
179
|
+
git commit -m "chore: Initial commit"
|
182
180
|
git push
|
183
181
|
```
|
184
182
|
|
185
|
-
|
183
|
+
Check the [Actions tab](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/actions) of your GitHub repository: The CI/CD workflow of your project is already running!
|
184
|
+
|
185
|
+
The workflow will fail at the SonarQube step, as this external service is not yet configured for our new repository. We will configure SonarQube and other services in the next step!
|
186
|
+
|
187
|
+
Notes:
|
188
|
+
1. Check out [this manual](https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key) on how to set up signed commits
|
186
189
|
|
187
190
|
**Step 5**: Follow the [instructions](SERVICE_CONNECTIONS.md) to wire up
|
188
191
|
external services such as CloudCov, SonarQube Cloud, Read The Docs, Docker.io, and Streamlit Community Cloud.
|
189
192
|
|
190
|
-
**Step 6**: Release the first
|
193
|
+
**Step 6**: Release the first version of your project
|
191
194
|
```shell
|
192
|
-
|
195
|
+
make bump
|
193
196
|
```
|
194
197
|
Notes:
|
195
|
-
1. You can remove this
|
196
|
-
2. The following sections refer to the dummy application and service
|
197
|
-
Use
|
198
|
+
1. You can remove the above sections - from "Scaffolding" to this notes - post having successfully generated your project.
|
199
|
+
2. The following sections refer to the dummy application and service generated into the `tests` and `src` folder by this template.
|
200
|
+
Use the documentation and code as inspiration, adapt to your business logic, or remove and start documenting and coding from scratch.
|
201
|
+
|
198
202
|
|
199
203
|
## Overview
|
200
204
|
|
@@ -407,11 +411,30 @@ docker compose run oe-python-template-example echo "Lorem"
|
|
407
411
|
docker compose run oe-python-template-example echo "Lorem" --json
|
408
412
|
docker compose run oe-python-template-example openapi
|
409
413
|
docker compose run oe-python-template-example openapi --output-format=json
|
410
|
-
|
414
|
+
echo "Running OE Python Template Example's API container as a daemon ..."
|
415
|
+
docker compose up -d
|
416
|
+
echo "Waiting for the API server to start ..."
|
417
|
+
sleep 5
|
418
|
+
echo "Checking health of v1 API ..."
|
419
|
+
curl http://127.0.0.1:8000/api/v1/healthz
|
420
|
+
echo ""
|
421
|
+
echo "Saying hello world with v1 API ..."
|
411
422
|
curl http://127.0.0.1:8000/api/v1/hello-world
|
423
|
+
echo ""
|
424
|
+
echo "Swagger docs of v1 API ..."
|
412
425
|
curl http://127.0.0.1:8000/api/v1/docs
|
426
|
+
echo ""
|
427
|
+
echo "Checking health of v2 API ..."
|
428
|
+
curl http://127.0.0.1:8000/api/v2/healthz
|
429
|
+
echo ""
|
430
|
+
echo "Saying hello world with v1 API ..."
|
413
431
|
curl http://127.0.0.1:8000/api/v2/hello-world
|
432
|
+
echo ""
|
433
|
+
echo "Swagger docs of v2 API ..."
|
414
434
|
curl http://127.0.0.1:8000/api/v2/docs
|
435
|
+
echo ""
|
436
|
+
echo "Shutting down the API container ..."
|
437
|
+
docker compose down
|
415
438
|
```
|
416
439
|
|
417
440
|
## Extra: Lorem Ipsum
|
@@ -45,36 +45,44 @@
|
|
45
45
|
|
46
46
|
Example project scaffolded and kept up to date with OE Python Template (oe-python-template).
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
1.
|
53
|
-
2.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
48
|
+
### Scaffolding
|
49
|
+
|
50
|
+
This [Copier](https://copier.readthedocs.io/en/stable/) template enables you to quickly generate (scaffold) a Python package with fully functioning build and test automation:
|
51
|
+
|
52
|
+
1. Projects generated from this template can be [easily updated](https://copier.readthedocs.io/en/stable/updating/) to benefit from improvements and new features of the template.
|
53
|
+
2. During project generation, you can flexibly configure naming of the Python distribution, import package, main author, GitHub repository, organization, and many other aspects to match your specific requirements (see [copier.yml](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template/blob/main/copier.yml) for all available options).
|
54
|
+
|
55
|
+
### Development Infrastructure
|
56
|
+
|
57
|
+
Projects generated with this template come with a comprehensive development toolchain and quality assurance framework that supports the entire software development lifecycle - from coding and testing to documentation, release management, and compliance auditing. This infrastructure automates routine tasks, enforces code quality standards, and streamlines the path to production:
|
58
|
+
|
59
|
+
1. Linting with [Ruff](https://github.com/astral-sh/ruff)
|
60
|
+
2. Static type checking with [mypy](https://mypy.readthedocs.io/en/stable/)
|
61
|
+
3. Complete set of [pre-commit](https://pre-commit.com/) hooks including [detect-secrets](https://github.com/Yelp/detect-secrets) and [pygrep](https://github.com/pre-commit/pygrep-hooks)
|
62
|
+
4. Unit and E2E testing with [pytest](https://docs.pytest.org/en/stable/) including parallel test execution
|
63
|
+
5. Matrix testing in multiple environments with [nox](https://nox.thea.codes/en/stable/)
|
64
|
+
6. Test coverage reported with [Codecov](https://codecov.io/) and published as release artifact
|
65
|
+
7. CI/CD pipeline automated with [GitHub Actions](https://github.com/features/actions)
|
66
|
+
8. CI/CD pipeline can be run locally with [act](https://github.com/nektos/act)
|
67
|
+
9. Code quality and security checks with [SonarQube](https://www.sonarsource.com/products/sonarcloud) and [GitHub CodeQL](https://codeql.github.com/)
|
68
|
+
10. Dependency monitoring with [pip-audit](https://pypi.org/project/pip-audit/), [Renovate](https://github.com/renovatebot/renovate), and [GitHub Dependabot](https://docs.github.com/en/code-security/getting-started/dependabot-quickstart-guide)
|
69
|
+
11. Licenses of dependencies extracted with [pip-licenses](https://pypi.org/project/pip-licenses/) and published as release artifacts in CSV and JSON format for compliance checks
|
70
|
+
12. Software Bill of Materials (SBOM) generated with [cyclonedx-python](https://github.com/CycloneDX/cyclonedx-python) and published as release artifact
|
71
|
+
13. Version and release management with [bump-my-version](https://callowayproject.github.io/bump-my-version/)
|
72
|
+
14. Changelog and release notes generated with [git-cliff](https://git-cliff.org/)
|
73
|
+
15. Documentation generated with [Sphinx](https://www.sphinx-doc.org/en/master/) including reference documentation and PDF export
|
74
|
+
16. Documentation published to [Read The Docs](https://readthedocs.org/)
|
75
|
+
17. Interactive OpenAPI specification with [Swagger](https://swagger.io/)
|
76
|
+
18. Python package published to [PyPI](https://pypi.org/)
|
77
|
+
19. Docker images published to [Docker.io](https://hub.docker.com/) and [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) with [artifact attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds)
|
78
|
+
20. One-click development environments with [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) and [GitHub Codespaces](https://github.com/features/codespaces)
|
79
|
+
21. Settings for use with [VSCode](https://code.visualstudio.com/)
|
80
|
+
22. Settings and custom instructions for use with [GitHub Copilot](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot)
|
81
|
+
|
82
|
+
### Application Features
|
83
|
+
|
84
|
+
Beyond development tooling, projects generated with this template include the code, documentation, and configuration of a fully functioning demo application and service. This reference implementation serves as a starting point for your own business logic with modern patterns and practices already in place:
|
85
|
+
|
78
86
|
1. Service architecture suitable for use as shared library
|
79
87
|
2. Validation with [pydantic](https://docs.pydantic.dev/)
|
80
88
|
3. Command-line interface (CLI) with [Typer](https://typer.tiangolo.com/)
|
@@ -88,52 +96,48 @@ Explore [here](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-templ
|
|
88
96
|
|
89
97
|
## Generate a new project
|
90
98
|
|
91
|
-
|
92
|
-
To generate a new project, follow these steps:
|
99
|
+
To generate, build and release a fully functioning project in a few minutes, follow these 5 steps:
|
93
100
|
|
94
|
-
**Step 1**:
|
101
|
+
**Step 1**: Execute the following command to install or update tooling.
|
95
102
|
```shell
|
96
|
-
|
97
|
-
|
98
|
-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
99
|
-
fi
|
100
|
-
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then # Install dependencies for Linux
|
101
|
-
sudo apt-get update -y && sudo apt-get install curl -y # Install curl
|
102
|
-
fi
|
103
|
-
if ! command -v uvx &> /dev/null; then # Install uv package manager if not present
|
104
|
-
curl -LsSf https://astral.sh/uv/install.sh | sh
|
105
|
-
source $HOME/.local/bin/env
|
106
|
-
fi
|
107
|
-
uv tool install copier # Install copier as global tool
|
103
|
+
# Install Homebrew, uv package manager, copier and further dev tools
|
104
|
+
curl -LsSf https://raw.githubusercontent.com/helmut-hoffer-von-ankershoffen/oe-python-template/HEAD/install.sh | sh
|
108
105
|
```
|
109
106
|
|
110
|
-
**Step 2**: [Create
|
107
|
+
**Step 2**: [Create a repository on GitHub](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-new-repository), clone to your local machine, and change into it's directory.
|
111
108
|
|
112
|
-
**Step 3**:
|
109
|
+
**Step 3**: Execute the following command to generate a new project based on this template.
|
113
110
|
```shell
|
111
|
+
# Ensure to stand in your freshly created git repository before executing this command
|
114
112
|
copier copy --trust gh:helmut-hoffer-von-ankershoffen/oe-python-template .
|
115
113
|
```
|
116
114
|
|
117
|
-
**Step 4**:
|
115
|
+
**Step 4**: Execute the following commands to push your initial commit to GitHub.
|
118
116
|
```shell
|
119
117
|
git add .
|
120
|
-
git commit -m "
|
118
|
+
git commit -m "chore: Initial commit"
|
121
119
|
git push
|
122
120
|
```
|
123
121
|
|
124
|
-
|
122
|
+
Check the [Actions tab](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/actions) of your GitHub repository: The CI/CD workflow of your project is already running!
|
123
|
+
|
124
|
+
The workflow will fail at the SonarQube step, as this external service is not yet configured for our new repository. We will configure SonarQube and other services in the next step!
|
125
|
+
|
126
|
+
Notes:
|
127
|
+
1. Check out [this manual](https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key) on how to set up signed commits
|
125
128
|
|
126
129
|
**Step 5**: Follow the [instructions](SERVICE_CONNECTIONS.md) to wire up
|
127
130
|
external services such as CloudCov, SonarQube Cloud, Read The Docs, Docker.io, and Streamlit Community Cloud.
|
128
131
|
|
129
|
-
**Step 6**: Release the first
|
132
|
+
**Step 6**: Release the first version of your project
|
130
133
|
```shell
|
131
|
-
|
134
|
+
make bump
|
132
135
|
```
|
133
136
|
Notes:
|
134
|
-
1. You can remove this
|
135
|
-
2. The following sections refer to the dummy application and service
|
136
|
-
Use
|
137
|
+
1. You can remove the above sections - from "Scaffolding" to this notes - post having successfully generated your project.
|
138
|
+
2. The following sections refer to the dummy application and service generated into the `tests` and `src` folder by this template.
|
139
|
+
Use the documentation and code as inspiration, adapt to your business logic, or remove and start documenting and coding from scratch.
|
140
|
+
|
137
141
|
|
138
142
|
## Overview
|
139
143
|
|
@@ -346,11 +350,30 @@ docker compose run oe-python-template-example echo "Lorem"
|
|
346
350
|
docker compose run oe-python-template-example echo "Lorem" --json
|
347
351
|
docker compose run oe-python-template-example openapi
|
348
352
|
docker compose run oe-python-template-example openapi --output-format=json
|
349
|
-
|
353
|
+
echo "Running OE Python Template Example's API container as a daemon ..."
|
354
|
+
docker compose up -d
|
355
|
+
echo "Waiting for the API server to start ..."
|
356
|
+
sleep 5
|
357
|
+
echo "Checking health of v1 API ..."
|
358
|
+
curl http://127.0.0.1:8000/api/v1/healthz
|
359
|
+
echo ""
|
360
|
+
echo "Saying hello world with v1 API ..."
|
350
361
|
curl http://127.0.0.1:8000/api/v1/hello-world
|
362
|
+
echo ""
|
363
|
+
echo "Swagger docs of v1 API ..."
|
351
364
|
curl http://127.0.0.1:8000/api/v1/docs
|
365
|
+
echo ""
|
366
|
+
echo "Checking health of v2 API ..."
|
367
|
+
curl http://127.0.0.1:8000/api/v2/healthz
|
368
|
+
echo ""
|
369
|
+
echo "Saying hello world with v1 API ..."
|
352
370
|
curl http://127.0.0.1:8000/api/v2/hello-world
|
371
|
+
echo ""
|
372
|
+
echo "Swagger docs of v2 API ..."
|
353
373
|
curl http://127.0.0.1:8000/api/v2/docs
|
374
|
+
echo ""
|
375
|
+
echo "Shutting down the API container ..."
|
376
|
+
docker compose down
|
354
377
|
```
|
355
378
|
|
356
379
|
## Extra: Lorem Ipsum
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "oe-python-template-example"
|
3
|
-
version = "0.2.
|
3
|
+
version = "0.2.7"
|
4
4
|
description = "🧠 Example project scaffolded and kept up to date with OE Python Template (oe-python-template)."
|
5
5
|
readme = "README.md"
|
6
6
|
authors = [
|
@@ -79,9 +79,15 @@ Changelog = "https://github.com/helmut-hoffer-von-ankershoffen/oe-python-templat
|
|
79
79
|
Issues = "https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/issues"
|
80
80
|
|
81
81
|
[build-system]
|
82
|
-
requires = ["hatchling"]
|
82
|
+
requires = ["hatchling==1.27.0"]
|
83
83
|
build-backend = "hatchling.build"
|
84
84
|
|
85
|
+
[tool.hatch.build]
|
86
|
+
include = ["src/*"]
|
87
|
+
|
88
|
+
[tool.hatch.build.targets.wheel]
|
89
|
+
packages = ["src/oe_python_template_example"]
|
90
|
+
|
85
91
|
[project.optional-dependencies]
|
86
92
|
examples = [
|
87
93
|
"streamlit>=1.43.2",
|
@@ -119,7 +125,6 @@ dev = [
|
|
119
125
|
"sphinx-copybutton>=0.5.2",
|
120
126
|
"sphinx-inline-tabs>=2023.4.21",
|
121
127
|
"sphinx-mdinclude>=0.6.2",
|
122
|
-
"sphinx-pydantic>=0.1.1",
|
123
128
|
"sphinx-rtd-theme>=3.0.2",
|
124
129
|
"sphinx_selective_exclude>=1.0.3",
|
125
130
|
"sphinx-toolbox>=3.9.0",
|
@@ -130,6 +135,12 @@ dev = [
|
|
130
135
|
"watchdog>=6.0.0",
|
131
136
|
]
|
132
137
|
|
138
|
+
[tool.uv]
|
139
|
+
override-dependencies = [ # https://github.com/astral-sh/uv/issues/4422
|
140
|
+
"rfc3987; sys_platform == 'never'", # GPLv3
|
141
|
+
]
|
142
|
+
|
143
|
+
|
133
144
|
[tool.ruff]
|
134
145
|
target-version = "py311"
|
135
146
|
preview = true
|
@@ -242,7 +253,7 @@ source = ["src/"]
|
|
242
253
|
|
243
254
|
|
244
255
|
[tool.bumpversion]
|
245
|
-
current_version = "0.2.
|
256
|
+
current_version = "0.2.7"
|
246
257
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
247
258
|
serialize = ["{major}.{minor}.{patch}"]
|
248
259
|
search = "{current_version}"
|
@@ -5,10 +5,15 @@ from .constants import (
|
|
5
5
|
__project_path__,
|
6
6
|
__version__,
|
7
7
|
)
|
8
|
+
from .models import Echo, Health, HealthStatus, Utterance
|
8
9
|
from .service import Service
|
9
10
|
|
10
11
|
__all__ = [
|
12
|
+
"Echo",
|
13
|
+
"Health",
|
14
|
+
"HealthStatus",
|
11
15
|
"Service",
|
16
|
+
"Utterance",
|
12
17
|
"__project_name__",
|
13
18
|
"__project_path__",
|
14
19
|
"__version__",
|
@@ -10,13 +10,12 @@ The endpoints use Pydantic models for request and response validation.
|
|
10
10
|
|
11
11
|
import os
|
12
12
|
from collections.abc import Generator
|
13
|
-
from enum import StrEnum
|
14
13
|
from typing import Annotated
|
15
14
|
|
16
15
|
from fastapi import Depends, FastAPI, Response, status
|
17
16
|
from pydantic import BaseModel, Field
|
18
17
|
|
19
|
-
from oe_python_template_example import Service
|
18
|
+
from oe_python_template_example import Echo, Health, HealthStatus, Service, Utterance
|
20
19
|
|
21
20
|
TITLE = "OE Python Template Example"
|
22
21
|
HELLO_WORLD_EXAMPLE = "Hello, world!"
|
@@ -94,30 +93,6 @@ api_v2 = FastAPI(
|
|
94
93
|
)
|
95
94
|
|
96
95
|
|
97
|
-
class _HealthStatus(StrEnum):
|
98
|
-
"""Health status enumeration."""
|
99
|
-
|
100
|
-
UP = "UP"
|
101
|
-
DOWN = "DOWN"
|
102
|
-
|
103
|
-
|
104
|
-
class Health(BaseModel):
|
105
|
-
"""Health status model."""
|
106
|
-
|
107
|
-
status: _HealthStatus
|
108
|
-
reason: str | None = None
|
109
|
-
|
110
|
-
|
111
|
-
class HealthResponse(BaseModel):
|
112
|
-
"""Response model for health endpoint."""
|
113
|
-
|
114
|
-
health: str = Field(
|
115
|
-
...,
|
116
|
-
description="The hello world message",
|
117
|
-
examples=[HELLO_WORLD_EXAMPLE],
|
118
|
-
)
|
119
|
-
|
120
|
-
|
121
96
|
@api_v1.get("/healthz", tags=["Observability"])
|
122
97
|
@api_v1.get("/health", tags=["Observability"])
|
123
98
|
@api_v2.get("/healthz", tags=["Observability"])
|
@@ -136,17 +111,17 @@ async def health(service: Annotated[Service, Depends(get_service)], response: Re
|
|
136
111
|
Health: The health status of the service.
|
137
112
|
"""
|
138
113
|
if service.healthy():
|
139
|
-
health_result = Health(status=
|
114
|
+
health_result = Health(status=HealthStatus.UP)
|
140
115
|
else:
|
141
|
-
health_result = Health(status=
|
116
|
+
health_result = Health(status=HealthStatus.DOWN, reason="Service is unhealthy")
|
142
117
|
|
143
|
-
if health_result.status ==
|
118
|
+
if health_result.status == HealthStatus.DOWN:
|
144
119
|
response.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
|
145
120
|
|
146
121
|
return health_result
|
147
122
|
|
148
123
|
|
149
|
-
class
|
124
|
+
class _HelloWorldResponse(BaseModel):
|
150
125
|
"""Response model for hello-world endpoint."""
|
151
126
|
|
152
127
|
message: str = Field(
|
@@ -158,81 +133,48 @@ class HelloWorldResponse(BaseModel):
|
|
158
133
|
|
159
134
|
@api_v1.get("/hello-world", tags=["Basics"])
|
160
135
|
@api_v2.get("/hello-world", tags=["Basics"])
|
161
|
-
async def hello_world() ->
|
136
|
+
async def hello_world() -> _HelloWorldResponse:
|
162
137
|
"""
|
163
138
|
Return a hello world message.
|
164
139
|
|
165
140
|
Returns:
|
166
|
-
|
141
|
+
_HelloWorldResponse: A response containing the hello world message.
|
167
142
|
"""
|
168
|
-
return
|
169
|
-
|
170
|
-
|
171
|
-
class EchoResponse(BaseModel):
|
172
|
-
"""Response model for echo endpoint."""
|
173
|
-
|
174
|
-
message: str = Field(
|
175
|
-
...,
|
176
|
-
min_length=1,
|
177
|
-
description="The message content",
|
178
|
-
examples=[HELLO_WORLD_EXAMPLE],
|
179
|
-
)
|
180
|
-
|
181
|
-
|
182
|
-
class EchoRequest(BaseModel):
|
183
|
-
"""Request model for echo endpoint."""
|
184
|
-
|
185
|
-
text: str = Field(
|
186
|
-
...,
|
187
|
-
min_length=1,
|
188
|
-
description="The text to echo back",
|
189
|
-
examples=[HELLO_WORLD_EXAMPLE],
|
190
|
-
)
|
143
|
+
return _HelloWorldResponse(message=Service.get_hello_world())
|
191
144
|
|
192
145
|
|
193
|
-
@api_v1.
|
194
|
-
async def echo(
|
146
|
+
@api_v1.get("/echo/{text}", tags=["Basics"])
|
147
|
+
async def echo(text: str) -> Echo:
|
195
148
|
"""
|
196
149
|
Echo back the provided text.
|
197
150
|
|
198
151
|
Args:
|
199
|
-
|
152
|
+
text (str): The text to echo.
|
200
153
|
|
201
154
|
Returns:
|
202
|
-
|
155
|
+
Echo: The echo.
|
203
156
|
|
204
157
|
Raises:
|
205
158
|
422 Unprocessable Entity: If text is not provided or empty.
|
206
159
|
"""
|
207
|
-
return
|
208
|
-
|
209
|
-
|
210
|
-
class Utterance(BaseModel):
|
211
|
-
"""Request model for echo endpoint."""
|
212
|
-
|
213
|
-
utterance: str = Field(
|
214
|
-
...,
|
215
|
-
min_length=1,
|
216
|
-
description="The utterance to echo back",
|
217
|
-
examples=[HELLO_WORLD_EXAMPLE],
|
218
|
-
)
|
160
|
+
return Service.echo(Utterance(text=text))
|
219
161
|
|
220
162
|
|
221
163
|
@api_v2.post("/echo", tags=["Basics"])
|
222
|
-
async def echo_v2(request: Utterance) ->
|
164
|
+
async def echo_v2(request: Utterance) -> Echo:
|
223
165
|
"""
|
224
166
|
Echo back the provided utterance.
|
225
167
|
|
226
168
|
Args:
|
227
|
-
request (Utterance): The
|
169
|
+
request (Utterance): The utterance to echo back.
|
228
170
|
|
229
171
|
Returns:
|
230
|
-
|
172
|
+
Echo: The echo.
|
231
173
|
|
232
174
|
Raises:
|
233
175
|
422 Unprocessable Entity: If utterance is not provided or empty.
|
234
176
|
"""
|
235
|
-
return
|
177
|
+
return Service.echo(request)
|
236
178
|
|
237
179
|
|
238
180
|
api.mount("/v1", api_v1)
|