Skip to content

luigi: silence 'not of type string' warnings on run_id_dir / callback#672

Merged
neoneye merged 1 commit intomainfrom
fix/luigi-parameter-type-warnings
May 5, 2026
Merged

luigi: silence 'not of type string' warnings on run_id_dir / callback#672
neoneye merged 1 commit intomainfrom
fix/luigi-parameter-type-warnings

Conversation

@neoneye
Copy link
Copy Markdown
Member

@neoneye neoneye commented May 5, 2026

Summary

Production logs emitted two UserWarnings 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.

Both were declared as plain luigi.Parameter while holding a pathlib.Path and a bound method.

Fix

New 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 on its own silences the string-type warning: Luigi's Parameter._warn_on_wrong_param_type returns early when self.__class__ != Parameter.

Wire-up:

  • PlanTask.run_id_dirPathParameter
  • PlanTask._pipeline_executor_callbackCallableParameter
  • InitialPlanRawTask.run_id_dirPathParameter (the warning also fired here once worker_plan: represent plan_raw.json as InitialPlanRawTask #666 introduced the ExternalTask, since self.clone(InitialPlanRawTask) propagates the parent's Path).

Test plan

  • Generate a plan and confirm the two UserWarning lines no longer appear in the logs.
  • Spot-check that self.run_id_dir / FilenameEnum.X.value still works in tasks that read it as a Path.

🤖 Generated with Claude Code

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`).
@neoneye neoneye merged commit ebb4bc7 into main May 5, 2026
3 checks passed
@neoneye neoneye deleted the fix/luigi-parameter-type-warnings branch May 5, 2026 19:43
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