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

Feat/anywidget #338

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
27 changes: 12 additions & 15 deletions buckaroo/buckaroo_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from ipywidgets import DOMWidget
import json
import pandas as pd
import traitlets
from traitlets import Unicode, List, Dict, observe

from ._frontend import module_name, module_version
import anywidget


from .customizations.analysis import (TypingStats, ComputedDefaultSummaryStats, DefaultSummaryStats)
Expand All @@ -28,19 +28,18 @@
from .dataflow.dataflow import CustomizableDataflow, StylingAnalysis
from .dataflow.dataflow_extras import (Sampling, exception_protect, merge_column_config)
from .dataflow.autocleaning import PandasAutocleaning
import importlib.metadata
import pathlib

import anywidget


class BuckarooProjectWidget(DOMWidget):
class BuckarooProjectWidget(anywidget.AnyWidget):
"""
Repetitious code needed to make Jupyter communicate properly with any BuckarooWidget in this package

"""
_model_module = Unicode(module_name).tag(sync=True)
_view_module = Unicode(module_name).tag(sync=True)

_model_module_version = Unicode(module_version).tag(sync=True)
_view_module_version = Unicode(module_version).tag(sync=True)

pass


class PdSampling(Sampling):
Expand Down Expand Up @@ -73,11 +72,9 @@ class BuckarooWidget(CustomizableDataflow, BuckarooProjectWidget):
Also adds buckaroo_state object and communication to simpler CustomizableDataFlow implementations

"""
_esm = pathlib.Path(__file__).parent.parent / "src" / "buckaroo_anywidget" / "static" / "widget.js"
_css = pathlib.Path(__file__).parent.parent / "src" / "buckaroo_anywidget" / "static" / "widget.css"

#### DOMWidget Boilerplate
_model_name = Unicode('DCEFWidgetModel').tag(sync=True)
_view_name = Unicode('DCEFWidgetView').tag(sync=True)
#END DOMWidget Boilerplate

sampling_klass = PdSampling
autocleaning_klass = PandasAutocleaning #override the base CustomizableDataFlow klass
Expand Down Expand Up @@ -150,7 +147,7 @@ def to_widgetdcfecell_ex(self):

const buckaroo_state = {json.dumps(self.buckaroo_state, indent=4)}

const commandConfig = {json.dumps(self.commandConfig, indent=4)}
const command_config = {json.dumps(self.command_config, indent=4)}

const w_operations = {json.dumps(self.operations, indent=4)}

Expand All @@ -167,7 +164,7 @@ def to_widgetdcfecell_ex(self):
buckaroo_options={{buckaroo_options}}
buckaroo_state={{bState}}
on_buckaroo_state={{setBState}}
commandConfig={{commandConfig}}
command_config={{command_config}}
operations={{operations}}
on_operations={{setOperations}}
operation_results={{operation_results}}
Expand Down
4 changes: 2 additions & 2 deletions buckaroo/dataflow/autocleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def dumb_merge_ops(existing_ops, cleaning_ops):
class SentinelAutocleaning:

def __init__(self, confs):
self.commandConfig = {}
self.command_config = {}

def handle_ops_and_clean(self, df, cleaning_method, quick_command_args, existing_operations):
cleaning_ops = []
Expand Down Expand Up @@ -129,7 +129,7 @@ def _setup_from_command_kls_list(self, name):

c_defaults, c_patterns, df_interpreter, gencode_interpreter = configure_buckaroo(c_klasses)
self.df_interpreter, self.gencode_interpreter = df_interpreter, gencode_interpreter
self.commandConfig = dict(argspecs=c_patterns, defaultArgs=c_defaults)
self.command_config = dict(argspecs=c_patterns, defaultArgs=c_defaults)
self.quick_command_klasses = conf.quick_command_klasses


Expand Down
6 changes: 3 additions & 3 deletions buckaroo/dataflow/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, raw_df):
self.summary_sd = {}
self.existing_operations = []
self.ac_obj = self.autocleaning_klass(self.autoclean_conf)
self.commandConfig = self.ac_obj.commandConfig
self.command_config = self.ac_obj.command_config
try:
self.raw_df = raw_df
except Exception:
Expand All @@ -46,7 +46,7 @@ def __init__(self, raw_df):
autocleaning_klass = SentinelAutocleaning
autoclean_conf = tuple()

commandConfig = Dict({}).tag(sync=True)
command_config = Dict({}).tag(sync=True)


raw_df = Any('')
Expand Down Expand Up @@ -198,7 +198,7 @@ class CustomizableDataflow(DataFlow):
This allows targetd extension and customization of DataFlow
"""
analysis_klasses = [StylingAnalysis]
commandConfig = Dict({}).tag(sync=True)
command_config = Dict({}).tag(sync=True)
DFStatsClass = DfStats
sampling_klass = Sampling
df_display_klasses = {}
Expand Down
83 changes: 0 additions & 83 deletions js/baked_data/colorMap.ts

This file was deleted.

Loading
Loading