feat: split Trouve into TrouveAbc + Trouve + PandasTrouve - #18
Merged
Conversation
Replace the df_fn field with a PandasTrouve class. A pandas transform is now a plain function that takes DataFrames, and the upstream Trouves come from an inputs list. Clair binds the inputs to the parameters by position. Before, a transform declared each dependency as a parameter default value. That made the pd.DataFrame annotation false, thus each parameter needed a `# type: ignore`, and a user could not call the function directly. The split introduces TrouveAbc, the abstract base that holds the attributes of every backend. Trouve keeps the SQL backend and its validation. This makes space for a Databricks backend later. - PandasTrouve validates the arity of the transform, and rejects *args/**kwargs - ClairDag, discovery, the compiler and the runner accept a TrouveAbc - The example project and every documentation page use the new API Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Resolve conflicts in favour of the PandasTrouve API from this branch, while it keeps the Simplified Technical English text and the routing exports from main. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Discovery gives a list[TrouveAbc] after the PandasTrouve split. The function reads only .compiled and .type, which the base class holds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
What
Replaces the
df_fnfield with aPandasTrouveclass, and splitsTrouveinto an abstract base plus one class per backend.Before — the dependency rode on the parameter default, so the annotation was false and every parameter needed a
# type: ignore:After — the transform is an honest function; the dependencies live on the Trouve:
Clair binds
inputsto the transform parameters by position, so parameter names are free.The class split
TrouveAbccolumns,tests,docs,run_config,compiledTrouvesqlPandasTrouveinputslistBackend-specific validation moved off the shared base:
_validate_sqlnow lives onTrouveonly. This is what makes room for aDatabricksTrouvelater.Why this shape
pd.DataFrameannotation is now true, so no# type: ignore— verified withty.PandasTrouvevalidates transform arity at import time and rejects*args/**kwargs, with an error naming the parameters.dag.get_trouve()returnsTrouveAbc,tynow forces explicit narrowing before any.sql/.transform/.build_sqlaccess. Several call sites gainedisinstanceasserts as a result.Breaking change
df_fnis removed rather than deprecated — pre-1.0, and keeping it would defeat the split. All in-repo callers migrated.Notes
# type: ignorecame from pandas stubs (groupby().size()types asSeries), not from clair. Rewritten as.agg(event_count=("event_type", "size")), which typechecks clean.CompiledAttributes.resolved_df_fnrenamed toresolved_transform.build_dag/find_routing_collisions/recompile_for_selectiontakeSequence[TrouveAbc]—listis invariant, so alist[Trouve]would not have been accepted.Verification
uv run pytest tests/— 529 passeduvx ruff check .— cleanuvx ty check --exclude example_notebooks— cleanmkdocs build --strict— cleanclair dagandclair compileonexample_projects/example_4— DAG resolves with the[PANDAS]node in place, and the compiled artifact header mapsrefined_events -> example_4_database.refined.eventsDocs updated: the pandas guide, the Trouve API reference, the Trouve concept page, the landing page, the reference index, and the README.
🤖 Generated with Claude Code