Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
  • Loading branch information
wxtim and MetRonnie committed May 26, 2022
1 parent 8ee49f8 commit fc67717
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Fourth Release Candidate for Cylc 8 suitable for acceptance testing.
### Enhancements

[#4896](https://github.com/cylc/cylc-flow/pull/4896) - Allow the setting of
default job runner directives for plaforms.
default job runner directives for platforms.

[#4887](https://github.com/cylc/cylc-flow/pull/4887) - Disallow relative paths
in `global.cylc[install]source dirs`.
Expand Down
6 changes: 3 additions & 3 deletions cylc/flow/cfgspec/globalcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,10 +1314,10 @@
``hosts = main, backup, failsafe``.
''')
with Conf('directives', desc='''
Job runner (batch scheduler) directives.
Default directives for :cylc:conf:
:Defaults for: :cylc:conf:
`flow.cylc[runtime][<namespace>][directives]`
Job runner (batch scheduler) directives.
'''):
Conf('<directive>', VDR.V_STRING, desc='''
Example directives for the built-in job runner handlers
Expand Down
27 changes: 3 additions & 24 deletions cylc/flow/task_job_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,27 +1278,6 @@ def _prep_submit_task_job_impl(self, workflow, itask, rtconfig):
job_d=job_d
)

@staticmethod
def default_dict_merger(defaults, tdef):
"""Use directive from platform if not set in rtconfig.
For item in defaults add item to output if not in tdef.
Examples:
>>> defaults = {'use': 1, 'override': 1}
>>> tdef = {'override': 2, 'nodefault': 1}
>>> result = TaskJobManager.default_dict_merger(defaults, tdef)
>>> {i: result[i] for i in sorted(result)}
{'nodefault': 1, 'override': 2, 'use': 1}
"""
output = {}
for key in set(list(defaults.keys()) + list(tdef.keys())):
if key in defaults and key not in tdef:
output[key] = defaults[key]
else:
output[key] = tdef[key]
return output

def get_job_conf(
self,
workflow,
Expand All @@ -1320,9 +1299,9 @@ def get_job_conf(
itask.platform['job runner command template']
),
'dependencies': itask.state.get_resolved_dependencies(),
'directives': self.default_dict_merger(
itask.platform['directives'], rtconfig['directives']
),
'directives': {
**itask.platform['directives'], **rtconfig['directives']
},
'environment': rtconfig['environment'],
'execution_time_limit': itask.summary[self.KEY_EXECUTE_TIME_LIMIT],
'env-script': rtconfig['env-script'],
Expand Down

0 comments on commit fc67717

Please sign in to comment.