Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
AMBS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
AMBS
Commits
552bc2a6
Commit
552bc2a6
authored
2 years ago
by
Michael Langguth
Browse files
Options
Downloads
Patches
Plain Diff
Clearer error-handling and inclusion of climatology-file to postprocess runscript generator.
parent
deeedd41
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
video_prediction_tools/utils/runscript_generator/config_postprocess.py
+21
-12
21 additions, 12 deletions
...ion_tools/utils/runscript_generator/config_postprocess.py
with
21 additions
and
12 deletions
video_prediction_tools/utils/runscript_generator/config_postprocess.py
+
21
−
12
View file @
552bc2a6
...
...
@@ -33,9 +33,10 @@ class Config_Postprocess(Config_runscript_base):
self
.
model
=
None
self
.
checkpoint_dir
=
None
self
.
results_dir
=
None
self
.
clim_f
=
None
#self.lquick = None
# list of variables to be written to runscript
self
.
list_batch_vars
=
[
"
VIRT_ENV_NAME
"
,
"
results_dir
"
,
"
checkpoint_dir
"
,
"
model
"
]
# , "lquick"]
self
.
list_batch_vars
=
[
"
VIRT_ENV_NAME
"
,
"
results_dir
"
,
"
checkpoint_dir
"
,
"
clim_f
"
]
# , "lquick"]
# copy over method for keyboard interaction
self
.
run_config
=
Config_Postprocess
.
run_postprocess
#
...
...
@@ -62,14 +63,14 @@ class Config_Postprocess(Config_runscript_base):
# First choose the basic experiment directory
dir_base
=
Config_Postprocess
.
handle_source_dir
(
self
,
"
models
"
)
expbase_req_str
=
"
Choose an experiment from the list above:
"
expbase_err
=
NotADirectoryError
(
"
Could not find passed directory
.
"
)
expbase_req_str
=
"
Choose an experiment
set
from the list above:
"
expbase_err
=
NotADirectoryError
(
"
Please select an experiment from the ones listed above
.
"
)
dir_base
=
Config_Postprocess
.
keyboard_interaction
(
expbase_req_str
,
Config_Postprocess
.
check_dir
,
expbase_err
,
prefix2arg
=
dir_base
+
"
/
"
,
ntries
=
2
)
# Choose the model
model_req_str
=
"
Enter the name of the
trained
model:
"
model_err
=
NotADirectoryError
(
"
No directory for trained
model
ex
ist
s
.
"
)
model_req_str
=
"
Enter the name of the model:
"
model_err
=
NotADirectoryError
(
"
Select a
model
l
ist
ed above (if any)
.
"
)
dir_base
=
Config_Postprocess
.
keyboard_interaction
(
model_req_str
,
Config_Postprocess
.
check_model
,
model_err
,
prefix2arg
=
dir_base
+
"
/
"
,
ntries
=
2
)
...
...
@@ -78,14 +79,14 @@ class Config_Postprocess(Config_runscript_base):
_
=
Config_Postprocess
.
get_subdir_list
(
dir_base
)
# Chose the checkpoint directory
ckp_req_str
=
"
Choose a
checkpoint directory
from the list above:
"
ckp_req_err
=
NotADirectoryError
(
"
C
ould not f
ind
the passed directory
.
"
)
ckp_req_str
=
"
Choose a
trained model
from the list above:
"
ckp_req_err
=
NotADirectoryError
(
"
C
hoose a tra
in
e
d
model from the ones listed above (if any)
.
"
)
dir_base
=
Config_Postprocess
.
keyboard_interaction
(
ckp_req_str
,
Config_Postprocess
.
check_dir
,
ckp_req_err
,
prefix2arg
=
dir_base
+
"
/
"
,
ntries
=
2
)
# List the subdirectories...
_
=
Config_Postprocess
.
get_subdir_list
(
dir_base
)
# ... and obtain the model directory with checkpoints
trained_dir_req_str
=
"
Choose a
trained model from the experiment
list above:
"
trained_dir_req_str
=
"
Choose a
checkpoint from the
list above:
"
trained_err
=
FileNotFoundError
(
"
No trained model parameters found.
"
)
self
.
checkpoint_dir
=
Config_Postprocess
.
keyboard_interaction
(
trained_dir_req_str
,
Config_Postprocess
.
check_traindir
,
...
...
@@ -103,6 +104,11 @@ class Config_Postprocess(Config_runscript_base):
# Set results_dir
self
.
results_dir
=
os
.
path
.
join
(
base_dir
,
"
results
"
,
exp_dir_base
,
self
.
model
,
exp_dir
)
self
.
clim_f
=
os
.
path
.
join
(
os
.
path
.
dirname
(
base_dir
),
"
T2climatology
"
,
"
climatology_t2m_1991-2020.nc
"
)
if
not
os
.
path
.
isfile
(
self
.
clim_f
):
print
(
"
WARNING: Cannot find netCDF-file with climatology of 2m temperature under
'
{0}
'
. Please adapt manually.
"
.
format
(
self
.
clim_f
))
return
# Decide if quick evaluation should be performed
quick_req_str
=
"
Should a reduced, quick evalutaion be performed (yes/no):
"
...
...
@@ -150,11 +156,14 @@ class Config_Postprocess(Config_runscript_base):
:param silent: flag if print-statement are executed
:return: status with True confirming success
"""
method
=
Config_Postprocess
.
check_dir
.
__name__
status
=
False
if
not
os
.
path
.
isdir
(
dir_in
):
if
not
silent
:
print
(
"
{0} is not a directory
"
.
format
(
dir_in
))
elif
dir_in
==
""
:
if
not
silent
:
print
(
"
{0}: Please enter a directory/checkpoint.
"
)
if
not
silent
and
not
dir_in
.
endswith
(
"
help
"
)
:
print
(
"
%
{0}
: {1}
is not a directory
"
.
format
(
method
,
dir_in
))
elif
dir_in
.
endswith
(
"
/
"
):
# this most likely happens when prefix2arg is passed
if
not
silent
:
print
(
"
%
{0}: Please enter a directory/checkpoint.
"
.
format
(
method
)
)
else
:
status
=
True
...
...
@@ -220,7 +229,7 @@ class Config_Postprocess(Config_runscript_base):
if
not
silent
:
print
(
"
{0} does not contain any model parameter files (model-*.meta).
"
.
format
(
checkpoint_dir
))
else
:
if
not
silent
:
print
(
"
Passed directory
'
{0}
'
does not exist!
"
.
format
(
checkpoint_dir
))
if
not
silent
and
not
checkpoint_dir
.
endswith
(
"
help
"
)
:
print
(
"
Passed directory
'
{0}
'
does not exist!
"
.
format
(
checkpoint_dir
))
return
status
#
# -----------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment