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

disable calls to plotly.io.show when running on Azure #5446

Merged
merged 9 commits into from
Jul 12, 2021

Conversation

grlee77
Copy link
Contributor

@grlee77 grlee77 commented Jun 26, 2021

Description

It has been a common occurance lately for the CI job on Azure that involves gallery testing to timeout.

I have a suspicion that this is somehow related to Plotly, but haven't confirmed that for sure yet.

In this PR, I try defining environment variable: SKIMAGE_DISABLE_PLOTLY_SHOW to disable it

This environment variable is only exported during Gallery testing on Azure, so users should still get the plots popping up in their browser if running the scripts from the command line.

Checklist

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.

…ts on Azure

define environment variable: SKIMAGE_DISABLE_PLOTLY_SHOW to enable this
@grlee77 grlee77 added the 🤖 type: Infrastructure CI, packaging, tools and automation label Jun 26, 2021
@grlee77 grlee77 changed the title WIP: disable calls to plotly.io.show when running on Azure disable calls to plotly.io.show when running on Azure Jun 27, 2021
@grlee77
Copy link
Contributor Author

grlee77 commented Jun 27, 2021

This seems to have worked. I manually started the Azure job a second time here to check that we didn't just get lucky.

@mkcor, the timeouts that have been common on Azure in recent weeks seem to have been related to the plotly.io.show calls I had asked you to add to the examples. This PR bypasses those when running the Azure gallery testing job. I tried this with a gallery example, but let me know if you are aware of anything else in Plotly itself.

@grlee77
Copy link
Contributor Author

grlee77 commented Jun 27, 2021

A second option would be replacing calls to show() with fig.write_html("<filename>"), but this would leave a files on disk that the user would have to manually go and open with a browser if they wanted to see it, so I am not a big fan of that.

@grlee77 grlee77 mentioned this pull request Jul 5, 2021
@jni
Copy link
Member

jni commented Jul 6, 2021

@grlee77 The problem I have with this is that it makes the gallery examples uglier, for something that is a mild problem from the developer side. I'm not sure on balance it is a good change. I think I would prefer writing a tool in our /tools folder that would crawl all our examples and comment-out lines with plotly.io.show. What do you think? (And maybe it doesn't need a dedicated script, just a grep/find/sed one-liner, but my shell-fu is not good enough for that!)

revert introduction of SKIMAGE_DISABLE_PLOTLY_SHOW env var
@grlee77
Copy link
Contributor Author

grlee77 commented Jul 6, 2021

I agree that it makes those examples more ugly. I reverted the environment variable and instead use a one line sed-based solution in 0e2dc2a.

@grlee77
Copy link
Contributor Author

grlee77 commented Jul 6, 2021

CI is green for the sed-based version as well.

The only change to an example script now is adding the show commands to doc/examples/applications/plot_3d_structure_tensor.py where they were missing.

@grlee77
Copy link
Contributor Author

grlee77 commented Jul 7, 2021

ping @jni

# Comment out any plotly.io.show() calls before running the example.
# Plotly opens a web browser, which often seemed to cause the CI to
# hang and timeout.
sed -i 's/plotly.io.show/# plotly.io.show/g' ${f}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this non-invasive workaround 🙂

azure-pipelines.yml Show resolved Hide resolved
doc/examples/applications/plot_3d_structure_tensor.py Outdated Show resolved Hide resolved
doc/examples/applications/plot_3d_structure_tensor.py Outdated Show resolved Hide resolved
@mkcor
Copy link
Member

mkcor commented Jul 12, 2021

@mkcor, the timeouts that have been common on Azure in recent weeks seem to have been related to the plotly.io.show calls I had asked you to add to the examples.

I think these timeouts would happen (sometimes) even without the plotly.io.show calls: Plotly figures by themselves can make the generated HTML files pretty heavy. When building the example gallery locally, I've noticed the slowdown caused by Plotly figures, regardless of the renderer.

This PR bypasses those when running the Azure gallery testing job.

Okay.

I tried this with a gallery example, but let me know if you are aware of anything else in Plotly itself.

Not really; I haven't followed closely beyond plotly/plotly.py#1577 by @emmanuelle. I didn't know of plotly.io.to_html and plotly.io.write_html before you pointed out the second option (shame on me).

I know that, here,

pio.renderers.default = 'sphinx_gallery_png'

we want 'sphinx_gallery_png' rather than 'sphinx_gallery' so that gallery thumbnails display well. The other renderer candidates don't seem fitting.

@grlee77
Copy link
Contributor Author

grlee77 commented Jul 12, 2021

@mkcor: I have addressed the comments. CI is still running, but the relevant Azure jobs have already passed.

@mkcor
Copy link
Member

mkcor commented Jul 12, 2021

@mkcor: I have addressed the comments. CI is still running, but the relevant Azure jobs have already passed.

Yay! Thanks. Since this is a CI+docs PR, can I go ahead and merge?

@grlee77
Copy link
Contributor Author

grlee77 commented Jul 12, 2021

We addressed Juan's original objection to the environment variable, so I say go for it!

@mkcor mkcor merged commit c480ca4 into scikit-image:main Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 type: Infrastructure CI, packaging, tools and automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants