Azure / Azure-TDSP-Utilities

Utilities and scripts developed as part of Microsoft's Team Data Science Process for productive data science
Creative Commons Attribution 4.0 International
373 stars 275 forks source link

Not resolved....(issue #34 ) #37

Closed lihka1 closed 6 years ago

lihka1 commented 6 years ago

When I update the ipywidgets, I get the error ...issue #26(Error in IDEAR.ipynb ('int' object has no attribute 'children') #26)

guybartal commented 6 years ago

+1 i didn't update ipywidgets, i've just clone this repo into new DSVM and got the same error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-861d7cb8f6e1> in <module>()
----> 1 i = interactive(TargetAnalytics.custom_barplot, df=fixed(df),                                                     filename=fixed(filename), col1=w1, Export=w_export)

C:\Anaconda\envs\py35\lib\site-packages\ipywidgets\widgets\interaction.py in __init__(self, _interactive__interact_f, _interactive__options, **kwargs)
    192             getcallargs(f, **{n:v for n,v,_ in new_kwargs})
    193         # Now build the widgets from the abbreviations.
--> 194         self.kwargs_widgets = self.widgets_from_abbreviations(new_kwargs)
    195 
    196         # This has to be done as an assignment, not using self.children.append,

C:\Anaconda\envs\py35\lib\site-packages\ipywidgets\widgets\interaction.py in widgets_from_abbreviations(self, seq)
    292             if not (isinstance(widget, ValueWidget) or isinstance(widget, fixed)):
    293                 if widget is None:
--> 294                     raise ValueError("{!r} cannot be transformed to a widget".format(abbrev))
    295                 else:
    296                     raise TypeError("{!r} is not a ValueWidget".format(widget))

ValueError: Button(description='Export', style=ButtonStyle()) cannot be transformed to a widget

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-12-b4e23ca35cec> in <module>()
     21     get_ipython().magic('reset_report')
     22     get_ipython().magic('add_interaction_code_to_report i = interactive(TargetAnalytics.custom_barplot, df=fixed(df),                                                     filename=fixed(filename), col1=w1, Export=w_export)')
---> 23     hbox = widgets.HBox(i.children)
     24     display(hbox)
     25     hbox.on_displayed(TargetAnalytics.custom_barplot(df=df0, filename=filename, col1=w1.value, Export=w_export))

AttributeError: 'int' object has no attribute 'children'

when running this cell:

md_text = '## Target Variable'
filename = 'tmp/target_variables.csv'
export_filename = 'target_report2.ipynb'

if conf_dict['Target'] in conf_dict['CategoricalColumns']:
    w1_value,w2_value,w3_value = '','',''
    w1, w2, w3, w4 = None, None, None, None
    silentremove(filename)    
    w1 = widgets.Dropdown(
        options=[conf_dict['Target']],
        value=conf_dict['Target'],
        description='Target Variable:',
    )

    ReportMagic.var_files = filename
    w_export = widgets.Button(description='Export', value='Export')
    handle_export_partial = partial(handle_export, w1=w1, w2=w2, w3=w3, export_filename=export_filename, md_text=md_text)      
    w1.observe(handle_change,'value')
    w_export.on_click(handle_export_partial)

    %reset_report
    %add_interaction_code_to_report i = interactive(TargetAnalytics.custom_barplot, df=fixed(df), \
                                                    filename=fixed(filename), col1=w1, Export=w_export)
    hbox = widgets.HBox(i.children)
    display(hbox)
    hbox.on_displayed(TargetAnalytics.custom_barplot(df=df0, filename=filename, col1=w1.value, Export=w_export))
else:
    w1_value, w2_value, w3_value = '', '', ''
    w1, w2, w3, w4 = None, None, None, None
    silentremove(filename) 
    w1 = widgets.Dropdown(
            options=[conf_dict['Target']],
            value=conf_dict['Target'],
            description='Target Variable:',
        )
    w_export = widgets.Button(description='Export', value='Export')
    handle_export_partial = partial(handle_export, w1=w1, w2=w2, w3=w3, export_filename=export_filename, md_text=md_text)       
    w1.observe(handle_change,'value')
    w_export.on_click(handle_export_partial)

    %reset_report
    %add_interaction_code_to_report i = interactive(NumericAnalytics.custom_barplot, df=fixed(df), filename=fixed(filename),\
                                                    col1=w1, Export=w_export)
    hbox = widgets.HBox(ii.children)
    display(hbox)
    hbox.on_displayed(NumericAnalytics.custom_barplot(df=df, filename=filename, col1=w1.value, Export=w_export))
murwebb commented 6 years ago

i am having the same issue

Norticaranda commented 6 years ago

I am too Any track? Thanks

elenaterenzi commented 6 years ago

as per my comment in the other open issue (https://github.com/Azure/Azure-TDSP-Utilities/issues/38):

so it looks like all you need to do is downgrade ipywidgets to 4: i did the following:

pip uninstall ipywidgets
pip install ipywidgets==4

and it worked I would highly recommend the team developing this tooling to provide a conda dependencies yml file to ensure environment is created with all the right dependencies

jreynolds01 commented 6 years ago

I've just created a pull request to add a conda environment yml file to address this.