From 22f15940206b6df8bc41eb9c355583b00af8cf41 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Tue, 6 May 2025 09:34:00 +0200 Subject: [PATCH] Configuration loader --- lightspeed-stack.yaml | 1 + src/lightspeed-stack.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lightspeed-stack.yaml diff --git a/lightspeed-stack.yaml b/lightspeed-stack.yaml new file mode 100644 index 000000000..ff55d09a9 --- /dev/null +++ b/lightspeed-stack.yaml @@ -0,0 +1 @@ +name: foo bar baz diff --git a/src/lightspeed-stack.py b/src/lightspeed-stack.py index 33414c242..b6fd2a59d 100644 --- a/src/lightspeed-stack.py +++ b/src/lightspeed-stack.py @@ -1,8 +1,20 @@ """Lightspeed stack.""" +import yaml + from runners.uvicorn import start_uvicorn -import version +from models.config import Configuration + + +def load_configuration(filename: str) -> Configuration: + """Load configuration from YAML file.""" + with open(filename, encoding="utf-8") as fin: + config_dict = yaml.safe_load(fin) + return Configuration(**config_dict) + if __name__ == "__main__": print("Lightspeed stack") + configuration = load_configuration("lightspeed-stack.yaml") + print(configuration) start_uvicorn()