fix(core): point misplaced run kwargs at the call site that works (P1-03) - #260
Open
migarci2 wants to merge 1 commit into
Open
fix(core): point misplaced run kwargs at the call site that works (P1-03)#260migarci2 wants to merge 1 commit into
migarci2 wants to merge 1 commit into
Conversation
…-03)
Pipeline options live in three places — the constructor, the fluent builders,
and the run entry points — with no rule a caller can guess. `timeout` is a
`run()` kwarg; `cache` is a builder. Guessing wrong produced a dead end:
TypeError: Pipeline.run() got an unexpected keyword argument 'cache'
which names neither where caching is configured nor how to spell it, so the
only way out was to read the source. It now reads:
TypeError: Pipeline.run() got an unexpected keyword argument 'cache' —
caching is configured on the pipeline: .cache(StepCache(...)).
`run`, `arun`, `batch_run` and `abatch_run` take `**unsupported` and reject it
immediately, so the signatures are not widened at runtime: every unknown
keyword still raises TypeError, and names outside the redirect table keep
CPython's exact wording so existing string matches still hold.
`max_concurrency` is a real parameter of arun/batch_run/abatch_run, so Python
binds it there and it never reaches the table; the redirect only fires on
run(), the one entry point that does not take it.
This is the error-message half of feedback.md row P1-03, not the alias half —
accepting `run(cache=...)` is an API-surface decision scoped for Wave 3B and
would widen the three-places problem rather than narrow it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Improves developer ergonomics in genblaze-core by turning “misplaced kwarg” TypeErrors on pipeline run entry points into actionable messages that point callers at the correct constructor/builder API, and documents where pipeline options belong.
Changes:
- Add a mapping of commonly-misplaced run-entry-point kwargs to “where this option actually lives” hints, and reject unsupported kwargs early in
run/arun/batch_run/abatch_run. - Add unit tests pinning redirect messages while preserving CPython’s exact wording for genuinely unknown kwargs.
- Document option placement in
docs/features/pipeline.mdand record the behavior change inCHANGELOG.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| libs/core/genblaze_core/pipeline/pipeline.py | Adds misplaced-kwarg hint table + a shared rejection helper; updates run entry points to collect and reject unsupported kwargs. |
| libs/core/tests/unit/test_pipeline_misplaced_kwargs.py | Adds regression tests for redirect messaging, CPython wording preservation, and max_concurrency asymmetry behavior. |
| docs/features/pipeline.md | Documents where options belong (constructor vs builders vs run entry points). |
| CHANGELOG.md | Notes the improved TypeError messaging behavior under [Unreleased] for genblaze-core. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
1964
to
1968
| on_retry: Any = None, | ||
| _config_override: RunnableConfig | None = None, | ||
| _owns_sink: bool = True, | ||
| **unsupported: Any, | ||
| ) -> PipelineResult: |
| constructor- or builder-level option is passed to them. `run(cache=...)` | ||
| previously produced a bare `got an unexpected keyword argument 'cache'`, | ||
| which named neither where caching is configured nor how to spell it; | ||
| it now adds `— caching is configured on the pipeline: |
Comment on lines
2200
to
2204
| on_retry: Any = None, | ||
| _config_override: RunnableConfig | None = None, | ||
| _owns_sink: bool = True, | ||
| **unsupported: Any, | ||
| ) -> PipelineResult: |
Comment on lines
2884
to
2888
| on_progress: Any = None, | ||
| pipeline_timeout: float | None = None, | ||
| on_step_complete: Any = None, | ||
| **unsupported: Any, | ||
| ) -> list[PipelineResult]: |
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
Pipeline options live in three places — the constructor, the fluent builders,
and the run entry points — and there is no rule a caller can guess about which
is which.
timeoutis arun()kwarg;cacheis a builder. Both read as "howthis run behaves".
When you guess wrong, the error is a dead end:
Correct, but it names neither where caching is configured nor how to spell it
there, so the loop is guess →
TypeError→ grep the source. After this PR:Changes
libs/core/genblaze_core/pipeline/pipeline.py_MISPLACED_RUN_KWARGS— a module-level table mapping a misplaced optionto the call site that works. Covers
cache,config,metadata,tracer,preflight,tenant_id,project_id,chain,moderation,structured_log,max_concurrency.Pipeline._reject_unsupported_run_kwargs()— a static helper in the sameshape as the existing
_reject_config_tenant()(fail loudly, point at thesupported path).
run,arun,batch_run,abatch_runtake**unsupportedand reject iton the first line.
The signatures are not actually widened at runtime: every unknown keyword
still raises
TypeError. Names not in the table keep CPython's exact wording(
Pipeline.run() got an unexpected keyword argument 'typo'), with no trailinghint, so anything matching on that string still matches. There is a test
pinning that.
max_concurrencydeserves a note. It is a real parameter ofarun(),batch_run()andabatch_run(), so Python binds it normally there and itnever reaches the table. It only fires on
run()— the one entry point thatdoes not take it — where the hint points at the async/batch entry points. A
test pins that
batch_run(..., max_concurrency=1)still works, so the tablecannot shadow a genuine parameter.
stream()/astream()forward**run_kwargstorun()/arun(), so theyinherit the redirect for free.
libs/core/tests/unit/test_pipeline_misplaced_kwargs.py— 20 tests: eachredirect message, the
max_concurrencyasymmetry both ways, CPython wordingpreserved for unknown names, all four entry points plus
stream(), and twohappy-path tests asserting every documented
run()kwarg still binds. 12fail on
main.docs/features/pipeline.md— a "Where each option goes" table, including thethree run kwargs that are not universal (
progressandon_retryarerun()/arun()only;max_concurrencyis everywhere exceptrun()).Verified against the live signatures rather than written from memory.
CHANGELOG.md—[Unreleased]entry undergenblaze-core.Notes for reviewers
This is the "better error" half of
docs/exec-plans/feedback.mdrow P1-03,deliberately not the alias half. Making
run(cache=...)actually work is anAPI-surface decision the plan already scopes for Wave 3B, and it would make the
three-places problem worse rather than better. This PR only makes the wrong
guess self-correcting. If you'd rather land the alias instead, or keep the
docs table without the
**unsupportedcatch, say so and I'll rework or closeit — the table alone is still worth having.
Test plan
make testpassesmake typecheckpasses (mypy, 92 source files)ruff check libs/ cli/ examples/clean;ruff format --checkclean onthe changed files
make lint— theruff format --checkstep reports 17 pre-existingREADME/CHANGELOG code-block findings already present on a clean
af84f8b; the count is unchanged by this branch and none are in files ittouches
main(12 of 20), pass with the changeRelated
docs/exec-plans/feedback.mdrow P1-03 (partial — error message only)