Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Update plotly in blog posts for Colab #17

Open
MaxGhenis opened this issue Jul 16, 2020 · 1 comment
Open

Update plotly in blog posts for Colab #17

MaxGhenis opened this issue Jul 16, 2020 · 1 comment

Comments

@MaxGhenis
Copy link
Contributor

Running https://colab.research.google.com/github/UBICenter/blog/blob/master/jb/20200707/adult_child_ubi.ipynb shows this error. I think it's because it's running an old version of plotly, so Colab notebooks should update plotly. cc @ngpsu22

ValueError                                Traceback (most recent call last)
<ipython-input-1-c893d11fa016> in <module>()
    201            title='Overall poverty rate and spending on cash transfer programs',
    202            xaxis_title='Spending in billions',
--> 203            yaxis_title='SPM poverty rate')

4 frames
/usr/local/lib/python3.6/dist-packages/plotly/basedatatypes.py in _raise_on_invalid_property_error(self, *args)
   3664                     full_obj_name=full_obj_name,
   3665                     invalid_str=invalid_str,
-> 3666                     prop_descriptions=self._prop_descriptions,
   3667                 )
   3668             )

ValueError: Invalid property specified for object of type plotly.graph_objs.Layout: 'legend_title_text'
@MaxGhenis
Copy link
Contributor Author

MaxGhenis commented Jul 16, 2020

Unfortunately it doesn't look like there's a way to update packages and have the notebook run smoothly from there, since the runtime needs to be restarted for the new package to be recognized. The closest possible is to have this code block at the beginning (fully hidden in jupyter-book) and then have users follow instructions in restarting after upgrading plotly:

import plotly
if plotly.__version__ < '4.8':
    !pip install --upgrade plotly
    print('Plotly upgraded! Now Runtime...Restart and run all.')
    import os
    os.kill(os.getpid(), 9)  # Kills Python to force a restart.

I confirmed that the blog post works fine after running this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant