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
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 1959
Build 2364: tox-on-jenkinsJenkins
Build 2363: arc lint + arc unit

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.