Skip to content

fix(widget): support format="predicate" in selection() - #288

Merged
donghaoren merged 1 commit into
apple:mainfrom
kwy404:fix-widget-selection-predicate
Oct 27, 2026
Merged

donghaoren merged 1 commit into
apple:mainfrom
kwy404:fix-widget-selection-predicate

Conversation

@kwy404

@kwy404 kwy404 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Root cause: EmbeddingAtlasWidget.selection (packages/backend/embedding_atlas/widget.py) documents 'dataframe', 'arrow' and 'predicate' as formats, and its error message lists all three, but only 'dataframe' and 'arrow' are handled. Asking for the predicate always raises:

widget = EmbeddingAtlasWidget(df, x="x", y="y")
widget.selection(format="predicate")
# ValueError: invalid format, supported options are 'dataframe', 'arrow', and 'predicate'

Fix: return self._predicate for format="predicate", before running the query. It is the SQL predicate the frontend syncs for the current selection, or None when nothing is selected, the same value the Streamlit component returns as predicate.

Test: added test_selection_as_predicate to packages/backend/tests/test_widget.py. It checks that the predicate is None without a selection and is returned as is once set. Before the fix it fails with the ValueError above, after the fix pytest tests/test_widget.py passes, and ruff format --check is clean.

@donghaoren
donghaoren enabled auto-merge (squash) October 27, 2026 00:11
@donghaoren
donghaoren merged commit 69ebd39 into apple:main Oct 27, 2026
8 checks passed
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.

2 participants