Repository navigation
Conversation
Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
Manishram-ai
approved these changes
Nov 1, 2026
Manishram-ai
left a comment
There was a problem hiding this comment.
I tested this locally. On master, timedelta(hours=-1) serializes to -1 w 6 d 23 h 0 m 0 s, and parse can't read it back. With your change the round trip works and all 162 tests in parameter_test.py pass. Your new test also fails on master, so it catches the bug.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
TimeDeltaParameter.serializenow falls back to a bare number of seconds (str(x.total_seconds())) when the value is negative or has a microsecond part.parsealready accepts that form through itsfloat()branch. Non negative whole second values keep the existing"n w n d n h n m n s"output, so their task ids are unchanged.Motivation and Context
The
"w d h m s"form cannot express these values:timedelta(hours=-1)serializes to-1 w 6 d 23 h 0 m 0 s, whichparserejects. A task with such a parameter yielded as a dynamic dependency makesluigi.buildraiseParameterException: Invalid time delta - could not parse -1 w 6 d 23 h 0 m 0 s, because the worker rebuilds the task fromto_str_params().timedelta(milliseconds=200)andtimedelta(milliseconds=700)both serialize to0 w 0 d 0 h 0 m 0 s, so tasks that differ only in that parameter share atask_id.This is the part of #1966 that #1968 did not cover.
The check reads
microsecondswithgetattrso duck typed values, as used intest_warn_on_non_timedelta_param, keep working.Have you tested this? If so, how?
I have included unit tests.
testSerializeRoundTripNegativeAndSubSecondintest/parameter_test.pyfails on master and passes with this change.test/parameter_test.py,test/task_test.py,test/date_interval_test.py,test/date_parameter_test.pyandtest/task_register_test.pypass locally (246 passed). I also ran the dynamic dependency example from the issue: on master it raises theParameterException, with this change both tasks run.Fixes #3473