Skip to content

Preserve microseconds when serializing TimeDeltaParameter - #3465

Open
rioyu123 wants to merge 1 commit into
spotify:masterfrom
rioyu123:fix/timedelta-fractional-serialization
Open

rioyu123 wants to merge 1 commit into
spotify:masterfrom
rioyu123:fix/timedelta-fractional-serialization

Conversation

@rioyu123

@rioyu123 rioyu123 commented Oct 4, 2026

Copy link
Copy Markdown

Description

Preserve microseconds when serializing TimeDeltaParameter. Fractional durations now use decimal seconds, such as 0.250000 or -1.234567. Whole-second durations keep their existing serialized values and task IDs.

Numeric strings are parsed with an isolated decimal context and rounded once to microsecond precision. This also keeps long durations exact when tasks are deserialized, without depending on the caller's decimal settings. Non-string inputs retain the existing parsing behavior.

Motivation and Context

TimeDeltaParameter already accepts fractional seconds, but serialization discarded the fraction. Tasks with durations of 0.25 seconds and 0.75 seconds therefore received the same task ID. In a local scheduler run, luigi.build() reported success while executing only one of them.

Task IDs for fractional durations will change to resolve this collision. Whole-second task IDs are unchanged.

Have you tested this? If so, how?

  • Added 25 cases covering actual local-scheduler execution, task serialization/deserialization, positive and negative durations, timedelta bounds, rounding and decimal-context independence. On unchanged master, 15 fail and 10 controls pass; all pass with the fix.
  • Parameter and task suites: 226 passed on Windows and Linux. The existing timedelta-like object warning test remains unchanged and passes.
  • tox run -e lint and tox run -e docs pass.
  • tox run -e py310-core: 1,560 passed, 24 skipped, 5 failed. All five failures are existing test/server_test.py::_ServerTest setup errors (TypeError: 'str' object is not callable), independently reproduced on unchanged master in the same environment. No new failures remain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant