Commit df5c5b57 authored by Eric Duminil's avatar Eric Duminil
Browse files

Return version and date

parent 6947ca38
...@@ -8,27 +8,28 @@ from .results import ( ...@@ -8,27 +8,28 @@ from .results import (
SolarPotentialResults, SolarPotentialResults,
create_simstadt_results, create_simstadt_results,
) )
from .runner import run_workflow_with_citygml, run_regionchooser from .runner import run_workflow_with_citygml, run_regionchooser, get_version_and_date
from .utils import clean_old_workflows from .utils import clean_old_workflows
from .workflows import greenwater_simulation, heatdemand_simulation, photovoltaic_simulation from .workflows import greenwater_simulation, heatdemand_simulation, photovoltaic_simulation
# TODO: Define Template class, with already defined Workflows? # TODO: Define Template class, with already defined Workflows?
__all__ = [ __all__ = [
"KPI", "GreenWaterResults",
"SimStadtResults",
"HeatDemandResults", "HeatDemandResults",
"KPI",
"LoadProfileResults", "LoadProfileResults",
"PhotovoltaicResults", "PhotovoltaicResults",
"GreenWaterResults", "SimStadtResults",
"SolarPotentialResults", "SolarPotentialResults",
"create_simstadt_results",
"clean_old_workflows", "clean_old_workflows",
"run_workflow_with_citygml", "create_simstadt_results",
"run_regionchooser", "get_version_and_date",
"photovoltaic_simulation",
"heatdemand_simulation",
"greenwater_simulation", "greenwater_simulation",
"heatdemand_simulation",
"photovoltaic_simulation",
"run_regionchooser",
"run_workflow_with_citygml",
] ]
......
...@@ -67,6 +67,14 @@ def get_template_path() -> Path: ...@@ -67,6 +67,14 @@ def get_template_path() -> Path:
"No template path found. Set SIMSTADT_TEMPLATE_PATH or create a templates/ directory." "No template path found. Set SIMSTADT_TEMPLATE_PATH or create a templates/ directory."
) )
def get_version_and_date() -> tuple[str, str]:
SIMSTADT_VERSION_FORMAT = re.compile(r"Launching SimStadt (\S+) \((\w+), rev. (\w+), (\d+)\)")
output = get_simstadt_output(get_simstadt_folder())
m = SIMSTADT_VERSION_FORMAT.search(output)
if not m:
raise ValueError(f"No SimStadt version string found in output:\n{output}")
version, _branch, _commit, date = m.groups()
return version, date
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Low-level workflow helpers # Low-level workflow helpers
......
...@@ -4,7 +4,7 @@ import re ...@@ -4,7 +4,7 @@ import re
import pytest import pytest
from simstadt.runner import get_simstadt_output from simstadt import get_version_and_date
SIMSTADT_MIN_VERSION = "0.14.0" SIMSTADT_MIN_VERSION = "0.14.0"
SIMSTADT_MIN_DATE = "20250701" SIMSTADT_MIN_DATE = "20250701"
...@@ -14,11 +14,7 @@ SIMSTADT_VERSION_FORMAT = re.compile(r"Launching SimStadt (\S+) \((\w+), rev. (\ ...@@ -14,11 +14,7 @@ SIMSTADT_VERSION_FORMAT = re.compile(r"Launching SimStadt (\S+) \((\w+), rev. (\
@pytest.mark.integration @pytest.mark.integration
def test_version(simstadt_folder): def test_version(simstadt_folder):
output = get_simstadt_output(simstadt_folder) version, date = get_version_and_date()
m = SIMSTADT_VERSION_FORMAT.search(output)
if not m:
pytest.fail(f"No SimStadt version string found in output:\n{output}")
version, _branch, _commit, date = m.groups()
assert version >= SIMSTADT_MIN_VERSION, ( assert version >= SIMSTADT_MIN_VERSION, (
f"SimStadt version {version} is older than required {SIMSTADT_MIN_VERSION}.\n" f"SimStadt version {version} is older than required {SIMSTADT_MIN_VERSION}.\n"
"https://simstadt.hft-stuttgart.de/download/InstallFiles/SimStadt2_latest.zip" "https://simstadt.hft-stuttgart.de/download/InstallFiles/SimStadt2_latest.zip"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment