oe-python-template-example 0.2.5__py3-none-any.whl → 0.2.7__py3-none-any.whl
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/__init__.py +5 -0
- oe_python_template_example/api.py +17 -75
- oe_python_template_example/cli.py +4 -3
- oe_python_template_example/models.py +44 -0
- oe_python_template_example/service.py +19 -1
- {oe_python_template_example-0.2.5.dist-info → oe_python_template_example-0.2.7.dist-info}/METADATA +144 -60
- oe_python_template_example-0.2.7.dist-info/RECORD +11 -0
- oe_python_template_example-0.2.5.dist-info/RECORD +0 -10
- {oe_python_template_example-0.2.5.dist-info → oe_python_template_example-0.2.7.dist-info}/WHEEL +0 -0
- {oe_python_template_example-0.2.5.dist-info → oe_python_template_example-0.2.7.dist-info}/entry_points.txt +0 -0
- {oe_python_template_example-0.2.5.dist-info → oe_python_template_example-0.2.7.dist-info}/licenses/LICENSE +0 -0
@@ -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)
|
@@ -9,7 +9,7 @@ import uvicorn
|
|
9
9
|
import yaml
|
10
10
|
from rich.console import Console
|
11
11
|
|
12
|
-
from oe_python_template_example import Service, __version__
|
12
|
+
from oe_python_template_example import Service, Utterance, __version__
|
13
13
|
from oe_python_template_example.api import api_v1, api_v2
|
14
14
|
|
15
15
|
console = Console()
|
@@ -30,10 +30,11 @@ def echo(
|
|
30
30
|
] = False,
|
31
31
|
) -> None:
|
32
32
|
"""Echo the text."""
|
33
|
+
echo = Service.echo(Utterance(text=text))
|
33
34
|
if json:
|
34
|
-
console.print_json(data={"text": text})
|
35
|
+
console.print_json(data={"text": echo.text})
|
35
36
|
else:
|
36
|
-
console.print(text)
|
37
|
+
console.print(echo.text)
|
37
38
|
|
38
39
|
|
39
40
|
@cli.command()
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"""Models used throughout OE Python Template Example's codebase ."""
|
2
|
+
|
3
|
+
from enum import StrEnum
|
4
|
+
|
5
|
+
from pydantic import BaseModel, Field
|
6
|
+
|
7
|
+
UTTERANCE_EXAMPLE = "Hello, world!"
|
8
|
+
ECHO_EXAMPLE = "HELLO, WORLD!"
|
9
|
+
|
10
|
+
|
11
|
+
class Utterance(BaseModel):
|
12
|
+
"""Model representing a text utterance."""
|
13
|
+
|
14
|
+
text: str = Field(
|
15
|
+
...,
|
16
|
+
min_length=1,
|
17
|
+
description="The utterance to echo back",
|
18
|
+
examples=[UTTERANCE_EXAMPLE],
|
19
|
+
)
|
20
|
+
|
21
|
+
|
22
|
+
class Echo(BaseModel):
|
23
|
+
"""Response model for echo endpoint."""
|
24
|
+
|
25
|
+
text: str = Field(
|
26
|
+
...,
|
27
|
+
min_length=1,
|
28
|
+
description="The echo",
|
29
|
+
examples=[ECHO_EXAMPLE],
|
30
|
+
)
|
31
|
+
|
32
|
+
|
33
|
+
class HealthStatus(StrEnum):
|
34
|
+
"""Health status enumeration."""
|
35
|
+
|
36
|
+
UP = "UP"
|
37
|
+
DOWN = "DOWN"
|
38
|
+
|
39
|
+
|
40
|
+
class Health(BaseModel):
|
41
|
+
"""Health status model."""
|
42
|
+
|
43
|
+
status: HealthStatus
|
44
|
+
reason: str | None = None
|
@@ -1,9 +1,11 @@
|
|
1
|
-
"""Service of OE Python Template Example."""
|
1
|
+
"""Service of OE Python Template Example's."""
|
2
2
|
|
3
3
|
import os
|
4
4
|
|
5
5
|
from dotenv import load_dotenv
|
6
6
|
|
7
|
+
from oe_python_template_example.models import Echo, Utterance
|
8
|
+
|
7
9
|
load_dotenv()
|
8
10
|
THE_VAR = os.getenv("THE_VAR", "not defined")
|
9
11
|
|
@@ -33,3 +35,19 @@ class Service:
|
|
33
35
|
bool: True if the service is healthy, False otherwise.
|
34
36
|
"""
|
35
37
|
return self.is_healthy
|
38
|
+
|
39
|
+
@staticmethod
|
40
|
+
def echo(utterance: Utterance) -> Echo:
|
41
|
+
"""
|
42
|
+
Loudly echo utterance.
|
43
|
+
|
44
|
+
Args:
|
45
|
+
utterance (Utterance): The utterance to echo.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
Echo: The loudly echoed utterance.
|
49
|
+
|
50
|
+
Raises:
|
51
|
+
ValueError: If the utterance is empty or contains only whitespace.
|
52
|
+
"""
|
53
|
+
return Echo(text=utterance.text.upper())
|
{oe_python_template_example-0.2.5.dist-info → oe_python_template_example-0.2.7.dist-info}/METADATA
RENAMED
@@ -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/
|
@@ -104,48 +104,130 @@ Description-Content-Type: text/markdown
|
|
104
104
|
---
|
105
105
|
|
106
106
|
|
107
|
-
Example project scaffolded and kept up to date with OE Python Template
|
108
|
-
(oe-python-template).
|
107
|
+
Example project scaffolded and kept up to date with OE Python Template (oe-python-template).
|
109
108
|
|
110
|
-
|
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
|
+
|
147
|
+
1. Service architecture suitable for use as shared library
|
148
|
+
2. Validation with [pydantic](https://docs.pydantic.dev/)
|
149
|
+
3. Command-line interface (CLI) with [Typer](https://typer.tiangolo.com/)
|
150
|
+
4. Versioned Web API with [FastAPI](https://fastapi.tiangolo.com/)
|
151
|
+
5. [Interactive Jupyter notebook](https://jupyter.org/) and [reactive Marimo notebook](https://marimo.io/)
|
152
|
+
6. Simple Web UI with [Streamlit](https://streamlit.io/)
|
153
|
+
7. Configuration to run the CLI and API in a Docker container including setup for [Docker Compose](https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-docker-compose/)
|
154
|
+
8. Documentation including badges, setup instructions, contribution guide and security policy
|
155
|
+
|
156
|
+
Explore [here](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example) for what's generated out of the box.
|
157
|
+
|
158
|
+
## Generate a new project
|
159
|
+
|
160
|
+
To generate, build and release a fully functioning project in a few minutes, follow these 5 steps:
|
161
|
+
|
162
|
+
**Step 1**: Execute the following command to install or update tooling.
|
163
|
+
```shell
|
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
|
166
|
+
```
|
167
|
+
|
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.
|
169
|
+
|
170
|
+
**Step 3**: Execute the following command to generate a new project based on this template.
|
171
|
+
```shell
|
172
|
+
# Ensure to stand in your freshly created git repository before executing this command
|
173
|
+
copier copy --trust gh:helmut-hoffer-von-ankershoffen/oe-python-template .
|
174
|
+
```
|
175
|
+
|
176
|
+
**Step 4**: Execute the following commands to push your initial commit to GitHub.
|
177
|
+
```shell
|
178
|
+
git add .
|
179
|
+
git commit -m "chore: Initial commit"
|
180
|
+
git push
|
181
|
+
```
|
182
|
+
|
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
|
189
|
+
|
190
|
+
**Step 5**: Follow the [instructions](SERVICE_CONNECTIONS.md) to wire up
|
191
|
+
external services such as CloudCov, SonarQube Cloud, Read The Docs, Docker.io, and Streamlit Community Cloud.
|
192
|
+
|
193
|
+
**Step 6**: Release the first version of your project
|
194
|
+
```shell
|
195
|
+
make bump
|
196
|
+
```
|
197
|
+
Notes:
|
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.
|
111
201
|
|
112
|
-
1. Dummy CLI application and service demonstrating example usage of the
|
113
|
-
directory structure and build pipeline generated by oe-python-template
|
114
202
|
|
115
203
|
## Overview
|
116
204
|
|
117
|
-
Adding OE Python Template Example to your project as a dependency is easy.
|
205
|
+
Adding OE Python Template Example to your project as a dependency is easy. See below for usage examples.
|
118
206
|
|
119
207
|
```shell
|
120
208
|
uv add oe-python-template-example # add dependency to your project
|
121
209
|
```
|
122
210
|
|
123
|
-
If you don't have uv installed follow
|
124
|
-
|
125
|
-
If you still prefer pip over the modern and fast package manager
|
126
|
-
[uv](https://github.com/astral-sh/uv), you can install the library like this:
|
211
|
+
If you don't have uv installed follow [these instructions](https://docs.astral.sh/uv/getting-started/installation/). If you still prefer pip over the modern and fast package manager [uv](https://github.com/astral-sh/uv), you can install the library like this:
|
212
|
+
|
127
213
|
|
128
214
|
```shell
|
129
215
|
pip install oe-python-template-example # add dependency to your project
|
130
216
|
```
|
131
217
|
|
132
|
-
Executing the command line interface (CLI) in an isolated Python environment is
|
133
|
-
just as easy:
|
218
|
+
Executing the command line interface (CLI) in an isolated Python environment is just as easy:
|
134
219
|
|
135
220
|
```shell
|
136
|
-
uvx oe-python-template-example hello-world
|
137
|
-
uvx oe-python-template-example serve
|
138
|
-
uvx oe-python-template-example serve --port=4711 # serves
|
221
|
+
uvx oe-python-template-example hello-world # prints "Hello, world! [..]"
|
222
|
+
uvx oe-python-template-example serve # serves web API
|
223
|
+
uvx oe-python-template-example serve --port=4711 # serves web API on port 4711
|
139
224
|
```
|
140
225
|
|
141
226
|
Notes:
|
227
|
+
1. The API is versioned, mounted at `/api/v1` resp. `/api/v2`
|
228
|
+
2. While serving the web API go to [http://127.0.0.1:8000/api/v1/hello-world](http://127.0.0.1:8000/api/v1/hello-world) to see the respons of the `hello-world` operation.
|
229
|
+
3. Interactive documentation is provided at [http://127.0.0.1:8000/api/docs](http://127.0.0.1:8000/api/docs)
|
142
230
|
|
143
|
-
- The API is versioned, mounted at `/api/v1` resp. `/api/v2`
|
144
|
-
- While serving the webservice API go to
|
145
|
-
[http://127.0.0.1:8000/api/v1/hello-world](http://127.0.0.1:8000/api/v1/hello-world)
|
146
|
-
to see the respons of the `hello-world` operation.
|
147
|
-
- Interactive documentation is provided at
|
148
|
-
[http://127.0.0.1:8000/api/docs](http://127.0.0.1:8000/api/docs)
|
149
231
|
|
150
232
|
The CLI provides extensive help:
|
151
233
|
|
@@ -157,48 +239,31 @@ uvx oe-python-template-example openapi --help
|
|
157
239
|
uvx oe-python-template-example serve --help
|
158
240
|
```
|
159
241
|
|
242
|
+
|
160
243
|
## Operational Excellence
|
161
244
|
|
162
|
-
This project is designed with operational excellence in mind, using modern
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
-
|
178
|
-
|
179
|
-
|
180
|
-
- Compliant with modern linting and formatting standards (powered by
|
181
|
-
[Ruff](https://github.com/astral-sh/ruff))
|
182
|
-
- Up-to-date dependencies (monitored by
|
183
|
-
[Renovate](https://github.com/renovatebot/renovate) and
|
184
|
-
[GitHub Dependabot](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/security/dependabot))
|
185
|
-
- [A-grade code quality](https://sonarcloud.io/summary/new_code?id=helmut-hoffer-von-ankershoffen_oe-python-template-example)
|
186
|
-
in security, maintainability, and reliability with low technical debt and
|
187
|
-
codesmell (verified by SonarQube)
|
188
|
-
- Additional code security checks using
|
189
|
-
[GitHub CodeQL](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/security/code-scanning)
|
190
|
-
- [Security Policy](SECURITY.md)
|
191
|
-
- [License](LICENSE) compliant with the Open Source Initiative (OSI)
|
192
|
-
- 1-liner for installation and execution of command line interface (CLI) via
|
193
|
-
[uv(x)](https://github.com/astral-sh/uv) or
|
194
|
-
[Docker](https://hub.docker.com/r/helmuthva/oe-python-template-example/tags)
|
195
|
-
- Setup for developing inside a
|
196
|
-
[devcontainer](https://code.visualstudio.com/docs/devcontainers/containers)
|
197
|
-
included (supports VSCode and GitHub Codespaces)
|
245
|
+
This project is designed with operational excellence in mind, using modern Python tooling and practices. It includes:
|
246
|
+
|
247
|
+
1. Various examples demonstrating usage:
|
248
|
+
a. [Simple Python script](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/blob/main/examples/script.py)
|
249
|
+
b. [Streamlit web application](https://oe-python-template-example.streamlit.app/) deployed on [Streamlit Community Cloud](https://streamlit.io/cloud)
|
250
|
+
c. [Jupyter](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/blob/main/examples/notebook.ipynb) and [Marimo](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/blob/main/examples/notebook.py) notebook
|
251
|
+
2. [Complete reference documentation](https://oe-python-template-example.readthedocs.io/en/latest/reference.html) on Read the Docs
|
252
|
+
3. [Transparent test coverage](https://app.codecov.io/gh/helmut-hoffer-von-ankershoffen/oe-python-template-example) including unit and E2E tests (reported on Codecov)
|
253
|
+
4. Matrix tested with [multiple python versions](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/blob/main/noxfile.py) to ensure compatibility (powered by [Nox](https://nox.thea.codes/en/stable/))
|
254
|
+
5. Compliant with modern linting and formatting standards (powered by [Ruff](https://github.com/astral-sh/ruff))
|
255
|
+
6. Up-to-date dependencies (monitored by [Renovate](https://github.com/renovatebot/renovate) and [Dependabot](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/security/dependabot))
|
256
|
+
7. [A-grade code quality](https://sonarcloud.io/summary/new_code?id=helmut-hoffer-von-ankershoffen_oe-python-template-example) in security, maintainability, and reliability with low technical debt and codesmell (verified by SonarQube)
|
257
|
+
8. Additional code security checks using [CodeQL](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/security/code-scanning)
|
258
|
+
9. [Security Policy](SECURITY.md)
|
259
|
+
10. [License](LICENSE) compliant with the Open Source Initiative (OSI)
|
260
|
+
11. 1-liner for installation and execution of command line interface (CLI) via [uv(x)](https://github.com/astral-sh/uv) or [Docker](https://hub.docker.com/r/helmuthva/oe-python-template-example/tags)
|
261
|
+
12. Setup for developing inside a [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) included (supports VSCode and GitHub Codespaces)
|
262
|
+
|
198
263
|
|
199
264
|
## Usage Examples
|
200
265
|
|
201
|
-
The following examples run from source
|
266
|
+
The following examples run from source - clone this repository using
|
202
267
|
`git clone git@github.com:helmut-hoffer-von-ankershoffen/oe-python-template-example.git`.
|
203
268
|
|
204
269
|
### Minimal Python Script:
|
@@ -346,11 +411,30 @@ docker compose run oe-python-template-example echo "Lorem"
|
|
346
411
|
docker compose run oe-python-template-example echo "Lorem" --json
|
347
412
|
docker compose run oe-python-template-example openapi
|
348
413
|
docker compose run oe-python-template-example openapi --output-format=json
|
349
|
-
|
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 ..."
|
350
422
|
curl http://127.0.0.1:8000/api/v1/hello-world
|
423
|
+
echo ""
|
424
|
+
echo "Swagger docs of v1 API ..."
|
351
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 ..."
|
352
431
|
curl http://127.0.0.1:8000/api/v2/hello-world
|
432
|
+
echo ""
|
433
|
+
echo "Swagger docs of v2 API ..."
|
353
434
|
curl http://127.0.0.1:8000/api/v2/docs
|
435
|
+
echo ""
|
436
|
+
echo "Shutting down the API container ..."
|
437
|
+
docker compose down
|
354
438
|
```
|
355
439
|
|
356
440
|
## Extra: Lorem Ipsum
|
@@ -0,0 +1,11 @@
|
|
1
|
+
oe_python_template_example/__init__.py,sha256=Ks3KjkBuzEO1gaezabSfal_WVOsJbuweHwRCs58oRv4,435
|
2
|
+
oe_python_template_example/api.py,sha256=Al2SrT0O8NFdb93OFi-5vFtMJ3TKps-pooMZynDU9B8,5010
|
3
|
+
oe_python_template_example/cli.py,sha256=a2NXRpybbrCGzlpPDk-YKwxD1TFV0xPdwWgYqGgv0vs,3541
|
4
|
+
oe_python_template_example/constants.py,sha256=6uQHr2CRgzWQWhUQCRRKiPuFhzKB2iblZk3dIRQ5dDc,358
|
5
|
+
oe_python_template_example/models.py,sha256=IbegPBFJq0OCAWS70V-ozl6coMd0dC2OsHZY-nIumGs,846
|
6
|
+
oe_python_template_example/service.py,sha256=Hm3uytzdik2v66agUAX9IsH_tynSuCu4NZK9BySEMUM,1226
|
7
|
+
oe_python_template_example-0.2.7.dist-info/METADATA,sha256=WHhQv5kl4DAOgOx7_mDAWhYNbWKQdPbwyLuJBhRvbCM,28966
|
8
|
+
oe_python_template_example-0.2.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
9
|
+
oe_python_template_example-0.2.7.dist-info/entry_points.txt,sha256=S2eCPB45b1Wgj_GsDRFAN-e4h7dBA5UPxT8od98erDE,82
|
10
|
+
oe_python_template_example-0.2.7.dist-info/licenses/LICENSE,sha256=5H409K6xzz9U5eUaoAHQExNkoWJRlU0LEj6wL2QJ34s,1113
|
11
|
+
oe_python_template_example-0.2.7.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
oe_python_template_example/__init__.py,sha256=-sCwS9lD6CvgWw88f7snBDF947PWIhEupJVebXL_w1M,314
|
2
|
-
oe_python_template_example/api.py,sha256=tYX07MjjmDJWMvxciwFbtuaB5CyptItqR5NyMNOmmqU,6291
|
3
|
-
oe_python_template_example/cli.py,sha256=BHuDCrzYkvJYDdvk06KwkK_sKQx7h7hhRiO0peQMM1s,3474
|
4
|
-
oe_python_template_example/constants.py,sha256=6uQHr2CRgzWQWhUQCRRKiPuFhzKB2iblZk3dIRQ5dDc,358
|
5
|
-
oe_python_template_example/service.py,sha256=XlCrklSRy8_YaYvlVYiDFPUubHHm-J8BPx2f7_niGG4,760
|
6
|
-
oe_python_template_example-0.2.5.dist-info/METADATA,sha256=HnyJ3bBiNjthc9sFRbm3Zxla8dsGXy-levU9zJ_WswI,21183
|
7
|
-
oe_python_template_example-0.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
-
oe_python_template_example-0.2.5.dist-info/entry_points.txt,sha256=S2eCPB45b1Wgj_GsDRFAN-e4h7dBA5UPxT8od98erDE,82
|
9
|
-
oe_python_template_example-0.2.5.dist-info/licenses/LICENSE,sha256=5H409K6xzz9U5eUaoAHQExNkoWJRlU0LEj6wL2QJ34s,1113
|
10
|
-
oe_python_template_example-0.2.5.dist-info/RECORD,,
|
{oe_python_template_example-0.2.5.dist-info → oe_python_template_example-0.2.7.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|
File without changes
|