mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 00:45:22 +00:00
Rename FastAPI server to EOS. (#355)
Rename FastAPI server to `eos` and FastHTML server to `eosdash`. Make an user easily identify what server is meant. FastAPI and FastHTML are implementation details that may confuse the non-technical user. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
parent
1d1fa9585a
commit
34d8e88771
12
Makefile
12
Makefile
@ -19,8 +19,8 @@ help:
|
|||||||
@echo " read-docs - Read HTML documentation in your browser."
|
@echo " read-docs - Read HTML documentation in your browser."
|
||||||
@echo " gen-docs - Generate openapi.json and docs/_generated/*.""
|
@echo " gen-docs - Generate openapi.json and docs/_generated/*.""
|
||||||
@echo " clean-docs - Remove generated documentation.""
|
@echo " clean-docs - Remove generated documentation.""
|
||||||
@echo " run - Run FastAPI production server in the virtual environment."
|
@echo " run - Run EOS production server in the virtual environment."
|
||||||
@echo " run-dev - Run FastAPI development server in the virtual environment (automatically reloads)."
|
@echo " run-dev - Run EOS development server in the virtual environment (automatically reloads)."
|
||||||
@echo " dist - Create distribution (in dist/)."
|
@echo " dist - Create distribution (in dist/)."
|
||||||
@echo " clean - Remove generated documentation, distribution and virtual environment."
|
@echo " clean - Remove generated documentation, distribution and virtual environment."
|
||||||
|
|
||||||
@ -84,12 +84,12 @@ clean: clean-docs
|
|||||||
@echo "Deletion complete."
|
@echo "Deletion complete."
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@echo "Starting FastAPI server, please wait..."
|
@echo "Starting EOS server, please wait..."
|
||||||
.venv/bin/fastapi run --port 8503 src/akkudoktoreos/server/fastapi_server.py
|
.venv/bin/fastapi run --port 8503 src/akkudoktoreos/server/eos.py
|
||||||
|
|
||||||
run-dev:
|
run-dev:
|
||||||
@echo "Starting FastAPI development server, please wait..."
|
@echo "Starting EOS development server, please wait..."
|
||||||
.venv/bin/fastapi dev --port 8503 src/akkudoktoreos/server/fastapi_server.py
|
.venv/bin/fastapi dev --port 8503 src/akkudoktoreos/server/eos.py
|
||||||
|
|
||||||
# Target to setup tests.
|
# Target to setup tests.
|
||||||
test-setup: pip-dev
|
test-setup: pip-dev
|
||||||
|
@ -37,13 +37,13 @@ Finally, start EOS fastapi server:
|
|||||||
Linux:
|
Linux:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
.venv/bin/fastapi run --port 8503 src/akkudoktoreos/server/fastapi_server.py
|
.venv/bin/fastapi run --port 8503 src/akkudoktoreos/server/eos.py
|
||||||
```
|
```
|
||||||
|
|
||||||
Windows:
|
Windows:
|
||||||
|
|
||||||
```
|
```
|
||||||
.venv\Scripts\fastapi run --port 8503 src/akkudoktoreos/server/fastapi_server.py
|
.venv\Scripts\fastapi run --port 8503 src/akkudoktoreos/server/eos.py
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
|
@ -287,12 +287,12 @@
|
|||||||
|
|
||||||
| Name | Type | Read-Only | Default | Description |
|
| Name | Type | Read-Only | Default | Description |
|
||||||
| ---- | ---- | --------- | ------- | ----------- |
|
| ---- | ---- | --------- | ------- | ----------- |
|
||||||
| `server_fastapi_host` | `Optional[pydantic.networks.IPvAnyAddress]` | `rw` | `0.0.0.0` | FastAPI server IP address. |
|
| `server_eos_host` | `Optional[pydantic.networks.IPvAnyAddress]` | `rw` | `0.0.0.0` | EOS server IP address. |
|
||||||
| `server_fastapi_port` | `Optional[int]` | `rw` | `8503` | FastAPI server IP port number. |
|
| `server_eos_port` | `Optional[int]` | `rw` | `8503` | EOS server IP port number. |
|
||||||
| `server_fastapi_startup_server_fasthtml` | `Optional[bool]` | `rw` | `True` | FastAPI server to startup application FastHTML server. |
|
| `server_eos_startup_eosdash` | `Optional[bool]` | `rw` | `True` | EOS server to start EOSdash server. |
|
||||||
| `server_fastapi_verbose` | `Optional[bool]` | `rw` | `False` | Enable debug output |
|
| `server_eos_verbose` | `Optional[bool]` | `rw` | `False` | Enable debug output |
|
||||||
| `server_fasthtml_host` | `Optional[pydantic.networks.IPvAnyAddress]` | `rw` | `0.0.0.0` | FastHTML server IP address. |
|
| `server_eosdash_host` | `Optional[pydantic.networks.IPvAnyAddress]` | `rw` | `0.0.0.0` | EOSdash server IP address. |
|
||||||
| `server_fasthtml_port` | `Optional[int]` | `rw` | `8504` | FastHTML server IP port number. |
|
| `server_eosdash_port` | `Optional[int]` | `rw` | `8504` | EOSdash server IP port number. |
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## Weather Forecast Configuration
|
## Weather Forecast Configuration
|
||||||
|
@ -202,17 +202,17 @@ Returns:
|
|||||||
|
|
||||||
**Parameters**:
|
**Parameters**:
|
||||||
|
|
||||||
- `server_fastapi_host` (query, optional): FastAPI server IP address.
|
- `server_eos_host` (query, optional): EOS server IP address.
|
||||||
|
|
||||||
- `server_fastapi_port` (query, optional): FastAPI server IP port number.
|
- `server_eos_port` (query, optional): EOS server IP port number.
|
||||||
|
|
||||||
- `server_fastapi_verbose` (query, optional): Enable debug output
|
- `server_eos_verbose` (query, optional): Enable debug output
|
||||||
|
|
||||||
- `server_fastapi_startup_server_fasthtml` (query, optional): FastAPI server to startup application FastHTML server.
|
- `server_eos_startup_eosdash` (query, optional): EOS server to start EOSdash server.
|
||||||
|
|
||||||
- `server_fasthtml_host` (query, optional): FastHTML server IP address.
|
- `server_eosdash_host` (query, optional): EOSdash server IP address.
|
||||||
|
|
||||||
- `server_fasthtml_port` (query, optional): FastHTML server IP port number.
|
- `server_eosdash_port` (query, optional): EOSdash server IP port number.
|
||||||
|
|
||||||
- `weatherimport_file_path` (query, optional): Path to the file to import weather data from.
|
- `weatherimport_file_path` (query, optional): Path to the file to import weather data from.
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@ Start the EOS fastapi server:
|
|||||||
|
|
||||||
.. code-block:: powershell
|
.. code-block:: powershell
|
||||||
|
|
||||||
.venv\Scripts\fastapi run src/akkudoktoreos/server/fastapi_server.py
|
.venv\Scripts\fastapi run src/akkudoktoreos/server/eos.py
|
||||||
|
|
||||||
.. tab:: Linux
|
.. tab:: Linux
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
.venv/bin/fastapi run src/akkudoktoreos/server/fastapi_server.py
|
.venv/bin/fastapi run src/akkudoktoreos/server/eos.py
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
112
openapi.json
112
openapi.json
@ -137,7 +137,7 @@
|
|||||||
"operationId": "fastapi_config_put_v1_config_put",
|
"operationId": "fastapi_config_put_v1_config_put",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "server_fastapi_host",
|
"name": "server_eos_host",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
@ -150,14 +150,14 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "FastAPI server IP address.",
|
"description": "EOS server IP address.",
|
||||||
"default": "0.0.0.0",
|
"default": "0.0.0.0",
|
||||||
"title": "Server Fastapi Host"
|
"title": "Server Eos Host"
|
||||||
},
|
},
|
||||||
"description": "FastAPI server IP address."
|
"description": "EOS server IP address."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "server_fastapi_port",
|
"name": "server_eos_port",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
@ -169,14 +169,14 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "FastAPI server IP port number.",
|
"description": "EOS server IP port number.",
|
||||||
"default": 8503,
|
"default": 8503,
|
||||||
"title": "Server Fastapi Port"
|
"title": "Server Eos Port"
|
||||||
},
|
},
|
||||||
"description": "FastAPI server IP port number."
|
"description": "EOS server IP port number."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "server_fastapi_verbose",
|
"name": "server_eos_verbose",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
@ -190,12 +190,12 @@
|
|||||||
],
|
],
|
||||||
"description": "Enable debug output",
|
"description": "Enable debug output",
|
||||||
"default": false,
|
"default": false,
|
||||||
"title": "Server Fastapi Verbose"
|
"title": "Server Eos Verbose"
|
||||||
},
|
},
|
||||||
"description": "Enable debug output"
|
"description": "Enable debug output"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "server_fastapi_startup_server_fasthtml",
|
"name": "server_eos_startup_eosdash",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
@ -207,14 +207,14 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "FastAPI server to startup application FastHTML server.",
|
"description": "EOS server to start EOSdash server.",
|
||||||
"default": true,
|
"default": true,
|
||||||
"title": "Server Fastapi Startup Server Fasthtml"
|
"title": "Server Eos Startup Eosdash"
|
||||||
},
|
},
|
||||||
"description": "FastAPI server to startup application FastHTML server."
|
"description": "EOS server to start EOSdash server."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "server_fasthtml_host",
|
"name": "server_eosdash_host",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
@ -227,14 +227,14 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "FastHTML server IP address.",
|
"description": "EOSdash server IP address.",
|
||||||
"default": "0.0.0.0",
|
"default": "0.0.0.0",
|
||||||
"title": "Server Fasthtml Host"
|
"title": "Server Eosdash Host"
|
||||||
},
|
},
|
||||||
"description": "FastHTML server IP address."
|
"description": "EOSdash server IP address."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "server_fasthtml_port",
|
"name": "server_eosdash_port",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": {
|
"schema": {
|
||||||
@ -246,11 +246,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "FastHTML server IP port number.",
|
"description": "EOSdash server IP port number.",
|
||||||
"default": 8504,
|
"default": 8504,
|
||||||
"title": "Server Fasthtml Port"
|
"title": "Server Eosdash Port"
|
||||||
},
|
},
|
||||||
"description": "FastHTML server IP port number."
|
"description": "EOSdash server IP port number."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "weatherimport_file_path",
|
"name": "weatherimport_file_path",
|
||||||
@ -3947,7 +3947,7 @@
|
|||||||
"schemas": {
|
"schemas": {
|
||||||
"ConfigEOS": {
|
"ConfigEOS": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"server_fastapi_host": {
|
"server_eos_host": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -3957,11 +3957,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fastapi Host",
|
"title": "Server Eos Host",
|
||||||
"description": "FastAPI server IP address.",
|
"description": "EOS server IP address.",
|
||||||
"default": "0.0.0.0"
|
"default": "0.0.0.0"
|
||||||
},
|
},
|
||||||
"server_fastapi_port": {
|
"server_eos_port": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
@ -3970,11 +3970,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fastapi Port",
|
"title": "Server Eos Port",
|
||||||
"description": "FastAPI server IP port number.",
|
"description": "EOS server IP port number.",
|
||||||
"default": 8503
|
"default": 8503
|
||||||
},
|
},
|
||||||
"server_fastapi_verbose": {
|
"server_eos_verbose": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@ -3983,11 +3983,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fastapi Verbose",
|
"title": "Server Eos Verbose",
|
||||||
"description": "Enable debug output",
|
"description": "Enable debug output",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"server_fastapi_startup_server_fasthtml": {
|
"server_eos_startup_eosdash": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@ -3996,11 +3996,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fastapi Startup Server Fasthtml",
|
"title": "Server Eos Startup Eosdash",
|
||||||
"description": "FastAPI server to startup application FastHTML server.",
|
"description": "EOS server to start EOSdash server.",
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
"server_fasthtml_host": {
|
"server_eosdash_host": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -4010,11 +4010,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fasthtml Host",
|
"title": "Server Eosdash Host",
|
||||||
"description": "FastHTML server IP address.",
|
"description": "EOSdash server IP address.",
|
||||||
"default": "0.0.0.0"
|
"default": "0.0.0.0"
|
||||||
},
|
},
|
||||||
"server_fasthtml_port": {
|
"server_eosdash_port": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
@ -4023,8 +4023,8 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fasthtml Port",
|
"title": "Server Eosdash Port",
|
||||||
"description": "FastHTML server IP port number.",
|
"description": "EOSdash server IP port number.",
|
||||||
"default": 8504
|
"default": 8504
|
||||||
},
|
},
|
||||||
"weatherimport_file_path": {
|
"weatherimport_file_path": {
|
||||||
@ -6626,7 +6626,7 @@
|
|||||||
},
|
},
|
||||||
"SettingsEOS": {
|
"SettingsEOS": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"server_fastapi_host": {
|
"server_eos_host": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -6636,11 +6636,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fastapi Host",
|
"title": "Server Eos Host",
|
||||||
"description": "FastAPI server IP address.",
|
"description": "EOS server IP address.",
|
||||||
"default": "0.0.0.0"
|
"default": "0.0.0.0"
|
||||||
},
|
},
|
||||||
"server_fastapi_port": {
|
"server_eos_port": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
@ -6649,11 +6649,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fastapi Port",
|
"title": "Server Eos Port",
|
||||||
"description": "FastAPI server IP port number.",
|
"description": "EOS server IP port number.",
|
||||||
"default": 8503
|
"default": 8503
|
||||||
},
|
},
|
||||||
"server_fastapi_verbose": {
|
"server_eos_verbose": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@ -6662,11 +6662,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fastapi Verbose",
|
"title": "Server Eos Verbose",
|
||||||
"description": "Enable debug output",
|
"description": "Enable debug output",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"server_fastapi_startup_server_fasthtml": {
|
"server_eos_startup_eosdash": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@ -6675,11 +6675,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fastapi Startup Server Fasthtml",
|
"title": "Server Eos Startup Eosdash",
|
||||||
"description": "FastAPI server to startup application FastHTML server.",
|
"description": "EOS server to start EOSdash server.",
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
"server_fasthtml_host": {
|
"server_eosdash_host": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -6689,11 +6689,11 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fasthtml Host",
|
"title": "Server Eosdash Host",
|
||||||
"description": "FastHTML server IP address.",
|
"description": "EOSdash server IP address.",
|
||||||
"default": "0.0.0.0"
|
"default": "0.0.0.0"
|
||||||
},
|
},
|
||||||
"server_fasthtml_port": {
|
"server_eosdash_port": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
@ -6702,8 +6702,8 @@
|
|||||||
"type": "null"
|
"type": "null"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"title": "Server Fasthtml Port",
|
"title": "Server Eosdash Port",
|
||||||
"description": "FastHTML server IP port number.",
|
"description": "EOSdash server IP port number.",
|
||||||
"default": 8504
|
"default": 8504
|
||||||
},
|
},
|
||||||
"weatherimport_file_path": {
|
"weatherimport_file_path": {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!.venv/bin/python
|
#!.venv/bin/python
|
||||||
"""This module generates the OpenAPI specification for the FastAPI application defined in `akkudoktoreos.server.fastapi_server`.
|
"""This module generates the OpenAPI specification for the EOS application defined in `akkudoktoreos.server.eos`.
|
||||||
|
|
||||||
The script can be executed directly to generate the OpenAPI specification
|
The script can be executed directly to generate the OpenAPI specification
|
||||||
either to the standard output or to a specified file.
|
either to the standard output or to a specified file.
|
||||||
@ -20,7 +20,7 @@ import sys
|
|||||||
|
|
||||||
from fastapi.openapi.utils import get_openapi
|
from fastapi.openapi.utils import get_openapi
|
||||||
|
|
||||||
from akkudoktoreos.server.fastapi_server import app
|
from akkudoktoreos.server.eos import app
|
||||||
|
|
||||||
|
|
||||||
def generate_openapi() -> dict:
|
def generate_openapi() -> dict:
|
||||||
|
@ -289,7 +289,7 @@ class ConfigEOS(SingletonMixin, SettingsEOS):
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
>>> config = get_config()
|
>>> config = get_config()
|
||||||
>>> new_data = {"prediction_hours": 24, "server_fastapi_port": 8000}
|
>>> new_data = {"prediction_hours": 24, "server_eos_port": 8000}
|
||||||
>>> config.merge_settings_from_dict(new_data)
|
>>> config.merge_settings_from_dict(new_data)
|
||||||
"""
|
"""
|
||||||
# Create new settings instance with reset optional fields and merged data
|
# Create new settings instance with reset optional fields and merged data
|
||||||
|
@ -103,11 +103,11 @@
|
|||||||
"pvforecast4_userhorizon": null,
|
"pvforecast4_userhorizon": null,
|
||||||
"pvforecast_provider": null,
|
"pvforecast_provider": null,
|
||||||
"pvforecastimport_file_path": null,
|
"pvforecastimport_file_path": null,
|
||||||
"server_fastapi_startup_server_fasthtml": true,
|
"server_eos_startup_eosdash": true,
|
||||||
"server_fastapi_host": "0.0.0.0",
|
"server_eos_host": "0.0.0.0",
|
||||||
"server_fastapi_port": 8503,
|
"server_eos_port": 8503,
|
||||||
"server_fasthtml_host": "0.0.0.0",
|
"server_eosdash_host": "0.0.0.0",
|
||||||
"server_fasthtml_port": 8504,
|
"server_eosdash_port": 8504,
|
||||||
"weather_provider": null,
|
"weather_provider": null,
|
||||||
"weatherimport_file_path": null
|
"weatherimport_file_path": null
|
||||||
}
|
}
|
||||||
|
@ -129,10 +129,10 @@ def create_error_page(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def start_fasthtml_server() -> subprocess.Popen:
|
def start_eosdash() -> subprocess.Popen:
|
||||||
"""Start the fasthtml server as a subprocess."""
|
"""Start the fasthtml server as a subprocess."""
|
||||||
server_process = subprocess.Popen(
|
server_process = subprocess.Popen(
|
||||||
[sys.executable, str(server_dir.joinpath("fasthtml_server.py"))],
|
[sys.executable, str(server_dir.joinpath("eosdash.py"))],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
)
|
)
|
||||||
@ -144,14 +144,14 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
|||||||
"""Lifespan manager for the app."""
|
"""Lifespan manager for the app."""
|
||||||
# On startup
|
# On startup
|
||||||
if (
|
if (
|
||||||
config_eos.server_fastapi_startup_server_fasthtml
|
config_eos.server_eos_startup_eosdash
|
||||||
and config_eos.server_fasthtml_host
|
and config_eos.server_eosdash_host
|
||||||
and config_eos.server_fasthtml_port
|
and config_eos.server_eosdash_port
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
fasthtml_process = start_fasthtml_server()
|
fasthtml_process = start_eosdash()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to start FastHTML server. Error: {e}")
|
logger.error(f"Failed to start EOSdash server. Error: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
# Handover to application
|
# Handover to application
|
||||||
yield
|
yield
|
||||||
@ -172,7 +172,7 @@ app = FastAPI(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# That's the problem
|
# That's the problem
|
||||||
opt_class = optimization_problem(verbose=bool(config_eos.server_fastapi_verbose))
|
opt_class = optimization_problem(verbose=bool(config_eos.server_eos_verbose))
|
||||||
|
|
||||||
server_dir = Path(__file__).parent.resolve()
|
server_dir = Path(__file__).parent.resolve()
|
||||||
|
|
||||||
@ -812,9 +812,9 @@ async def proxy_put(request: Request, path: str) -> Response:
|
|||||||
|
|
||||||
|
|
||||||
async def proxy(request: Request, path: str) -> Union[Response | RedirectResponse | HTMLResponse]:
|
async def proxy(request: Request, path: str) -> Union[Response | RedirectResponse | HTMLResponse]:
|
||||||
if config_eos.server_fasthtml_host and config_eos.server_fasthtml_port:
|
if config_eos.server_eosdash_host and config_eos.server_eosdash_port:
|
||||||
# Proxy to fasthtml server
|
# Proxy to fasthtml server
|
||||||
url = f"http://{config_eos.server_fasthtml_host}:{config_eos.server_fasthtml_port}/{path}"
|
url = f"http://{config_eos.server_eosdash_host}:{config_eos.server_eosdash_port}/{path}"
|
||||||
headers = dict(request.headers)
|
headers = dict(request.headers)
|
||||||
|
|
||||||
data = await request.body()
|
data = await request.body()
|
||||||
@ -834,11 +834,11 @@ async def proxy(request: Request, path: str) -> Union[Response | RedirectRespons
|
|||||||
status_code="404",
|
status_code="404",
|
||||||
error_title="Page Not Found",
|
error_title="Page Not Found",
|
||||||
error_message=f"""<pre>
|
error_message=f"""<pre>
|
||||||
Application server not reachable: '{url}'
|
EOSdash server not reachable: '{url}'
|
||||||
Did you start the application server
|
Did you start the EOSdash server
|
||||||
or set 'server_fastapi_startup_server_fasthtml'?
|
or set 'server_eos_startup_eosdash'?
|
||||||
If there is no application server intended please
|
If there is no application server intended please
|
||||||
set 'server_fasthtml_host' or 'server_fasthtml_port' to None.
|
set 'server_eosdash_host' or 'server_eosdash_port' to None.
|
||||||
</pre>
|
</pre>
|
||||||
""",
|
""",
|
||||||
error_details=f"{e}",
|
error_details=f"{e}",
|
||||||
@ -855,22 +855,22 @@ set 'server_fasthtml_host' or 'server_fasthtml_port' to None.
|
|||||||
return RedirectResponse(url="/docs")
|
return RedirectResponse(url="/docs")
|
||||||
|
|
||||||
|
|
||||||
def start_fastapi_server() -> None:
|
def start_eos() -> None:
|
||||||
"""Start FastAPI server."""
|
"""Start EOS server."""
|
||||||
try:
|
try:
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
app,
|
app,
|
||||||
host=str(config_eos.server_fastapi_host),
|
host=str(config_eos.server_eos_host),
|
||||||
port=config_eos.server_fastapi_port,
|
port=config_eos.server_eos_port,
|
||||||
log_level="debug",
|
log_level="debug",
|
||||||
access_log=True,
|
access_log=True,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(
|
logger.error(
|
||||||
f"Could not bind to host {config_eos.server_fastapi_host}:{config_eos.server_fastapi_port}. Error: {e}"
|
f"Could not bind to host {config_eos.server_eos_host}:{config_eos.server_eos_port}. Error: {e}"
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
start_fastapi_server()
|
start_eos()
|
@ -41,20 +41,18 @@ def config_table() -> Table:
|
|||||||
|
|
||||||
@rt("/")
|
@rt("/")
|
||||||
def get(): # type: ignore
|
def get(): # type: ignore
|
||||||
return Titled("EOS Config App", H1("Configuration"), config_table())
|
return Titled("EOS Dashboard", H1("Configuration"), config_table())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
logger.info(
|
logger.info(f"Starting {config_eos.server_eosdash_host}:{config_eos.server_eosdash_port}.")
|
||||||
f"Starting {config_eos.server_fasthtml_host}:{config_eos.server_fasthtml_port}."
|
|
||||||
)
|
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
app, host=str(config_eos.server_fasthtml_host), port=config_eos.server_fasthtml_port
|
app, host=str(config_eos.server_eosdash_host), port=config_eos.server_eosdash_port
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Error handling for binding issues
|
# Error handling for binding issues
|
||||||
logger.error(
|
logger.error(
|
||||||
f"Could not bind to host {config_eos.server_fasthtml_host}:{config_eos.server_fasthtml_port}. Error: {e}"
|
f"Could not bind to host {config_eos.server_eosdash_host}:{config_eos.server_eosdash_port}. Error: {e}"
|
||||||
)
|
)
|
||||||
exit(1)
|
exit(1)
|
@ -17,24 +17,22 @@ class ServerCommonSettings(SettingsBaseModel):
|
|||||||
To be added
|
To be added
|
||||||
"""
|
"""
|
||||||
|
|
||||||
server_fastapi_host: Optional[IPvAnyAddress] = Field(
|
server_eos_host: Optional[IPvAnyAddress] = Field(
|
||||||
default="0.0.0.0", description="FastAPI server IP address."
|
default="0.0.0.0", description="EOS server IP address."
|
||||||
)
|
)
|
||||||
server_fastapi_port: Optional[int] = Field(
|
server_eos_port: Optional[int] = Field(default=8503, description="EOS server IP port number.")
|
||||||
default=8503, description="FastAPI server IP port number."
|
server_eos_verbose: Optional[bool] = Field(default=False, description="Enable debug output")
|
||||||
|
server_eos_startup_eosdash: Optional[bool] = Field(
|
||||||
|
default=True, description="EOS server to start EOSdash server."
|
||||||
)
|
)
|
||||||
server_fastapi_verbose: Optional[bool] = Field(default=False, description="Enable debug output")
|
server_eosdash_host: Optional[IPvAnyAddress] = Field(
|
||||||
server_fastapi_startup_server_fasthtml: Optional[bool] = Field(
|
default="0.0.0.0", description="EOSdash server IP address."
|
||||||
default=True, description="FastAPI server to startup application FastHTML server."
|
|
||||||
)
|
)
|
||||||
server_fasthtml_host: Optional[IPvAnyAddress] = Field(
|
server_eosdash_port: Optional[int] = Field(
|
||||||
default="0.0.0.0", description="FastHTML server IP address."
|
default=8504, description="EOSdash server IP port number."
|
||||||
)
|
|
||||||
server_fasthtml_port: Optional[int] = Field(
|
|
||||||
default=8504, description="FastHTML server IP port number."
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@field_validator("server_fastapi_port", "server_fasthtml_port")
|
@field_validator("server_eos_port", "server_eosdash_port")
|
||||||
def validate_server_port(cls, value: Optional[int]) -> Optional[int]:
|
def validate_server_port(cls, value: Optional[int]) -> Optional[int]:
|
||||||
if value is not None and not (1024 <= value <= 49151):
|
if value is not None and not (1024 <= value <= 49151):
|
||||||
raise ValueError("Server port number must be between 1024 and 49151.")
|
raise ValueError("Server port number must be between 1024 and 49151.")
|
||||||
|
@ -170,7 +170,7 @@ def server(xprocess, config_eos, config_default_dirs):
|
|||||||
# assure server to be installed
|
# assure server to be installed
|
||||||
try:
|
try:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[sys.executable, "-c", "import akkudoktoreos.server.fastapi_server"],
|
[sys.executable, "-c", "import akkudoktoreos.server.eos"],
|
||||||
check=True,
|
check=True,
|
||||||
env=env,
|
env=env,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
@ -186,7 +186,7 @@ def server(xprocess, config_eos, config_default_dirs):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# command to start server process
|
# command to start server process
|
||||||
args = [sys.executable, "-m", "akkudoktoreos.server.fastapi_server"]
|
args = [sys.executable, "-m", "akkudoktoreos.server.eos"]
|
||||||
|
|
||||||
# startup pattern
|
# startup pattern
|
||||||
pattern = "Application startup complete."
|
pattern = "Application startup complete."
|
||||||
|
@ -17,7 +17,7 @@ def test_openapi_spec_current(config_eos):
|
|||||||
with open(expected_spec_path) as f_expected:
|
with open(expected_spec_path) as f_expected:
|
||||||
expected_spec = json.load(f_expected)
|
expected_spec = json.load(f_expected)
|
||||||
|
|
||||||
# Patch get_config and import within guard to patch global variables within the fastapi_server module.
|
# Patch get_config and import within guard to patch global variables within the eos module.
|
||||||
with patch("akkudoktoreos.config.config.get_config", return_value=config_eos):
|
with patch("akkudoktoreos.config.config.get_config", return_value=config_eos):
|
||||||
# Ensure the script works correctly as part of a package
|
# Ensure the script works correctly as part of a package
|
||||||
root_dir = Path(__file__).resolve().parent.parent
|
root_dir = Path(__file__).resolve().parent.parent
|
||||||
@ -50,7 +50,7 @@ def test_openapi_md_current(config_eos):
|
|||||||
with open(expected_spec_md_path, encoding="utf8") as f_expected:
|
with open(expected_spec_md_path, encoding="utf8") as f_expected:
|
||||||
expected_spec_md = f_expected.read()
|
expected_spec_md = f_expected.read()
|
||||||
|
|
||||||
# Patch get_config and import within guard to patch global variables within the fastapi_server module.
|
# Patch get_config and import within guard to patch global variables within the eos module.
|
||||||
with patch("akkudoktoreos.config.config.get_config", return_value=config_eos):
|
with patch("akkudoktoreos.config.config.get_config", return_value=config_eos):
|
||||||
# Ensure the script works correctly as part of a package
|
# Ensure the script works correctly as part of a package
|
||||||
root_dir = Path(__file__).resolve().parent.parent
|
root_dir = Path(__file__).resolve().parent.parent
|
||||||
@ -79,7 +79,7 @@ def test_config_md_current(config_eos):
|
|||||||
with open(expected_config_md_path, encoding="utf8") as f_expected:
|
with open(expected_config_md_path, encoding="utf8") as f_expected:
|
||||||
expected_config_md = f_expected.read()
|
expected_config_md = f_expected.read()
|
||||||
|
|
||||||
# Patch get_config and import within guard to patch global variables within the fastapi_server module.
|
# Patch get_config and import within guard to patch global variables within the eos module.
|
||||||
with patch("akkudoktoreos.config.config.get_config", return_value=config_eos):
|
with patch("akkudoktoreos.config.config.get_config", return_value=config_eos):
|
||||||
# Ensure the script works correctly as part of a package
|
# Ensure the script works correctly as part of a package
|
||||||
root_dir = Path(__file__).resolve().parent.parent
|
root_dir = Path(__file__).resolve().parent.parent
|
||||||
|
8
tests/testdata/EOS.config.json
vendored
8
tests/testdata/EOS.config.json
vendored
@ -101,10 +101,10 @@
|
|||||||
"pvforecast4_userhorizon": null,
|
"pvforecast4_userhorizon": null,
|
||||||
"pvforecast_provider": null,
|
"pvforecast_provider": null,
|
||||||
"pvforecastimport_file_path": null,
|
"pvforecastimport_file_path": null,
|
||||||
"server_fastapi_host": "0.0.0.0",
|
"server_eos_host": "0.0.0.0",
|
||||||
"server_fastapi_port": 8503,
|
"server_eos_port": 8503,
|
||||||
"server_fasthtml_host": "0.0.0.0",
|
"server_eosdash_host": "0.0.0.0",
|
||||||
"server_fasthtml_port": 8504,
|
"server_eosdash_port": 8504,
|
||||||
"weather_provider": null,
|
"weather_provider": null,
|
||||||
"weatherimport_file_path": null
|
"weatherimport_file_path": null
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user