Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow platform default directives #4896

Merged
merged 5 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
  • Loading branch information
wxtim and MetRonnie committed May 26, 2022
commit fc67717f3ab6e8b72071ebb033a7d56059ed4b48
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': {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MetRonnie - I knew there should be a 1-line for this!

**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