Page MenuHomeSoftware Heritage

swh.scheduler.utils: Allow to add more task information
ClosedPublic

Authored by ardumont on Oct 26 2018, 8:36 PM.

Details

Summary

... as in the missing retries_left configuration.

  • Also add test on that function.

Related D608#inline-2891

Test Plan

tox

Diff Detail

Repository
rDSCH Scheduling utilities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

No change, just plug the diff to branch 'update-utils'.

vlorentz requested changes to this revision.EditedOct 29 2018, 9:19 AM

As there is no copy of kwargs, the new for loop also modifies task['arguments']['kwargs'].

Although this is the correct behavior, it's not obvious it happens when reading the code. I suggest rewriting the function like this:

task_extra = {}
for extra_key in ['priority', 'retries_left']:
    if extra_key in kwargs:
        extra_val = kwargs.pop(extra_key)
        task_extra[extra_key] = extra_val

task = {
    'policy': policy,
    # ...
}
task.update(task_extra)
This revision now requires changes to proceed.Oct 29 2018, 9:19 AM
  • swh.scheduler.utils: Improve implementation to clarify intent
This revision is now accepted and ready to land.Oct 29 2018, 9:36 AM
This revision was automatically updated to reflect the committed changes.