Skip to content

Commit e6c9975

Browse files
committed
various review changes
1 parent 0d70707 commit e6c9975

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

cylc/flow/data_store_mgr.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
}
216216

217217
# internal runtime to protobuf field name mapping
218-
RUNTIME_MAPPING = {
218+
RUNTIME_CFG_MAP_TO_FIELD = {
219219
'completion': 'completion',
220220
'directives': 'directives',
221221
'environment': 'environment',
@@ -244,7 +244,6 @@
244244
}
245245
RUNTIME_JSON_DUMPS = {'directives', 'environment', 'outputs'}
246246
RUNTIME_STRINGIFYS = {'execution time limit'}
247-
RUNTIME_TRY_ITEMS = {'platform': 'name'}
248247

249248

250249
def setbuff(obj, key, value):
@@ -353,41 +352,35 @@ def runtime_from_config(rtconfig):
353352
def runtime_from_partial(rtconfig, runtimeold=None):
354353
"""Populate runtime object from partial/full config.
355354
356-
Potentially slower with all the setattr calls, but no expected fields.
355+
Potentially slower than the non-partial one, due to tha the setattr calls,
356+
but does not have expected fields.
357357
"""
358358
runtime = PbRuntime()
359359
if runtimeold is not None:
360360
runtime.CopyFrom(runtimeold)
361361
for key, val in rtconfig.items():
362-
if val is None or key not in RUNTIME_MAPPING:
362+
if val is None or key not in RUNTIME_CFG_MAP_TO_FIELD:
363363
continue
364364
elif key in RUNTIME_LIST_JOINS:
365-
setattr(runtime, RUNTIME_MAPPING[key], listjoin(val))
365+
setattr(runtime, RUNTIME_CFG_MAP_TO_FIELD[key], listjoin(val))
366366
elif key in RUNTIME_JSON_DUMPS:
367367
setattr(
368368
runtime,
369-
RUNTIME_MAPPING[key],
369+
RUNTIME_CFG_MAP_TO_FIELD[key],
370370
json.dumps(
371371
[
372372
{'key': k, 'value': v}
373373
for k, v in val.items()
374374
]
375375
)
376376
)
377-
elif key in RUNTIME_TRY_ITEMS:
378-
try:
379-
setattr(
380-
runtime,
381-
RUNTIME_MAPPING[key],
382-
val[RUNTIME_TRY_ITEMS[key]]
383-
)
384-
except (KeyError, TypeError):
385-
with suppress(KeyError, TypeError):
386-
setattr(runtime, RUNTIME_MAPPING[key], val)
377+
elif key == 'platform' and isinstance(val, dict):
378+
with suppress(KeyError, TypeError):
379+
setattr(runtime, RUNTIME_CFG_MAP_TO_FIELD[key], val['name'])
387380
elif key in RUNTIME_STRINGIFYS:
388-
setattr(runtime, RUNTIME_MAPPING[key], str(val or ''))
381+
setattr(runtime, RUNTIME_CFG_MAP_TO_FIELD[key], str(val or ''))
389382
else:
390-
setattr(runtime, RUNTIME_MAPPING[key], val)
383+
setattr(runtime, RUNTIME_CFG_MAP_TO_FIELD[key], val)
391384
return runtime
392385

393386

cylc/flow/network/schema.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
FAMILIES,
6363
FAMILY_PROXIES,
6464
JOBS,
65+
RUNTIME_CFG_MAP_TO_FIELD,
6566
TASK_PROXIES,
6667
TASKS,
6768
)
@@ -874,19 +875,10 @@ class Meta:
874875

875876

876877
RUNTIME_FIELD_TO_CFG_MAP = {
877-
**{
878-
k: k.replace('_', ' ') for k in Runtime.__dict__
879-
if not k.startswith('_')
880-
},
881-
'init_script': 'init-script',
882-
'env_script': 'env-script',
883-
'err_script': 'err-script',
884-
'exit_script': 'exit-script',
885-
'pre_script': 'pre-script',
886-
'post_script': 'post-script',
887-
'work_sub_dir': 'work sub-directory',
878+
v: k
879+
for k, v in RUNTIME_CFG_MAP_TO_FIELD.items()
888880
}
889-
"""Map GQL Runtime fields' names to workflow config setting names."""
881+
"""Map Pb/GQL Runtime fields' names to workflow config setting names."""
890882

891883

892884
def runtime_schema_to_cfg(runtime: dict) -> dict:

tests/integration/test_reload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,9 @@ async def test_orphan_reload(
314314
start,
315315
log_filter,
316316
):
317-
"""Reload should not fail about orphaned tasks.
317+
"""Reload should not fail because of orphaned tasks.
318318
319-
The following aspects of reload about orphans are tested:
319+
The following aspects of reload-with-orphans are tested:
320320
- Broadcast deltas generated after reload.
321321
https://github.com/cylc/cylc-flow/issues/6814
322322
- Removal of both xtrigger and associated active/incomplete task.

0 commit comments

Comments
 (0)