Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mayer
CircularGreenSimCity
Commits
12ac2ddb
Commit
12ac2ddb
authored
Apr 05, 2024
by
Eric Duminil
Browse files
Modifying run_simstadt structure a bit
parent
358ed818
Changes
1
Show whitespace changes
Inline
Side-by-side
python_scripts/run_simstadt_from_python/run_simstadt_workflow.py
View file @
12ac2ddb
...
...
@@ -64,7 +64,7 @@ SCRIPT_DIR = Path(__file__).parent
SIMSTADT_GLOB
=
'Desktop/SimStadt_0.*/'
REPO_PATH
=
SCRIPT_DIR
.
parent
.
parent
/
'simstadt'
/
'TestRepository'
REPO_PATH
=
Path
.
home
()
/
'git'
/
'simstadt'
/
'TestRepository'
PROJECT_NAME
=
'Gruenbuehl'
WORKFLOW_FOLDERS
=
[
'a.step'
,
'b.step'
]
CITYGMLS
=
[
'Gruenbuehl_LOD2_ALKIS_1010.gml'
,
'Gruenbuehl_LOD2_ALKIS_1010_2buildings.gml'
]
...
...
@@ -72,12 +72,11 @@ CITYGMLS = ['Gruenbuehl_LOD2_ALKIS_1010.gml', 'Gruenbuehl_LOD2_ALKIS_1010_2build
##############################################
PROJECT_PATH
=
REPO_PATH
/
f
'
{
PROJECT_NAME
}
.proj'
PARAMS
=
'params.xml'
# TODO: write tests
def
find_simstadt
(
simstadt_glob
)
:
def
find_simstadt
(
simstadt_glob
:
str
)
->
Path
:
try
:
found
=
next
(
Path
.
home
().
glob
(
simstadt_glob
))
logging
.
info
(
"# SimStadt found in %s
\n
"
,
found
)
...
...
@@ -86,7 +85,7 @@ def find_simstadt(simstadt_glob):
sys
.
exit
(
f
"Sorry, no SimStadt installation could be found in
{
simstadt_glob
}
"
)
def
check_paths
(
repo_path
,
workflow_path
):
def
check_paths
(
repo_path
:
Path
,
workflow_path
:
Path
):
if
not
repo_path
.
exists
():
sys
.
exit
(
f
"Sorry, no Repository could be found in
{
repo_path
}
"
)
...
...
@@ -103,6 +102,9 @@ def check_paths(repo_path, workflow_path):
def
prepare_workflow
(
workflow_path
,
citygmls
):
if
isinstance
(
citygmls
,
str
):
citygmls
=
[
citygmls
]
tree
=
et
.
parse
(
workflow_path
/
PARAMS
)
root
=
tree
.
getroot
()
...
...
@@ -173,10 +175,10 @@ def compare_written_files(repo_path, before, after):
logging
.
info
(
"
\n
"
)
def
run_workflow
(
simstadt_path
,
workflow_
folder
,
citygmls
):
workflow_path
=
PROJECT_PATH
/
workflow_folder
def
run_workflow
(
simstadt_path
:
Path
,
workflow_
path
:
Path
,
citygmls
:
list
[
str
]
):
repo_path
=
workflow_path
.
parent
.
parent
check_paths
(
REPO_PATH
,
workflow_path
)
check_paths
(
repo_path
,
workflow_path
)
name
=
prepare_workflow
(
workflow_path
,
citygmls
)
...
...
@@ -184,15 +186,16 @@ def run_workflow(simstadt_path, workflow_folder, citygmls):
run_simstadt
(
simstadt_path
,
workflow_path
,
name
)
after
=
get_all_files
(
workflow_path
)
compare_written_files
(
REPO_PATH
,
before
,
after
)
compare_written_files
(
repo_path
,
before
,
after
)
def
main
(
glob
,
workflows
,
citygmls
):
def
main
(
glob
:
str
,
repo
:
Path
,
project_name
:
str
,
workflows
:
list
[
str
],
citygmls
:
list
[
str
]
):
simstadt_path
=
find_simstadt
(
glob
)
project_path
=
repo
/
f
'
{
project_name
}
.proj'
for
workflow_folder
in
workflows
:
run_workflow
(
simstadt_path
,
workflow_folder
,
citygmls
)
run_workflow
(
simstadt_path
,
project_path
/
workflow_folder
,
citygmls
)
if
__name__
==
'__main__'
:
main
(
SIMSTADT_GLOB
,
WORKFLOW_FOLDERS
,
CITYGMLS
)
main
(
SIMSTADT_GLOB
,
REPO_PATH
,
PROJECT_NAME
,
WORKFLOW_FOLDERS
,
CITYGMLS
)
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