Skip to content

uploading a second unnamed figure using chart-studio 1.0.0a2 causes error #1622

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

Closed
michaelbabyn opened this issue Jun 17, 2019 · 11 comments
Closed
Labels
bug something broken

Comments

@michaelbabyn
Copy link
Contributor

michaelbabyn commented Jun 17, 2019

For context, I was curious to see how the new chart_studio package would handle the switch to using the v2 rest API so I did a little QA and ran into the below issue.

I get PlotlyRequestError: Sorry, a file named 'plot from API' already exists after trying to upload a second unnamed plot to plot.ly using chart-studio 1.0.0a2.

Steps to reproduce:

import plotly.graph_objs as go
import chart_studio.plotly as py

f = go.Figure()
f.add_scatter(y=[3,4,3,5])
py.plot(f)

f.add_bar(y=[3,4,3,5])

py.plot(f)
@jonmmease
Copy link
Contributor

Thanks for giving it a try @michaelbabyn,

I'm not able to reproduce your exact error, but I am seeing something weird on repeated calls to plot. I think part of the problem is that it looks like the update endpoint (https://api.plot.ly/v2/files#update) only updates the metadata of a file, not the content. So we may need to delete existing files first and the use create to upload.

Do you get the error if you wait a couple of seconds in between calls to plot? I'm wondering if there may also be a race condition there.

@jonmmease jonmmease added the bug something broken label Jun 17, 2019
@michaelbabyn
Copy link
Contributor Author

I don't think there's a race condition, I get the issue even after waiting a few seconds between the calls. I think there might be a couple of bugs here. What I was expecting was that a new plot and grid would be created on Chart Studio but plotly.py is trying to overwrite an existing plot named "plot from API".

The other bug is that plotly.py cannot update "plot from API".

@michaelbabyn
Copy link
Contributor Author

michaelbabyn commented Jun 17, 2019

Also, I only see that error if I change the number of traces in the grid. For example the code below works (although the data in the grid is unchanged).

import plotly.graph_objs as go
import chart_studio.plotly as py

f = go.Figure()
f.add_scatter(y=[3,4,3,5])
py.plot(f)

f = go.Figure()
f.add_bar(y=[9,9,9,9])

py.plot(f)

So it looks like the plot gets updated properly but the grid doesn't.

@jonmmease
Copy link
Contributor

jonmmease commented Jun 18, 2019

Please try out chart_studio==1.0.0a3 chart_studio==1.0.0a4 when you have a chance and let me know how it goes. Thanks!

@michaelbabyn
Copy link
Contributor Author

michaelbabyn commented Jun 26, 2019

@jonmmease , Sorry I didn't see this until now but I've been going through the chart studio docs using 1.0.0a4 and I'm now able to update the data for the grid of an existing plot but if I want to create a new plot without passing a filename argument, it will write over whatever plot has the name "plot from API".

I think we need to get rid of the default plot name now that fileopt is gone.

@jonmmease
Copy link
Contributor

Ahh, yeah, a grid shouldn't overwrite a plot. But what do you expect to happen when a grid is uploaded without a name? Should it be called "grid from API" or something?

@michaelbabyn
Copy link
Contributor Author

@jonmmease I edited my comment above to make it more clear that my issue is the default filename. Calling iplot without a specific filename (e.g chart_studio.plotly.iplot(fig)) always gives a default filename of "plot from API". In version 3, plotly.py would create a new file named "plot from API (1)" if "plot from API" already existed but now it overwrites it.

I find this behaviour a little weird since I'm used to not having to name every plot I want to send to the cloud.

@nicolaskruchten
Copy link
Contributor

What happens if we just provide no name at all? I thought Chart Studio handled adding the "(1)" or otherwise deduping names, no?

@jonmmease
Copy link
Contributor

Hmm, the file name "plot from API" was passed along before through the clientresp I believe. If we don't specify the name at all, we get names like Grid 122 and Plot 123, without overwriting.

That works for me, I'll do this in the next alpha. but let me know what you think

@jonmmease
Copy link
Contributor

jonmmease commented Jul 1, 2019

@michaelbabyn ok, please try out 1.0.0a5 when you have a chance 🙂

@michaelbabyn
Copy link
Contributor Author

@jonmmease , chart_studio version 1.0.0a5 works as I expect it to. I'll go ahead and close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

3 participants