luigi: silence 'not of type string' warnings on run_id_dir / callback#672
Merged
luigi: silence 'not of type string' warnings on run_id_dir / callback#672
Conversation
Production logs were emitting two `UserWarning`s on every Luigi
task instantiation:
Parameter "run_id_dir" with value "/app/run/…" is not of type string.
Parameter "_pipeline_executor_callback" with value "<bound method …>"
is not of type string.
…because both were declared as plain `luigi.Parameter` while
holding a `pathlib.Path` and a bound method respectively.
Add `worker_plan_internal/luigi_util/parameters.py`:
- `PathParameter` — accepts `str|Path`, normalizes/parses to
`Path`, serializes to `str`.
- `CallableParameter` — non-significant private slot for bound
methods.
Both subclass `luigi.Parameter`, which is enough on its own to
skip the string-type warning: Luigi's
`Parameter._warn_on_wrong_param_type` returns early when
`self.__class__ != Parameter`.
Wire-up:
- `PlanTask.run_id_dir` -> `PathParameter`.
- `PlanTask._pipeline_executor_callback` -> `CallableParameter`.
- `InitialPlanRawTask.run_id_dir` -> `PathParameter` (the warning
also fired here once #666 introduced the ExternalTask, since
`self.clone(InitialPlanRawTask)` propagates the parent's `Path`).
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.
Summary
Production logs emitted two
UserWarnings on every Luigi task instantiation:Both were declared as plain
luigi.Parameterwhile holding apathlib.Pathand a bound method.Fix
New
worker_plan_internal/luigi_util/parameters.py:PathParameter— acceptsstr | Path, normalizes/parses toPath, serializes tostr.CallableParameter— non-significant private slot for bound methods.Both subclass
luigi.Parameter, which on its own silences the string-type warning: Luigi'sParameter._warn_on_wrong_param_typereturns early whenself.__class__ != Parameter.Wire-up:
PlanTask.run_id_dir→PathParameterPlanTask._pipeline_executor_callback→CallableParameterInitialPlanRawTask.run_id_dir→PathParameter(the warning also fired here once worker_plan: represent plan_raw.json as InitialPlanRawTask #666 introduced theExternalTask, sinceself.clone(InitialPlanRawTask)propagates the parent'sPath).Test plan
UserWarninglines no longer appear in the logs.self.run_id_dir / FilenameEnum.X.valuestill works in tasks that read it as aPath.🤖 Generated with Claude Code