mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-11-26 07:16:25 +00:00
Migrate from Flask to FastAPI (#163)
* Migrate from Flask to FastAPI
* FastAPI migration:
- Use pydantic model classes as input parameters to the
data/calculation classes.
- Interface field names changed to constructor parameter names (for
simplicity only during transition, should be updated in a followup
PR).
- Add basic interface requirements (e.g. some values > 0, etc.).
* Update tests for new data format.
* Python requirement down to 3.9 (TypeGuard no longer needed)
* Makefile: Add helpful targets (e.g. development server with reload)
* Move API doc from README to pydantic model classes (swagger)
* Link to swagger.io with own openapi.yml.
* Commit openapi.json and check with pytest for changes so the
documentation is always up-to-date.
* Streamline docker
* FastAPI: Run startup action on dev server
* Fix config for /strompreis, endpoint still broken however.
* test_openapi: Compare against docs/.../openapi.json
* Move fastapi to server/ submodule
* See #187 for new repository structure.
This commit is contained in:
committed by
GitHub
parent
ed3226e522
commit
f61665669f
@@ -50,7 +50,7 @@ def server(xprocess, tmp_path: Path):
|
||||
# assure server to be installed
|
||||
try:
|
||||
subprocess.run(
|
||||
[sys.executable, "-c", "import akkudoktoreosserver"],
|
||||
[sys.executable, "-c", "import akkudoktoreos.server"],
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
@@ -65,11 +65,11 @@ def server(xprocess, tmp_path: Path):
|
||||
)
|
||||
|
||||
# command to start server process
|
||||
args = [sys.executable, "-m", "akkudoktoreosserver.flask_server"]
|
||||
args = [sys.executable, "-m", "akkudoktoreos.server.fastapi_server"]
|
||||
env = {EOS_DIR: f"{tmp_path}", **os.environ.copy()}
|
||||
|
||||
# startup pattern
|
||||
pattern = "Debugger PIN:"
|
||||
pattern = "Application startup complete."
|
||||
# search the first 30 lines for the startup pattern, if not found
|
||||
# a RuntimeError will be raised informing the user
|
||||
max_read_lines = 30
|
||||
@@ -81,14 +81,14 @@ def server(xprocess, tmp_path: Path):
|
||||
terminate_on_interrupt = True
|
||||
|
||||
# ensure process is running and return its logfile
|
||||
logfile = xprocess.ensure("akkudoktoreosserver", Starter)
|
||||
logfile = xprocess.ensure("eos", Starter)
|
||||
|
||||
# create url/port info to the server
|
||||
url = "http://127.0.0.1:8503"
|
||||
yield url
|
||||
|
||||
# clean up whole process tree afterwards
|
||||
xprocess.getinfo("akkudoktoreosserver").terminate()
|
||||
xprocess.getinfo("eos").terminate()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user