Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for auto filtering generation #501

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion doc/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,3 @@ button.copybtn:hover {
ul.current.nav.bd-sidenav {
padding: 0;
}

15 changes: 11 additions & 4 deletions lumen/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,19 @@ class Pipeline(Viewer, Component):
_required_fields: ClassVar[List[str | Tuple[str, str]]] = [('source', 'pipeline')]
_valid_keys: ClassVar[List[str] | Literal['params'] | None] = 'params'

def __init__(self, *, source, table, **params):
if 'schema' not in params:
params['schema'] = source.get_schema(table)
def __init__(self, *, source, table, schema=None, filters=None, **params):
if schema is None:
schema = source.get_schema(table)
if filters == 'auto':
filters = [
Filter.from_spec(filt, source_schema={table: schema})
for filt in auto_filters(schema).values()
]
elif filters is None:
filters = []
if any(isinstance(t, SQLTransform) for t in params.get('transforms', [])):
raise TypeError('Pipeline.transforms must be regular Transform components, not SQLTransform.')
super().__init__(source=source, table=table, **params)
super().__init__(source=source, table=table, filters=filters, schema=schema, **params)
self._update_widget = pn.Param(self.param['update'], widgets={'update': {'button_type': 'success'}})[0]
self._init_callbacks()

Expand Down