Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
MLAir
Commits
234183fd
Commit
234183fd
authored
4 years ago
by
leufen1
Browse files
Options
Downloads
Patches
Plain Diff
stations parameter is now internally always a list
parent
741f72fe
No related branches found
No related tags found
5 merge requests
!192
include Develop
,
!191
Resolve "release v1.1.0"
,
!168
Lukas issue193 bug index error
,
!167
Resolve "bug: too many indices in PlotClimatologicalSkillScore"
,
!139
Draft: Resolve "KZ filter"
Pipeline
#48722
passed
4 years ago
Stage: test
Stage: docs
Stage: pages
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mlair/run_modules/experiment_setup.py
+8
-4
8 additions, 4 deletions
mlair/run_modules/experiment_setup.py
test/test_run_modules/test_experiment_setup.py
+11
-1
11 additions, 1 deletion
test/test_run_modules/test_experiment_setup.py
with
19 additions
and
5 deletions
mlair/run_modules/experiment_setup.py
+
8
−
4
View file @
234183fd
...
...
@@ -4,7 +4,7 @@ __date__ = '2019-11-15'
import
argparse
import
logging
import
os
from
typing
import
Union
,
Dict
,
Any
,
List
from
typing
import
Union
,
Dict
,
Any
,
List
,
Callable
from
mlair.configuration
import
path_config
from
mlair
import
helpers
...
...
@@ -279,7 +279,7 @@ class ExperimentSetup(RunEnvironment):
path_config
.
check_path_and_create
(
self
.
data_store
.
get
(
"
logging_path
"
))
# setup for data
self
.
_set_param
(
"
stations
"
,
helpers
.
to_list
(
stations
)
,
default
=
DEFAULT_STATIONS
)
self
.
_set_param
(
"
stations
"
,
stations
,
default
=
DEFAULT_STATIONS
,
apply
=
helpers
.
to_list
)
self
.
_set_param
(
"
statistics_per_var
"
,
statistics_per_var
,
default
=
DEFAULT_VAR_ALL_DICT
)
self
.
_set_param
(
"
variables
"
,
variables
,
default
=
list
(
self
.
data_store
.
get
(
"
statistics_per_var
"
).
keys
()))
self
.
_set_param
(
"
start
"
,
start
,
default
=
DEFAULT_START
)
...
...
@@ -355,10 +355,14 @@ class ExperimentSetup(RunEnvironment):
raise
KeyError
(
f
"
Given argument
{
k
}
with value
{
v
}
cannot be set for this experiment due to a
"
f
"
conflict with an existing entry with same naming:
{
k
}
=
{
self
.
data_store
.
get
(
k
)
}
"
)
def
_set_param
(
self
,
param
:
str
,
value
:
Any
,
default
:
Any
=
None
,
scope
:
str
=
"
general
"
)
->
None
:
"""
Set given parameter and log in debug.
"""
def
_set_param
(
self
,
param
:
str
,
value
:
Any
,
default
:
Any
=
None
,
scope
:
str
=
"
general
"
,
apply
:
Callable
=
None
)
->
None
:
"""
Set given parameter and log in debug. Use apply parameter to adjust the stored value (e.g. to transform value
to a list use apply=helpers.to_list).
"""
if
value
is
None
and
default
is
not
None
:
value
=
default
if
apply
is
not
None
:
value
=
apply
(
value
)
self
.
data_store
.
set
(
param
,
value
,
scope
)
logging
.
debug
(
f
"
set experiment attribute:
{
param
}
(
{
scope
}
)=
{
value
}
"
)
...
...
This diff is collapsed.
Click to expand it.
test/test_run_modules/test_experiment_setup.py
+
11
−
1
View file @
234183fd
...
...
@@ -4,7 +4,7 @@ import os
import
pytest
from
mlair.helpers
import
TimeTracking
from
mlair.helpers
import
TimeTracking
,
to_list
from
mlair.configuration.path_config
import
prepare_host
from
mlair.run_modules.experiment_setup
import
ExperimentSetup
...
...
@@ -33,6 +33,16 @@ class TestExperimentSetup:
empty_obj
.
_set_param
(
"
AnotherNoneTester
"
,
None
)
assert
empty_obj
.
data_store
.
get
(
"
AnotherNoneTester
"
,
"
general
"
)
is
None
def
test_set_param_with_apply
(
self
,
caplog
,
empty_obj
):
empty_obj
.
_set_param
(
"
NoneTester
"
,
None
,
default
=
"
notNone
"
,
apply
=
None
)
assert
empty_obj
.
data_store
.
get
(
"
NoneTester
"
)
==
"
notNone
"
empty_obj
.
_set_param
(
"
NoneTester
"
,
None
,
default
=
"
notNone
"
,
apply
=
to_list
)
assert
empty_obj
.
data_store
.
get
(
"
NoneTester
"
)
==
[
"
notNone
"
]
empty_obj
.
_set_param
(
"
NoneTester
"
,
None
,
apply
=
to_list
)
assert
empty_obj
.
data_store
.
get
(
"
NoneTester
"
)
==
[
None
]
empty_obj
.
_set_param
(
"
NoneTester
"
,
2.3
,
apply
=
int
)
assert
empty_obj
.
data_store
.
get
(
"
NoneTester
"
)
==
2
def
test_init_default
(
self
):
exp_setup
=
ExperimentSetup
()
data_store
=
exp_setup
.
data_store
...
...
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