oe-python-template-example 0.2.7__py3-none-any.whl → 0.2.9__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/api.py +3 -3
- oe_python_template_example/cli.py +22 -10
- oe_python_template_example/service.py +27 -11
- oe_python_template_example/settings.py +35 -0
- {oe_python_template_example-0.2.7.dist-info → oe_python_template_example-0.2.9.dist-info}/METADATA +5 -5
- oe_python_template_example-0.2.9.dist-info/RECORD +12 -0
- oe_python_template_example-0.2.7.dist-info/RECORD +0 -11
- {oe_python_template_example-0.2.7.dist-info → oe_python_template_example-0.2.9.dist-info}/WHEEL +0 -0
- {oe_python_template_example-0.2.7.dist-info → oe_python_template_example-0.2.9.dist-info}/entry_points.txt +0 -0
- {oe_python_template_example-0.2.7.dist-info → oe_python_template_example-0.2.9.dist-info}/licenses/LICENSE +0 -0
@@ -15,7 +15,7 @@ from typing import Annotated
|
|
15
15
|
from fastapi import Depends, FastAPI, Response, status
|
16
16
|
from pydantic import BaseModel, Field
|
17
17
|
|
18
|
-
from
|
18
|
+
from . import Echo, Health, HealthStatus, Service, Utterance
|
19
19
|
|
20
20
|
TITLE = "OE Python Template Example"
|
21
21
|
HELLO_WORLD_EXAMPLE = "Hello, world!"
|
@@ -133,14 +133,14 @@ class _HelloWorldResponse(BaseModel):
|
|
133
133
|
|
134
134
|
@api_v1.get("/hello-world", tags=["Basics"])
|
135
135
|
@api_v2.get("/hello-world", tags=["Basics"])
|
136
|
-
async def hello_world() -> _HelloWorldResponse:
|
136
|
+
async def hello_world(service: Annotated[Service, Depends(get_service)]) -> _HelloWorldResponse:
|
137
137
|
"""
|
138
138
|
Return a hello world message.
|
139
139
|
|
140
140
|
Returns:
|
141
141
|
_HelloWorldResponse: A response containing the hello world message.
|
142
142
|
"""
|
143
|
-
return _HelloWorldResponse(message=
|
143
|
+
return _HelloWorldResponse(message=service.get_hello_world())
|
144
144
|
|
145
145
|
|
146
146
|
@api_v1.get("/echo/{text}", tags=["Basics"])
|
@@ -9,12 +9,24 @@ import uvicorn
|
|
9
9
|
import yaml
|
10
10
|
from rich.console import Console
|
11
11
|
|
12
|
-
from
|
13
|
-
from
|
14
|
-
|
15
|
-
console = Console()
|
12
|
+
from . import Service, Utterance, __version__
|
13
|
+
from .api import api_v1, api_v2
|
16
14
|
|
17
15
|
cli = typer.Typer(name="Command Line Interface of OE Python Template Example")
|
16
|
+
_service = Service()
|
17
|
+
_console = Console()
|
18
|
+
|
19
|
+
|
20
|
+
@cli.command()
|
21
|
+
def health() -> None:
|
22
|
+
"""Indicate if service is healthy."""
|
23
|
+
_console.print(_service.healthy())
|
24
|
+
|
25
|
+
|
26
|
+
@cli.command()
|
27
|
+
def info() -> None:
|
28
|
+
"""Print info about service configuration."""
|
29
|
+
_console.print(_service.info())
|
18
30
|
|
19
31
|
|
20
32
|
@cli.command()
|
@@ -32,15 +44,15 @@ def echo(
|
|
32
44
|
"""Echo the text."""
|
33
45
|
echo = Service.echo(Utterance(text=text))
|
34
46
|
if json:
|
35
|
-
|
47
|
+
_console.print_json(data={"text": echo.text})
|
36
48
|
else:
|
37
|
-
|
49
|
+
_console.print(echo.text)
|
38
50
|
|
39
51
|
|
40
52
|
@cli.command()
|
41
53
|
def hello_world() -> None:
|
42
54
|
"""Print hello world message and what's in the environment variable THE_VAR."""
|
43
|
-
|
55
|
+
_console.print(_service.get_hello_world())
|
44
56
|
|
45
57
|
|
46
58
|
@cli.command()
|
@@ -50,7 +62,7 @@ def serve(
|
|
50
62
|
watch: Annotated[bool, typer.Option(help="Enable auto-reload")] = True,
|
51
63
|
) -> None:
|
52
64
|
"""Start the API server."""
|
53
|
-
|
65
|
+
_console.print(f"Starting API server at http://{host}:{port}")
|
54
66
|
os.environ["UVICORN_HOST"] = host
|
55
67
|
os.environ["UVICORN_PORT"] = str(port)
|
56
68
|
uvicorn.run(
|
@@ -111,9 +123,9 @@ def openapi(
|
|
111
123
|
schema = api_v2.openapi()
|
112
124
|
match output_format:
|
113
125
|
case OutputFormat.JSON:
|
114
|
-
|
126
|
+
_console.print_json(data=schema)
|
115
127
|
case OutputFormat.YAML:
|
116
|
-
|
128
|
+
_console.print(yaml.dump(schema, default_flow_style=False), end="")
|
117
129
|
|
118
130
|
|
119
131
|
def _apply_cli_settings(cli: typer.Typer, epilog: str) -> None:
|
@@ -1,10 +1,11 @@
|
|
1
|
-
"""Service of OE Python Template Example
|
1
|
+
"""Service of OE Python Template Example."""
|
2
2
|
|
3
3
|
import os
|
4
4
|
|
5
5
|
from dotenv import load_dotenv
|
6
6
|
|
7
|
-
from
|
7
|
+
from .models import Echo, Utterance
|
8
|
+
from .settings import Language, Settings
|
8
9
|
|
9
10
|
load_dotenv()
|
10
11
|
THE_VAR = os.getenv("THE_VAR", "not defined")
|
@@ -13,28 +14,43 @@ THE_VAR = os.getenv("THE_VAR", "not defined")
|
|
13
14
|
class Service:
|
14
15
|
"""Service of OE Python Template Example."""
|
15
16
|
|
17
|
+
_settings: Settings
|
18
|
+
|
16
19
|
def __init__(self) -> None:
|
17
20
|
"""Initialize service."""
|
21
|
+
self._settings = Settings() # pyright: ignore[reportCallIssue] - false positive
|
18
22
|
self.is_healthy = True
|
19
23
|
|
20
|
-
|
21
|
-
def get_hello_world() -> str:
|
24
|
+
def healthy(self) -> bool:
|
22
25
|
"""
|
23
|
-
|
26
|
+
Check if the service is healthy.
|
24
27
|
|
25
28
|
Returns:
|
26
|
-
|
29
|
+
bool: True if the service is healthy, False otherwise.
|
27
30
|
"""
|
28
|
-
return
|
31
|
+
return self.is_healthy
|
29
32
|
|
30
|
-
def
|
33
|
+
def info(self) -> str:
|
31
34
|
"""
|
32
|
-
|
35
|
+
Get info about configuration of service.
|
33
36
|
|
34
37
|
Returns:
|
35
|
-
|
38
|
+
str: Service configuration.
|
36
39
|
"""
|
37
|
-
return self.
|
40
|
+
return self._settings.model_dump_json()
|
41
|
+
|
42
|
+
def get_hello_world(self) -> str:
|
43
|
+
"""
|
44
|
+
Get a hello world message.
|
45
|
+
|
46
|
+
Returns:
|
47
|
+
str: Hello world message.
|
48
|
+
"""
|
49
|
+
match self._settings.language:
|
50
|
+
case Language.GERMAN:
|
51
|
+
return "Hallo, Welt!"
|
52
|
+
case _:
|
53
|
+
return "Hello, world!"
|
38
54
|
|
39
55
|
@staticmethod
|
40
56
|
def echo(utterance: Utterance) -> Echo:
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"""Settings of OE Python Template Example."""
|
2
|
+
|
3
|
+
from enum import StrEnum
|
4
|
+
from typing import Annotated
|
5
|
+
|
6
|
+
from pydantic import Field
|
7
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
8
|
+
|
9
|
+
from . import __project_name__
|
10
|
+
|
11
|
+
|
12
|
+
class Language(StrEnum):
|
13
|
+
"""Supported languages."""
|
14
|
+
|
15
|
+
GERMAN = "de_DE"
|
16
|
+
US_ENGLISH = "en_US"
|
17
|
+
|
18
|
+
|
19
|
+
class Settings(BaseSettings):
|
20
|
+
"""Settings."""
|
21
|
+
|
22
|
+
model_config = SettingsConfigDict(
|
23
|
+
env_prefix=f"{__project_name__.upper()}_",
|
24
|
+
extra="ignore",
|
25
|
+
env_file=".env",
|
26
|
+
env_file_encoding="utf-8",
|
27
|
+
)
|
28
|
+
|
29
|
+
language: Annotated[
|
30
|
+
Language,
|
31
|
+
Field(
|
32
|
+
Language.US_ENGLISH,
|
33
|
+
description="Language to use for output - defaults to US english.",
|
34
|
+
),
|
35
|
+
]
|
{oe_python_template_example-0.2.7.dist-info → oe_python_template_example-0.2.9.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.9
|
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/
|
@@ -48,15 +48,15 @@ Classifier: Programming Language :: Python :: 3.12
|
|
48
48
|
Classifier: Programming Language :: Python :: 3.13
|
49
49
|
Classifier: Typing :: Typed
|
50
50
|
Requires-Python: <4.0,>=3.11
|
51
|
-
Requires-Dist: fastapi[all,standard]>=0.115.
|
51
|
+
Requires-Dist: fastapi[all,standard]>=0.115.12
|
52
|
+
Requires-Dist: pydantic-settings>=2.8.1
|
52
53
|
Requires-Dist: pydantic>=2.10.6
|
53
|
-
Requires-Dist: python-dotenv>=1.0.1
|
54
54
|
Requires-Dist: typer>=0.15.1
|
55
55
|
Provides-Extra: examples
|
56
56
|
Requires-Dist: jinja2>=3.1.6; extra == 'examples'
|
57
57
|
Requires-Dist: jupyter>=1.1.1; extra == 'examples'
|
58
|
-
Requires-Dist: marimo>=0.11.
|
59
|
-
Requires-Dist: streamlit>=1.
|
58
|
+
Requires-Dist: marimo>=0.11.28; extra == 'examples'
|
59
|
+
Requires-Dist: streamlit>=1.44.0; extra == 'examples'
|
60
60
|
Description-Content-Type: text/markdown
|
61
61
|
|
62
62
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
oe_python_template_example/__init__.py,sha256=Ks3KjkBuzEO1gaezabSfal_WVOsJbuweHwRCs58oRv4,435
|
2
|
+
oe_python_template_example/api.py,sha256=_4-Xauw5jA9a6VPTJ5RBjBcbB7gd6Pn585b5OULF13A,5034
|
3
|
+
oe_python_template_example/cli.py,sha256=xqIiE2iYkzkGIj9g94ISolGmRd09gxyjbyKhSV1OStM,3761
|
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=2bxTQH9JeM4ugoQMpTp-pOdANOSZ0HZrQc4JpJzXBqg,1650
|
7
|
+
oe_python_template_example/settings.py,sha256=mQu7Bl2EhR6taQLqbaK1s86Ngn3kLVeEoMyhCqbydig,751
|
8
|
+
oe_python_template_example-0.2.9.dist-info/METADATA,sha256=Dl2KxhDGOudFls8zMI9AKGk7jLVdiJ8D9wS2II2e_jg,28970
|
9
|
+
oe_python_template_example-0.2.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
oe_python_template_example-0.2.9.dist-info/entry_points.txt,sha256=S2eCPB45b1Wgj_GsDRFAN-e4h7dBA5UPxT8od98erDE,82
|
11
|
+
oe_python_template_example-0.2.9.dist-info/licenses/LICENSE,sha256=5H409K6xzz9U5eUaoAHQExNkoWJRlU0LEj6wL2QJ34s,1113
|
12
|
+
oe_python_template_example-0.2.9.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
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,,
|
{oe_python_template_example-0.2.7.dist-info → oe_python_template_example-0.2.9.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|
File without changes
|