Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
simstadtpy
Commits
f34d5150
Commit
f34d5150
authored
Aug 04, 2026
by
Eric Duminil
Browse files
Use CSV export as parameter
parent
82415e8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/simstadt/cli.py
View file @
f34d5150
...
@@ -65,6 +65,7 @@ def cmd_run(args: argparse.Namespace) -> None:
...
@@ -65,6 +65,7 @@ def cmd_run(args: argparse.Namespace) -> None:
description
=
args
.
description
,
description
=
args
.
description
,
destination
=
args
.
destination
,
destination
=
args
.
destination
,
project_path
=
args
.
project_path
,
project_path
=
args
.
project_path
,
csv_export
=
args
.
csv_export
,
)
)
except
(
FileNotFoundError
,
ValueError
)
as
e
:
except
(
FileNotFoundError
,
ValueError
)
as
e
:
print
(
f
"Error:
{
e
}
"
,
file
=
sys
.
stderr
)
print
(
f
"Error:
{
e
}
"
,
file
=
sys
.
stderr
)
...
...
src/simstadt/runner.py
View file @
f34d5150
...
@@ -69,8 +69,11 @@ def get_template_path() -> Path:
...
@@ -69,8 +69,11 @@ 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
]:
def
get_version_and_date
()
->
tuple
[
str
,
str
]:
SIMSTADT_VERSION_PATTERN
=
re
.
compile
(
f
"Launching SimStadt
{
SIMSTADT_VERSION_FORMAT
}
"
)
SIMSTADT_VERSION_PATTERN
=
re
.
compile
(
f
"Launching SimStadt
{
SIMSTADT_VERSION_FORMAT
}
"
)
output
=
get_simstadt_output
(
get_simstadt_folder
())
output
=
get_simstadt_output
(
get_simstadt_folder
())
m
=
SIMSTADT_VERSION_PATTERN
.
search
(
output
)
m
=
SIMSTADT_VERSION_PATTERN
.
search
(
output
)
if
not
m
:
if
not
m
:
...
@@ -78,6 +81,7 @@ def get_version_and_date() -> tuple[str, str]:
...
@@ -78,6 +81,7 @@ def get_version_and_date() -> tuple[str, str]:
version
,
_branch
,
_commit
,
date
=
m
.
groups
()
version
,
_branch
,
_commit
,
date
=
m
.
groups
()
return
version
,
date
return
version
,
date
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# Low-level workflow helpers
# Low-level workflow helpers
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
...
@@ -207,16 +211,22 @@ def get_simstadt_output(path: Path) -> str:
...
@@ -207,16 +211,22 @@ def get_simstadt_output(path: Path) -> str:
)
)
return
result
.
stdout
return
result
.
stdout
# TODO: Show which workflow is currently run
# TODO: Show which workflow is currently run
# TODO: Show absolute paths to listed files?
# TODO: Show absolute paths to listed files?
def
run_simstadt
(
workflow_path
:
Path
,
name
:
str
)
->
str
:
def
run_simstadt
(
workflow_path
:
Path
,
name
:
str
,
csv_export
:
bool
=
False
)
->
str
:
"""Invoke the SimStadt CLI for the given workflow. Returns stdout."""
"""Invoke the SimStadt CLI for the given workflow. Returns stdout."""
workflow_path
=
workflow_path
.
resolve
()
workflow_path
=
workflow_path
.
resolve
()
with
chdir
(
get_simstadt_folder
()):
with
chdir
(
get_simstadt_folder
()):
log
.
info
(
"Launching %s:"
,
name
)
log
.
info
(
"Launching %s:"
,
name
)
# NOTE: --csv-export requires SimStadt version >= August 2026
params
=
[
_simstadt_script
(),
str
(
workflow_path
)]
if
csv_export
:
params
.
append
(
"--csv-export"
)
result
=
subprocess
.
run
(
result
=
subprocess
.
run
(
[
_simstadt_script
(),
str
(
workflow_path
)]
,
params
,
text
=
True
,
text
=
True
,
capture_output
=
True
,
capture_output
=
True
,
check
=
False
,
check
=
False
,
...
@@ -247,13 +257,17 @@ def run_regionchooser(*params: str) -> str:
...
@@ -247,13 +257,17 @@ def run_regionchooser(*params: str) -> str:
return
result
.
stdout
return
result
.
stdout
def
run_workflow
(
workflow_path
:
Path
,
citygmls
:
list
[
str
])
->
list
[
Path
]:
def
run_workflow
(
workflow_path
:
Path
,
citygmls
:
list
[
str
],
csv_export
:
bool
=
False
,
)
->
list
[
Path
]:
"""Prepare and run a SimStadt workflow. Returns the list of files written by SimStadt."""
"""Prepare and run a SimStadt workflow. Returns the list of files written by SimStadt."""
repo_path
=
workflow_path
.
parent
.
parent
repo_path
=
workflow_path
.
parent
.
parent
_check_paths
(
repo_path
,
workflow_path
)
_check_paths
(
repo_path
,
workflow_path
)
name
=
_prepare_workflow
(
workflow_path
,
citygmls
)
name
=
_prepare_workflow
(
workflow_path
,
citygmls
)
before
=
_get_all_files
(
workflow_path
)
before
=
_get_all_files
(
workflow_path
)
run_simstadt
(
workflow_path
,
name
)
run_simstadt
(
workflow_path
,
name
,
csv_export
)
after
=
_get_all_files
(
workflow_path
)
after
=
_get_all_files
(
workflow_path
)
return
_compare_written_files
(
repo_path
,
before
,
after
)
return
_compare_written_files
(
repo_path
,
before
,
after
)
...
@@ -273,7 +287,7 @@ def _resolve_project(citygml_path: Path, project_path: Path | None) -> tuple[Pat
...
@@ -273,7 +287,7 @@ def _resolve_project(citygml_path: Path, project_path: Path | None) -> tuple[Pat
if
not
citygml_path
.
exists
():
if
not
citygml_path
.
exists
():
raise
FileNotFoundError
(
f
"
{
citygml_path
}
not found"
)
raise
FileNotFoundError
(
f
"
{
citygml_path
}
not found"
)
if
project_path
is
not
None
:
if
project_path
is
not
None
:
project_path
=
project_path
.
with_suffix
(
'
.proj
'
)
project_path
=
project_path
.
with_suffix
(
"
.proj
"
)
project_path
.
mkdir
(
exist_ok
=
True
,
parents
=
True
)
project_path
.
mkdir
(
exist_ok
=
True
,
parents
=
True
)
dest
=
project_path
/
citygml_path
.
name
dest
=
project_path
/
citygml_path
.
name
if
not
dest
.
exists
():
if
not
dest
.
exists
():
...
@@ -300,6 +314,7 @@ def run_workflow_with_citygml(
...
@@ -300,6 +314,7 @@ def run_workflow_with_citygml(
description
:
str
|
None
=
None
,
description
:
str
|
None
=
None
,
destination
:
str
|
None
=
None
,
destination
:
str
|
None
=
None
,
project_path
:
Path
|
None
=
None
,
project_path
:
Path
|
None
=
None
,
csv_export
:
bool
=
False
,
)
->
SimStadtResults
:
)
->
SimStadtResults
:
"""Copy a workflow template, inject parameters, run SimStadt, and return parsed results.
"""Copy a workflow template, inject parameters, run SimStadt, and return parsed results.
...
@@ -313,6 +328,7 @@ def run_workflow_with_citygml(
...
@@ -313,6 +328,7 @@ def run_workflow_with_citygml(
- project_path given: copy CityGML there if not already present (takes priority).
- project_path given: copy CityGML there if not already present (takes priority).
- CityGML inside a .proj folder: use parent as project, reference by name.
- CityGML inside a .proj folder: use parent as project, reference by name.
- Neither: create a temporary repository under /tmp (not auto-cleaned).
- Neither: create a temporary repository under /tmp (not auto-cleaned).
csv_export: If available, workflowsteps will export Buildings/Surfaces CSV files.
"""
"""
citygml_path
=
Path
(
citygml_path
)
citygml_path
=
Path
(
citygml_path
)
...
@@ -331,7 +347,7 @@ def run_workflow_with_citygml(
...
@@ -331,7 +347,7 @@ def run_workflow_with_citygml(
workflow_path
=
copy_workflow_from_template
(
workflow_path
=
copy_workflow_from_template
(
template_path
,
resolved_project_path
,
destination
,
replaces
template_path
,
resolved_project_path
,
destination
,
replaces
)
)
output_files
=
run_workflow
(
workflow_path
,
[
citygml_filename
])
output_files
=
run_workflow
(
workflow_path
,
[
citygml_filename
]
,
csv_export
)
if
description
is
None
:
if
description
is
None
:
description
=
f
"
{
template_name
}
for
{
citygml_path
.
name
}
"
description
=
f
"
{
template_name
}
for
{
citygml_path
.
name
}
"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment