oe-python-template-example 0.0.9__tar.gz → 0.1.0__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.0.9/.act-env → oe_python_template_example-0.1.0/.act-env-public +0 -1
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.copier-answers.yml +1 -1
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.gitignore +9 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.pre-commit-config.yaml +1 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/Dockerfile +3 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/PKG-INFO +57 -21
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/README.md +56 -20
- oe_python_template_example-0.1.0/VERSION +1 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/_readme_main.md +56 -20
- oe_python_template_example-0.1.0/compose.yaml +35 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/source/_static/openapi.json +77 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/source/_static/openapi.yaml +79 -0
- oe_python_template_example-0.1.0/docs/source/_static/openapi_v1.json +262 -0
- oe_python_template_example-0.1.0/docs/source/_static/openapi_v1.yaml +210 -0
- oe_python_template_example-0.1.0/docs/source/_static/openapi_v2.json +262 -0
- oe_python_template_example-0.1.0/docs/source/_static/openapi_v2.yaml +210 -0
- oe_python_template_example-0.1.0/docs/source/api_v1.rst +5 -0
- oe_python_template_example-0.1.0/docs/source/api_v2.rst +5 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/source/conf.py +1 -1
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/source/index.rst +2 -1
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/examples/notebook.py +1 -1
- oe_python_template_example-0.1.0/github-action-run +5 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/noxfile.py +14 -5
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/pyproject.toml +3 -2
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/sonar-project.properties +1 -1
- oe_python_template_example-0.1.0/src/oe_python_template_example/api.py +237 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/src/oe_python_template_example/cli.py +54 -12
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/src/oe_python_template_example/service.py +10 -0
- oe_python_template_example-0.1.0/tests/api_test.py +126 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/tests/cli_test.py +13 -2
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/uv.lock +12 -1
- oe_python_template_example-0.0.9/.act-secret +0 -1
- oe_python_template_example-0.0.9/VERSION +0 -1
- oe_python_template_example-0.0.9/compose.yaml +0 -13
- oe_python_template_example-0.0.9/docs/source/api.rst +0 -5
- oe_python_template_example-0.0.9/github-action-run +0 -4
- oe_python_template_example-0.0.9/src/oe_python_template_example/api.py +0 -87
- oe_python_template_example-0.0.9/tests/api_test.py +0 -48
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.devcontainer/Dockerfile +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.devcontainer/devcontainer.json +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.devcontainer/onCreateCommand +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.devcontainer/postAttachCommand +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.devcontainer/postCreateCommand +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.env.example +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.github/workflows/docker-image-build-publish.yml +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.github/workflows/package-build-publish-release.yml +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.github/workflows/test-and-report.yml +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.python-version +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.readthedocs.yml +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.secrets.baseline +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.vscode/extensions.json +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/.vscode/settings.json +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/CHANGELOG.md +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/CODEOWNERS +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/CONTRIBUTING.md +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/LICENSE +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/RELEASE_NOTES.md +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/SERVICE_CONNECTIONS.md +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/_readme_footer.md +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/_readme_header.md +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/bin/git-cliff +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/bump +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/codecov.yml +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/Makefile +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/make.bat +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/source/_static/.keep +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/source/contributing.rst +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/source/latexmkrc +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/source/main.rst +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/source/reference.rst +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/docs/source/release-notes.rst +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/examples/__init__.py +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/examples/notebook.ipynb +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/examples/script.py +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/examples/streamlit.py +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/CHANGELOG.md +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/LICENSE-APACHE +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/LICENSE-MIT +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/README.md +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/completions/_git-cliff +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/completions/_git-cliff.ps1 +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/completions/git-cliff.bash +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/completions/git-cliff.elv +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/completions/git-cliff.fish +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/git-cliff-completions +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/git-cliff-mangen +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0/man/git-cliff.1 +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/git-cliff-2.7.0-x86_64-unknown-linux-gnu.tar.gz +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/latexmkrc +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/logo.png +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/renovate.json +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/src/oe_python_template_example/__init__.py +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/src/oe_python_template_example/constants.py +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/tests/__init__.py +0 -0
- {oe_python_template_example-0.0.9 → oe_python_template_example-0.1.0}/tests/fixtures/.keep +0 -0
@@ -35,5 +35,8 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
|
35
35
|
|
36
36
|
ENV OE_PYTHON_TEMPLATE_EXAMPLE_RUNNING_IN_CONTAINER=1
|
37
37
|
|
38
|
+
# API will run on port 8000 by default
|
39
|
+
EXPOSE 8000/tcp
|
40
|
+
|
38
41
|
# But feel free to add arguments and options as needed when doing a docker run
|
39
42
|
ENTRYPOINT ["uv", "run", "--no-dev", "oe-python-template-example"]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: oe-python-template-example
|
3
|
-
Version: 0.0
|
3
|
+
Version: 0.1.0
|
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/
|
@@ -101,9 +101,9 @@ Use Cases:
|
|
101
101
|
2) Consistent update of already scaffolded projects to benefit from new and improved features.
|
102
102
|
3) Dummy CLI application and service demonstrating example usage of the generated directory structure and build pipeline
|
103
103
|
|
104
|
-
## Scaffolding
|
104
|
+
## Scaffolding
|
105
105
|
|
106
|
-
Step 1
|
106
|
+
**Step 1**: Install uv package manager and copier
|
107
107
|
```shell
|
108
108
|
if [[ "$OSTYPE" == "darwin"* ]]; then # Install dependencies for macOS X
|
109
109
|
if ! command -v brew &> /dev/null; then ## Install Homebrew if not present
|
@@ -119,31 +119,32 @@ fi
|
|
119
119
|
uv tool install copier # Install copier as global tool
|
120
120
|
```
|
121
121
|
|
122
|
-
Step 2
|
122
|
+
**Step 2**: Now create an empty repository on GitHubm, clone to your local machine, and change into it's directory.
|
123
123
|
|
124
|
-
Step 3
|
124
|
+
**Step 3**: Scaffold the project
|
125
125
|
```shell
|
126
126
|
copier copy gh:helmut-hoffer-von-ankershoffen/oe-python-template .
|
127
127
|
```
|
128
|
-
Step 4
|
128
|
+
**Step 4**: Setup the local environment
|
129
129
|
|
130
130
|
```shell
|
131
131
|
uv run nox -s setup_dev
|
132
132
|
```
|
133
133
|
|
134
|
-
Step 5
|
134
|
+
**Step 5**: Perform initial commit and push
|
135
135
|
```shell
|
136
136
|
git add .
|
137
137
|
git commit -m "feat: Initial commit"
|
138
|
+
git push
|
138
139
|
```
|
139
140
|
|
140
141
|
Visit your GitHub repository and check the Actions tab. The CI workflow should fail at the SonarQube step,
|
141
142
|
as this external service is not yet configured for our new repository.
|
142
143
|
|
143
|
-
Step 6
|
144
|
-
such as Cloudcov, SonarQube Cloud, Read The Docs, Docker.io, GHCR.io and Streamlit Community Cloud.
|
144
|
+
**Step 6**: Follow the [SERVICE_INSTRUCTIONS.md](instructions) to wire up
|
145
|
+
external services such as Cloudcov, SonarQube Cloud, Read The Docs, Docker.io, GHCR.io and Streamlit Community Cloud.
|
145
146
|
|
146
|
-
Step 7
|
147
|
+
**Step 7**: Release the first versions
|
147
148
|
```shell
|
148
149
|
./bump
|
149
150
|
```
|
@@ -166,25 +167,39 @@ If you don't have uv installed follow [these instructions](https://docs.astral.s
|
|
166
167
|
pip install oe-python-template-example # add dependency to your project
|
167
168
|
```
|
168
169
|
|
169
|
-
Executing the command line interface (CLI) is just as easy:
|
170
|
+
Executing the command line interface (CLI) in an isolated Python environment is just as easy:
|
170
171
|
|
171
172
|
```shell
|
172
|
-
uvx oe-python-template-example
|
173
|
+
uvx oe-python-template-example hello-world # prints "Hello, world! [..]"
|
174
|
+
uvx oe-python-template-example serve # serves webservice API
|
173
175
|
```
|
174
176
|
|
177
|
+
When serving the 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 result.
|
178
|
+
|
179
|
+
The API is versioned and provides interactive documentation at [http://127.0.0.1:8000/api/v1/docs](http://127.0.0.1:8000/api/v1/docs) resp. [http://127.0.0.1:8000/api/v2/docs](http://127.0.0.1:8000/api/v2/docs)
|
180
|
+
|
181
|
+
|
182
|
+
```shell
|
183
|
+
|
184
|
+
When running the webservice API, goto http://127.0.0.1:8000/api/v1/docs
|
185
|
+
|
175
186
|
The CLI provides extensive help:
|
176
187
|
|
177
188
|
```shell
|
178
189
|
uvx oe-python-template-example --help # all CLI commands
|
179
190
|
uvx oe-python-template-example hello-world --help # help for specific command
|
191
|
+
uvx oe-python-template-example echo --help
|
192
|
+
uvx oe-python-template-example openapi --help
|
193
|
+
uvx oe-python-template-example serve --help
|
180
194
|
```
|
181
195
|
|
182
196
|
|
183
|
-
##
|
197
|
+
## Operational Excellence
|
184
198
|
|
185
|
-
|
186
|
-
|
187
|
-
|
199
|
+
This project is designed with operational excellence in mind, using modern Python tooling and practices. It includes:
|
200
|
+
|
201
|
+
* Various examples demonstrating usage:
|
202
|
+
- [Simple Python script](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/blob/main/examples/script.py)
|
188
203
|
- [Streamlit web application](https://oe-python-template-example.streamlit.app/) deployed on [Streamlit Community Cloud](https://streamlit.io/cloud)
|
189
204
|
- [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
|
190
205
|
* [Complete reference documenation](https://oe-python-template-example.readthedocs.io/en/latest/reference.html) on Read the Docs
|
@@ -199,6 +214,9 @@ uvx oe-python-template-example hello-world --help # help for specific command
|
|
199
214
|
|
200
215
|
## Usage Examples
|
201
216
|
|
217
|
+
The following examples run from source. Clone this repository first using
|
218
|
+
`git clone git@github.com:helmut-hoffer-von-ankershoffen/oe-python-template-example.git`.
|
219
|
+
|
202
220
|
### Minimal Python Script:
|
203
221
|
|
204
222
|
```python
|
@@ -240,7 +258,7 @@ uv run streamlit run examples/streamlit.py # Serve on localhost:8501, o
|
|
240
258
|
... or run within VSCode
|
241
259
|
|
242
260
|
```shell
|
243
|
-
uv sync --all-extras # Install
|
261
|
+
uv sync --all-extras # Install dependencies required for examples such as Juypyter kernel, see pyproject.toml
|
244
262
|
```
|
245
263
|
Install the [Jupyter extension for VSCode](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter)
|
246
264
|
|
@@ -284,8 +302,12 @@ Execute commands:
|
|
284
302
|
|
285
303
|
```shell
|
286
304
|
uvx oe-python-template-example hello-world
|
287
|
-
uvx oe-python-template-example
|
288
|
-
uvx oe-python-template-example echo "Lorem
|
305
|
+
uvx oe-python-template-example echo --help
|
306
|
+
uvx oe-python-template-example echo "Lorem"
|
307
|
+
uvx oe-python-template-example echo "Lorem" --json
|
308
|
+
uvx oe-python-template-example openapi
|
309
|
+
uvx oe-python-template-example openapi --output-format=json
|
310
|
+
uvx oe-python-template-example serve
|
289
311
|
```
|
290
312
|
|
291
313
|
### Environment
|
@@ -306,8 +328,12 @@ You can as well run the CLI within Docker.
|
|
306
328
|
```shell
|
307
329
|
docker run helmuthva/oe-python-template-example --help
|
308
330
|
docker run helmuthva/oe-python-template-example hello-world
|
309
|
-
docker run helmuthva/oe-python-template-example
|
331
|
+
docker run helmuthva/oe-python-template-example echo --help
|
310
332
|
docker run helmuthva/oe-python-template-example echo "Lorem"
|
333
|
+
docker run helmuthva/oe-python-template-example echo "Lorem" --json
|
334
|
+
docker run helmuthva/oe-python-template-example openapi
|
335
|
+
docker run helmuthva/oe-python-template-example openapi --output-format=json
|
336
|
+
docker run helmuthva/oe-python-template-example serve
|
311
337
|
```
|
312
338
|
|
313
339
|
Execute command:
|
@@ -321,8 +347,18 @@ Or use docker compose
|
|
321
347
|
The .env is passed through from the host to the Docker container.
|
322
348
|
|
323
349
|
```shell
|
324
|
-
docker compose up
|
325
350
|
docker compose run oe-python-template-example --help
|
351
|
+
docker compose run oe-python-template-example hello-world
|
352
|
+
docker compose run oe-python-template-example echo --help
|
353
|
+
docker compose run oe-python-template-example echo "Lorem"
|
354
|
+
docker compose run oe-python-template-example echo "Lorem" --json
|
355
|
+
docker compose run oe-python-template-example openapi
|
356
|
+
docker compose run oe-python-template-example openapi --output-format=json
|
357
|
+
docker compose up
|
358
|
+
curl http://127.0.0.1:8000/api/v1/hello-world
|
359
|
+
curl http://127.0.0.1:8000/api/v1/docs
|
360
|
+
curl http://127.0.0.1:8000/api/v2/hello-world
|
361
|
+
curl http://127.0.0.1:8000/api/v2/docs
|
326
362
|
```
|
327
363
|
|
328
364
|
## Extra: Lorem Ipsum
|
@@ -40,9 +40,9 @@ Use Cases:
|
|
40
40
|
2) Consistent update of already scaffolded projects to benefit from new and improved features.
|
41
41
|
3) Dummy CLI application and service demonstrating example usage of the generated directory structure and build pipeline
|
42
42
|
|
43
|
-
## Scaffolding
|
43
|
+
## Scaffolding
|
44
44
|
|
45
|
-
Step 1
|
45
|
+
**Step 1**: Install uv package manager and copier
|
46
46
|
```shell
|
47
47
|
if [[ "$OSTYPE" == "darwin"* ]]; then # Install dependencies for macOS X
|
48
48
|
if ! command -v brew &> /dev/null; then ## Install Homebrew if not present
|
@@ -58,31 +58,32 @@ fi
|
|
58
58
|
uv tool install copier # Install copier as global tool
|
59
59
|
```
|
60
60
|
|
61
|
-
Step 2
|
61
|
+
**Step 2**: Now create an empty repository on GitHubm, clone to your local machine, and change into it's directory.
|
62
62
|
|
63
|
-
Step 3
|
63
|
+
**Step 3**: Scaffold the project
|
64
64
|
```shell
|
65
65
|
copier copy gh:helmut-hoffer-von-ankershoffen/oe-python-template .
|
66
66
|
```
|
67
|
-
Step 4
|
67
|
+
**Step 4**: Setup the local environment
|
68
68
|
|
69
69
|
```shell
|
70
70
|
uv run nox -s setup_dev
|
71
71
|
```
|
72
72
|
|
73
|
-
Step 5
|
73
|
+
**Step 5**: Perform initial commit and push
|
74
74
|
```shell
|
75
75
|
git add .
|
76
76
|
git commit -m "feat: Initial commit"
|
77
|
+
git push
|
77
78
|
```
|
78
79
|
|
79
80
|
Visit your GitHub repository and check the Actions tab. The CI workflow should fail at the SonarQube step,
|
80
81
|
as this external service is not yet configured for our new repository.
|
81
82
|
|
82
|
-
Step 6
|
83
|
-
such as Cloudcov, SonarQube Cloud, Read The Docs, Docker.io, GHCR.io and Streamlit Community Cloud.
|
83
|
+
**Step 6**: Follow the [SERVICE_INSTRUCTIONS.md](instructions) to wire up
|
84
|
+
external services such as Cloudcov, SonarQube Cloud, Read The Docs, Docker.io, GHCR.io and Streamlit Community Cloud.
|
84
85
|
|
85
|
-
Step 7
|
86
|
+
**Step 7**: Release the first versions
|
86
87
|
```shell
|
87
88
|
./bump
|
88
89
|
```
|
@@ -105,25 +106,39 @@ If you don't have uv installed follow [these instructions](https://docs.astral.s
|
|
105
106
|
pip install oe-python-template-example # add dependency to your project
|
106
107
|
```
|
107
108
|
|
108
|
-
Executing the command line interface (CLI) is just as easy:
|
109
|
+
Executing the command line interface (CLI) in an isolated Python environment is just as easy:
|
109
110
|
|
110
111
|
```shell
|
111
|
-
uvx oe-python-template-example
|
112
|
+
uvx oe-python-template-example hello-world # prints "Hello, world! [..]"
|
113
|
+
uvx oe-python-template-example serve # serves webservice API
|
112
114
|
```
|
113
115
|
|
116
|
+
When serving the 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 result.
|
117
|
+
|
118
|
+
The API is versioned and provides interactive documentation at [http://127.0.0.1:8000/api/v1/docs](http://127.0.0.1:8000/api/v1/docs) resp. [http://127.0.0.1:8000/api/v2/docs](http://127.0.0.1:8000/api/v2/docs)
|
119
|
+
|
120
|
+
|
121
|
+
```shell
|
122
|
+
|
123
|
+
When running the webservice API, goto http://127.0.0.1:8000/api/v1/docs
|
124
|
+
|
114
125
|
The CLI provides extensive help:
|
115
126
|
|
116
127
|
```shell
|
117
128
|
uvx oe-python-template-example --help # all CLI commands
|
118
129
|
uvx oe-python-template-example hello-world --help # help for specific command
|
130
|
+
uvx oe-python-template-example echo --help
|
131
|
+
uvx oe-python-template-example openapi --help
|
132
|
+
uvx oe-python-template-example serve --help
|
119
133
|
```
|
120
134
|
|
121
135
|
|
122
|
-
##
|
136
|
+
## Operational Excellence
|
123
137
|
|
124
|
-
|
125
|
-
|
126
|
-
|
138
|
+
This project is designed with operational excellence in mind, using modern Python tooling and practices. It includes:
|
139
|
+
|
140
|
+
* Various examples demonstrating usage:
|
141
|
+
- [Simple Python script](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/blob/main/examples/script.py)
|
127
142
|
- [Streamlit web application](https://oe-python-template-example.streamlit.app/) deployed on [Streamlit Community Cloud](https://streamlit.io/cloud)
|
128
143
|
- [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
|
129
144
|
* [Complete reference documenation](https://oe-python-template-example.readthedocs.io/en/latest/reference.html) on Read the Docs
|
@@ -138,6 +153,9 @@ uvx oe-python-template-example hello-world --help # help for specific command
|
|
138
153
|
|
139
154
|
## Usage Examples
|
140
155
|
|
156
|
+
The following examples run from source. Clone this repository first using
|
157
|
+
`git clone git@github.com:helmut-hoffer-von-ankershoffen/oe-python-template-example.git`.
|
158
|
+
|
141
159
|
### Minimal Python Script:
|
142
160
|
|
143
161
|
```python
|
@@ -179,7 +197,7 @@ uv run streamlit run examples/streamlit.py # Serve on localhost:8501, o
|
|
179
197
|
... or run within VSCode
|
180
198
|
|
181
199
|
```shell
|
182
|
-
uv sync --all-extras # Install
|
200
|
+
uv sync --all-extras # Install dependencies required for examples such as Juypyter kernel, see pyproject.toml
|
183
201
|
```
|
184
202
|
Install the [Jupyter extension for VSCode](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter)
|
185
203
|
|
@@ -223,8 +241,12 @@ Execute commands:
|
|
223
241
|
|
224
242
|
```shell
|
225
243
|
uvx oe-python-template-example hello-world
|
226
|
-
uvx oe-python-template-example
|
227
|
-
uvx oe-python-template-example echo "Lorem
|
244
|
+
uvx oe-python-template-example echo --help
|
245
|
+
uvx oe-python-template-example echo "Lorem"
|
246
|
+
uvx oe-python-template-example echo "Lorem" --json
|
247
|
+
uvx oe-python-template-example openapi
|
248
|
+
uvx oe-python-template-example openapi --output-format=json
|
249
|
+
uvx oe-python-template-example serve
|
228
250
|
```
|
229
251
|
|
230
252
|
### Environment
|
@@ -245,8 +267,12 @@ You can as well run the CLI within Docker.
|
|
245
267
|
```shell
|
246
268
|
docker run helmuthva/oe-python-template-example --help
|
247
269
|
docker run helmuthva/oe-python-template-example hello-world
|
248
|
-
docker run helmuthva/oe-python-template-example
|
270
|
+
docker run helmuthva/oe-python-template-example echo --help
|
249
271
|
docker run helmuthva/oe-python-template-example echo "Lorem"
|
272
|
+
docker run helmuthva/oe-python-template-example echo "Lorem" --json
|
273
|
+
docker run helmuthva/oe-python-template-example openapi
|
274
|
+
docker run helmuthva/oe-python-template-example openapi --output-format=json
|
275
|
+
docker run helmuthva/oe-python-template-example serve
|
250
276
|
```
|
251
277
|
|
252
278
|
Execute command:
|
@@ -260,8 +286,18 @@ Or use docker compose
|
|
260
286
|
The .env is passed through from the host to the Docker container.
|
261
287
|
|
262
288
|
```shell
|
263
|
-
docker compose up
|
264
289
|
docker compose run oe-python-template-example --help
|
290
|
+
docker compose run oe-python-template-example hello-world
|
291
|
+
docker compose run oe-python-template-example echo --help
|
292
|
+
docker compose run oe-python-template-example echo "Lorem"
|
293
|
+
docker compose run oe-python-template-example echo "Lorem" --json
|
294
|
+
docker compose run oe-python-template-example openapi
|
295
|
+
docker compose run oe-python-template-example openapi --output-format=json
|
296
|
+
docker compose up
|
297
|
+
curl http://127.0.0.1:8000/api/v1/hello-world
|
298
|
+
curl http://127.0.0.1:8000/api/v1/docs
|
299
|
+
curl http://127.0.0.1:8000/api/v2/hello-world
|
300
|
+
curl http://127.0.0.1:8000/api/v2/docs
|
265
301
|
```
|
266
302
|
|
267
303
|
## Extra: Lorem Ipsum
|
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -5,9 +5,9 @@ Use Cases:
|
|
5
5
|
2) Consistent update of already scaffolded projects to benefit from new and improved features.
|
6
6
|
3) Dummy CLI application and service demonstrating example usage of the generated directory structure and build pipeline
|
7
7
|
|
8
|
-
## Scaffolding
|
8
|
+
## Scaffolding
|
9
9
|
|
10
|
-
Step 1
|
10
|
+
**Step 1**: Install uv package manager and copier
|
11
11
|
```shell
|
12
12
|
if [[ "$OSTYPE" == "darwin"* ]]; then # Install dependencies for macOS X
|
13
13
|
if ! command -v brew &> /dev/null; then ## Install Homebrew if not present
|
@@ -23,31 +23,32 @@ fi
|
|
23
23
|
uv tool install copier # Install copier as global tool
|
24
24
|
```
|
25
25
|
|
26
|
-
Step 2
|
26
|
+
**Step 2**: Now create an empty repository on GitHubm, clone to your local machine, and change into it's directory.
|
27
27
|
|
28
|
-
Step 3
|
28
|
+
**Step 3**: Scaffold the project
|
29
29
|
```shell
|
30
30
|
copier copy gh:helmut-hoffer-von-ankershoffen/oe-python-template .
|
31
31
|
```
|
32
|
-
Step 4
|
32
|
+
**Step 4**: Setup the local environment
|
33
33
|
|
34
34
|
```shell
|
35
35
|
uv run nox -s setup_dev
|
36
36
|
```
|
37
37
|
|
38
|
-
Step 5
|
38
|
+
**Step 5**: Perform initial commit and push
|
39
39
|
```shell
|
40
40
|
git add .
|
41
41
|
git commit -m "feat: Initial commit"
|
42
|
+
git push
|
42
43
|
```
|
43
44
|
|
44
45
|
Visit your GitHub repository and check the Actions tab. The CI workflow should fail at the SonarQube step,
|
45
46
|
as this external service is not yet configured for our new repository.
|
46
47
|
|
47
|
-
Step 6
|
48
|
-
such as Cloudcov, SonarQube Cloud, Read The Docs, Docker.io, GHCR.io and Streamlit Community Cloud.
|
48
|
+
**Step 6**: Follow the [SERVICE_INSTRUCTIONS.md](instructions) to wire up
|
49
|
+
external services such as Cloudcov, SonarQube Cloud, Read The Docs, Docker.io, GHCR.io and Streamlit Community Cloud.
|
49
50
|
|
50
|
-
Step 7
|
51
|
+
**Step 7**: Release the first versions
|
51
52
|
```shell
|
52
53
|
./bump
|
53
54
|
```
|
@@ -70,25 +71,39 @@ If you don't have uv installed follow [these instructions](https://docs.astral.s
|
|
70
71
|
pip install oe-python-template-example # add dependency to your project
|
71
72
|
```
|
72
73
|
|
73
|
-
Executing the command line interface (CLI) is just as easy:
|
74
|
+
Executing the command line interface (CLI) in an isolated Python environment is just as easy:
|
74
75
|
|
75
76
|
```shell
|
76
|
-
uvx oe-python-template-example
|
77
|
+
uvx oe-python-template-example hello-world # prints "Hello, world! [..]"
|
78
|
+
uvx oe-python-template-example serve # serves webservice API
|
77
79
|
```
|
78
80
|
|
81
|
+
When serving the 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 result.
|
82
|
+
|
83
|
+
The API is versioned and provides interactive documentation at [http://127.0.0.1:8000/api/v1/docs](http://127.0.0.1:8000/api/v1/docs) resp. [http://127.0.0.1:8000/api/v2/docs](http://127.0.0.1:8000/api/v2/docs)
|
84
|
+
|
85
|
+
|
86
|
+
```shell
|
87
|
+
|
88
|
+
When running the webservice API, goto http://127.0.0.1:8000/api/v1/docs
|
89
|
+
|
79
90
|
The CLI provides extensive help:
|
80
91
|
|
81
92
|
```shell
|
82
93
|
uvx oe-python-template-example --help # all CLI commands
|
83
94
|
uvx oe-python-template-example hello-world --help # help for specific command
|
95
|
+
uvx oe-python-template-example echo --help
|
96
|
+
uvx oe-python-template-example openapi --help
|
97
|
+
uvx oe-python-template-example serve --help
|
84
98
|
```
|
85
99
|
|
86
100
|
|
87
|
-
##
|
101
|
+
## Operational Excellence
|
88
102
|
|
89
|
-
|
90
|
-
|
91
|
-
|
103
|
+
This project is designed with operational excellence in mind, using modern Python tooling and practices. It includes:
|
104
|
+
|
105
|
+
* Various examples demonstrating usage:
|
106
|
+
- [Simple Python script](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/blob/main/examples/script.py)
|
92
107
|
- [Streamlit web application](https://oe-python-template-example.streamlit.app/) deployed on [Streamlit Community Cloud](https://streamlit.io/cloud)
|
93
108
|
- [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
|
94
109
|
* [Complete reference documenation](https://oe-python-template-example.readthedocs.io/en/latest/reference.html) on Read the Docs
|
@@ -103,6 +118,9 @@ uvx oe-python-template-example hello-world --help # help for specific command
|
|
103
118
|
|
104
119
|
## Usage Examples
|
105
120
|
|
121
|
+
The following examples run from source. Clone this repository first using
|
122
|
+
`git clone git@github.com:helmut-hoffer-von-ankershoffen/oe-python-template-example.git`.
|
123
|
+
|
106
124
|
### Minimal Python Script:
|
107
125
|
|
108
126
|
```python
|
@@ -144,7 +162,7 @@ uv run streamlit run examples/streamlit.py # Serve on localhost:8501, o
|
|
144
162
|
... or run within VSCode
|
145
163
|
|
146
164
|
```shell
|
147
|
-
uv sync --all-extras # Install
|
165
|
+
uv sync --all-extras # Install dependencies required for examples such as Juypyter kernel, see pyproject.toml
|
148
166
|
```
|
149
167
|
Install the [Jupyter extension for VSCode](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter)
|
150
168
|
|
@@ -188,8 +206,12 @@ Execute commands:
|
|
188
206
|
|
189
207
|
```shell
|
190
208
|
uvx oe-python-template-example hello-world
|
191
|
-
uvx oe-python-template-example
|
192
|
-
uvx oe-python-template-example echo "Lorem
|
209
|
+
uvx oe-python-template-example echo --help
|
210
|
+
uvx oe-python-template-example echo "Lorem"
|
211
|
+
uvx oe-python-template-example echo "Lorem" --json
|
212
|
+
uvx oe-python-template-example openapi
|
213
|
+
uvx oe-python-template-example openapi --output-format=json
|
214
|
+
uvx oe-python-template-example serve
|
193
215
|
```
|
194
216
|
|
195
217
|
### Environment
|
@@ -210,8 +232,12 @@ You can as well run the CLI within Docker.
|
|
210
232
|
```shell
|
211
233
|
docker run helmuthva/oe-python-template-example --help
|
212
234
|
docker run helmuthva/oe-python-template-example hello-world
|
213
|
-
docker run helmuthva/oe-python-template-example
|
235
|
+
docker run helmuthva/oe-python-template-example echo --help
|
214
236
|
docker run helmuthva/oe-python-template-example echo "Lorem"
|
237
|
+
docker run helmuthva/oe-python-template-example echo "Lorem" --json
|
238
|
+
docker run helmuthva/oe-python-template-example openapi
|
239
|
+
docker run helmuthva/oe-python-template-example openapi --output-format=json
|
240
|
+
docker run helmuthva/oe-python-template-example serve
|
215
241
|
```
|
216
242
|
|
217
243
|
Execute command:
|
@@ -225,8 +251,18 @@ Or use docker compose
|
|
225
251
|
The .env is passed through from the host to the Docker container.
|
226
252
|
|
227
253
|
```shell
|
228
|
-
docker compose up
|
229
254
|
docker compose run oe-python-template-example --help
|
255
|
+
docker compose run oe-python-template-example hello-world
|
256
|
+
docker compose run oe-python-template-example echo --help
|
257
|
+
docker compose run oe-python-template-example echo "Lorem"
|
258
|
+
docker compose run oe-python-template-example echo "Lorem" --json
|
259
|
+
docker compose run oe-python-template-example openapi
|
260
|
+
docker compose run oe-python-template-example openapi --output-format=json
|
261
|
+
docker compose up
|
262
|
+
curl http://127.0.0.1:8000/api/v1/hello-world
|
263
|
+
curl http://127.0.0.1:8000/api/v1/docs
|
264
|
+
curl http://127.0.0.1:8000/api/v2/hello-world
|
265
|
+
curl http://127.0.0.1:8000/api/v2/docs
|
230
266
|
```
|
231
267
|
|
232
268
|
## Extra: Lorem Ipsum
|
@@ -0,0 +1,35 @@
|
|
1
|
+
services:
|
2
|
+
oe-python-template-example:
|
3
|
+
build: .
|
4
|
+
env_file:
|
5
|
+
- path: .env
|
6
|
+
required: true
|
7
|
+
develop:
|
8
|
+
watch:
|
9
|
+
- path: src
|
10
|
+
action: rebuild
|
11
|
+
restart: no
|
12
|
+
profiles:
|
13
|
+
- manual
|
14
|
+
tty: true
|
15
|
+
stdin_open: true
|
16
|
+
oe-python-template-example-api:
|
17
|
+
build: .
|
18
|
+
env_file:
|
19
|
+
- path: .env
|
20
|
+
required: true
|
21
|
+
develop:
|
22
|
+
watch:
|
23
|
+
- path: src
|
24
|
+
action: rebuild
|
25
|
+
command: serve --host=0.0.0.0 --port=8000 --no-reload
|
26
|
+
restart: always
|
27
|
+
ports:
|
28
|
+
- "8000:8000"
|
29
|
+
healthcheck:
|
30
|
+
test: [ "CMD", "curl", "-f", "http://127.0.0.1:8000/healthz" ]
|
31
|
+
interval: 5s
|
32
|
+
timeout: 2s
|
33
|
+
retries: 3
|
34
|
+
start_period: 5s
|
35
|
+
start_interval: 1s
|