@@ -49,7 +49,7 @@ def __init__(
49
49
dry_run : bool = False ,
50
50
key_path : Optional [list [str ]] = None ,
51
51
schema_file : Optional [Path ] = None ,
52
- controller : Optional [str ] = None ,
52
+ controller : Optional [list [ str ] ] = None ,
53
53
) -> None :
54
54
config_input = config if isinstance (config , YAMLConfig ) else YAMLConfig (config = config )
55
55
config_input .dereference (
@@ -65,8 +65,7 @@ def __init__(
65
65
self ._config : dict = self ._config_intermediate [self .driver_name ()]
66
66
except KeyError as e :
67
67
raise UWConfigError ("Required '%s' block missing in config" % self .driver_name ()) from e
68
- if controller :
69
- self ._config [STR .rundir ] = self ._config_intermediate [controller ][STR .rundir ]
68
+ self ._delegate (controller , STR .rundir )
70
69
self .schema_file = schema_file
71
70
self ._validate ()
72
71
dryrun (enable = dry_run )
@@ -167,6 +166,19 @@ def _create_user_updated_config(
167
166
else :
168
167
log .debug (f"Failed to validate { path } " )
169
168
169
+ def _delegate (self , controller : Optional [list [str ]], config_key : str ) -> None :
170
+ """
171
+ Selectively delegate config to controller.
172
+
173
+ :param controller: Key(s) leading to block in config controlling run-time values.
174
+ :param config_key: Name of config item to delegate to controller.
175
+ """
176
+ if controller :
177
+ val = self ._config_intermediate [controller [0 ]]
178
+ for key in controller [1 :]:
179
+ val = val [key ]
180
+ self ._config [config_key ] = val [config_key ]
181
+
170
182
# Public helper methods
171
183
172
184
@classmethod
@@ -241,7 +253,7 @@ def __init__(
241
253
dry_run : bool = False ,
242
254
key_path : Optional [list [str ]] = None ,
243
255
schema_file : Optional [Path ] = None ,
244
- controller : Optional [str ] = None ,
256
+ controller : Optional [list [ str ] ] = None ,
245
257
):
246
258
super ().__init__ (
247
259
cycle = cycle ,
@@ -274,7 +286,7 @@ def __init__(
274
286
dry_run : bool = False ,
275
287
key_path : Optional [list [str ]] = None ,
276
288
schema_file : Optional [Path ] = None ,
277
- controller : Optional [str ] = None ,
289
+ controller : Optional [list [ str ] ] = None ,
278
290
):
279
291
super ().__init__ (
280
292
cycle = cycle ,
@@ -314,7 +326,7 @@ def __init__(
314
326
dry_run : bool = False ,
315
327
key_path : Optional [list [str ]] = None ,
316
328
schema_file : Optional [Path ] = None ,
317
- controller : Optional [str ] = None ,
329
+ controller : Optional [list [ str ] ] = None ,
318
330
):
319
331
super ().__init__ (
320
332
config = config ,
@@ -339,7 +351,7 @@ def __init__(
339
351
key_path : Optional [list [str ]] = None ,
340
352
batch : bool = False ,
341
353
schema_file : Optional [Path ] = None ,
342
- controller : Optional [str ] = None ,
354
+ controller : Optional [list [ str ] ] = None ,
343
355
):
344
356
super ().__init__ (
345
357
cycle = cycle ,
@@ -351,8 +363,7 @@ def __init__(
351
363
controller = controller ,
352
364
)
353
365
self ._batch = batch
354
- if controller :
355
- self ._config [STR .execution ] = self .config_full [controller ][STR .execution ]
366
+ self ._delegate (controller , STR .execution )
356
367
357
368
# Workflow tasks
358
369
@@ -541,7 +552,7 @@ def __init__(
541
552
key_path : Optional [list [str ]] = None ,
542
553
batch : bool = False ,
543
554
schema_file : Optional [Path ] = None ,
544
- controller : Optional [str ] = None ,
555
+ controller : Optional [list [ str ] ] = None ,
545
556
):
546
557
super ().__init__ (
547
558
cycle = cycle ,
@@ -576,7 +587,7 @@ def __init__(
576
587
key_path : Optional [list [str ]] = None ,
577
588
batch : bool = False ,
578
589
schema_file : Optional [Path ] = None ,
579
- controller : Optional [str ] = None ,
590
+ controller : Optional [list [ str ] ] = None ,
580
591
):
581
592
super ().__init__ (
582
593
cycle = cycle ,
@@ -618,7 +629,7 @@ def __init__(
618
629
key_path : Optional [list [str ]] = None ,
619
630
batch : bool = False ,
620
631
schema_file : Optional [Path ] = None ,
621
- controller : Optional [str ] = None ,
632
+ controller : Optional [list [ str ] ] = None ,
622
633
):
623
634
super ().__init__ (
624
635
config = config ,
@@ -650,7 +661,7 @@ def _add_docstring(class_: type, omit: Optional[list[str]] = None) -> None:
650
661
:param key_path: Keys leading through the config to the driver's configuration block.
651
662
:param batch: Run component via the batch system?
652
663
:param schema_file: Path to schema file to use to validate an external driver.
653
- :param controller: Name of block in config controlling run-time values.
664
+ :param controller: Key(s) leading to block in config controlling run-time values.
654
665
"""
655
666
setattr (
656
667
class_ ,
0 commit comments