Repository navigation
Conversation
…i.Task class names Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
kitagry
left a comment
There was a problem hiding this comment.
Thanks! I checked both claims against _make_hash_id and gokart.utils.flatten, and both hold: renaming the keys of requires() (or swapping which key maps to which task while keeping the order of the values) keeps the id, and so does swapping a plain luigi.Task / ExternalTask dependency for another class with the same significant parameters. With gokart.build the second run returns the stale output of the first one, so the warning is worth having. The RST builds with no new Sphinx warnings.
Some suggestions, mostly on the workarounds:
-
rerun=Truedoes not fix the tasks downstream.rerunissignificant=False, so it does not changemake_unique_id(). A task that depends on the rewired task keeps its old output, and since that downstream task is already complete, the task withrerun=Trueis not even scheduled. In my check,Final -> Sub(rerun=True)still returned the old result after rewiringSub.requires(), whileSub(serialized_task_definition_check=True)changed Sub's id andFinalre-ran.docs/task_settings.rst("rerun" section) already explains this and recommends adding or bumping a significant parameter (e.g. a version parameter) instead. Could the note point there, along these lines?To avoid this, set
serialized_task_definition_check=True, or add a significant parameter (e.g. a version) and change it when you changerequires()(see :doc:task_settings).rerun=Trueonly re-runs the task itself; it does not change the hash, so tasks that depend on it keep their existing outputs. -
What
serialized_task_definition_check=Truehashes.get_own_code()collects the source of the methods of the class only. Ifrequires()uses a class attribute (e.g.dep_cls = LAandreturn {'ext': self.dep_cls()}), changing it todep_cls = LBkeeps the id, and the stale output is reused. The same applies to module-level helpers or aliases and to changes inside the dependency class. Maybe "the source code of the methods of the task, includingrequires(), is then hashed (class attributes and code outside the class are not)". It is also worth saying that turning it on changes the id (so the existing outputs of this task and its downstream tasks are recomputed once), and that any later edit to a method, even inrun(), does the same. -
Scope of the dict-key caveat. It applies to a hand-written
requires(). With the defaultrequires()(dependencies passed asTaskInstanceParameter), the keys are the parameter names, and they are hashed through the task's own parameters:D(a=X(), b=Y())andD(a=Y(), b=X())get different ids. Saying "a dict returned by an overriddenrequires()" would avoid scaring users of the common pattern. -
"which includes its class name" is only the bare
__class__.__name__(no module, no namespace). Two same-namedTaskOnKartclasses from different modules with the same parameters get the same id, so swapping the import inrequires()has the same problem as the plainluigi.Taskcase. A dependency withsignificant=Falseis dropped from the hash entirely. Maybe worth a short mention, since the note reads as the list of what is not included. -
(nit, optional) Only the flattened values are hashed, so the container shape is not part of the id either (
{'a': X(), 'b': Y()},[X(), Y()],(X(), Y()), nested dicts, andX()vs[X()]). And the other way round, reordering the entries of the dict without changing the mapping does change the id and re-runs the task. -
(question) #682 lists hashing the keys / the class name as possible fixes. Should this PR use
Refs #682instead ofCloses #682, so the fix can still be considered for 2.0.0 (#685)? Fine either way if documenting it is the decision.
Minor: the added block leaves three blank lines before the TaskOnKart.load heading (two elsewhere). In the PR description, _make_hash_id uses gokart.utils.flatten (a copy of luigi.task.flatten), not luigi.task.flatten itself; it behaves the same for dicts.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks for the careful review! All addressed in the latest commit:
Also fixed the blank-line count before the |
Refs #682
Summary
Added a note to docs/task_on_kart.rst about what is excluded from make_unique_id() (no changes to code behavior).
Verification
🤖 Generated with Claude Code