Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121360298
overwrite_config.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jul 10, 07:07
Size
954 B
Mime Type
text/x-python
Expires
Sat, Jul 12, 07:07 (2 d)
Engine
blob
Format
Raw Data
Handle
27309408
Attached To
R2915 eSCT pipeline interoperability
overwrite_config.py
View Options
from
pipeline.scripts.load_config
import
load_config
def
overwrite_config
(
config
,
config_file_path
):
"""
Overwrites the provided configuration with the configuration from the specified YAML configuration file.
@author: Balazs Laurenczy
@date: 2017-2018
"""
new_config
=
load_config
(
config_file_path
)
# replace the fields of the base configuration with the values from the new one
for
field
,
value
in
new_config
.
items
():
config
=
overwrite_dict
(
config
,
field
,
value
)
return
config
def
overwrite_dict
(
config
,
field
,
value
):
# in case a field contains a dictionary itself
if
isinstance
(
value
,
dict
):
# just overwrite the sub-fields, do not overwrite the entire dictionary
for
field2
,
value2
in
value
.
items
():
config
[
field
]
=
overwrite_dict
(
config
[
field
],
field2
,
value2
)
# otherwise, just assign the value
else
:
config
[
field
]
=
value
return
config
Event Timeline
Log In to Comment