-
Notifications
You must be signed in to change notification settings - Fork 39
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
Widget screenshot in magicgui.md
error
#283
Comments
Could you put a link to webpage? Or it happens when build locally? |
It's here, in the dev docs: |
Interesting. Maybe it's a browser problem, I'll check with chromium |
Whoops mis read. It looks fine on CI for me too so hopefully fixed by commit |
I have merged new commit and problem still exists (image is regenerated). |
I think it would have to be merged to napari/docs/main? |
the dev docs are generated on every merge to main of napari/napari repository. |
Which screenshot? Just to clarify you see the same problem in dev? (dev vs stable) Do we generate stable/dev differently? Maybe a different magicgui version (is causing the problem)? |
We have not regenerated stable since the 0.4.18 release. |
The napari generated screenshot just below the wierd one. |
I know right?! I was very confused by this 😂
The example does not use napari at all. Just |
Line 51 in de3c3e0
It is here in code. Some bug in during code review happens. |
Oh yeah I knew it was in the code. I did not know the intention but yes probably missed in code review. |
I have found that we have two workflows for build docs: https://github.com/napari/docs/blob/main/.github/workflows/deploy_docs.yml The deploy one do not use constraints in I think that we should use a single workflow with conditional deeploy steep. |
Does the code used: from magicgui import magicgui
import datetime
import pathlib
@magicgui(
call_button="Calculate",
slider_float={"widget_type": "FloatSlider", 'max': 10},
dropdown={"choices": ['first', 'second', 'third']},
)
def widget_demo(
maybe: bool,
some_int: int,
spin_float=3.14159,
slider_float=4.5,
string="Text goes here",
dropdown='first',
date=datetime.datetime.now(),
filename=pathlib.Path('/some/path.ext')
):
...
widget_demo.show() work for others? It generates an empty widget for me (but I am likely to be running it wrong). |
You need to launch event loop to have visible widget: from qtpy.QtWidgets import QApplication
from magicgui import magicgui
import datetime
import pathlib
app = QApplication([])
@magicgui(
call_button="Calculate",
slider_float={"widget_type": "FloatSlider", 'max': 10},
dropdown={"choices": ['first', 'second', 'third']},
)
def widget_demo(
maybe: bool,
some_int: int,
spin_float=3.14159,
slider_float=4.5,
string="Text goes here",
dropdown='first',
date=datetime.datetime.now(),
filename=pathlib.Path('/some/path.ext')
):
...
widget_demo.show()
app.exec() |
Ahhhh okay, I see we have: Line 219 in de3c3e0
which does the app stuff. |
But this iterates over napari main windowses. How should it discover the magicgui widget? |
I see we have: docs/.github/workflows/build_docs.yml Lines 1 to 2 in de3c3e0
so there may be a reason we didn't/couldn't use the same workflow, @melissawm ? Deploy uses constraints: docs/.github/workflows/deploy_docs.yml Lines 49 to 50 in de3c3e0
Build (used in PRs), just uses the docs/.github/workflows/build_docs.yml Line 46 in de3c3e0
|
I am not good with Qt stuff but maybe this will answer your question: https://sphinx-gallery.github.io/stable/advanced.html#write-a-custom-image-scraper tl;dr for each 'code' block/section in the docs, images are scraped using |
I'm author of this note. It is because when I was fixing build_docs workflows I miss deploy docs one. Build also uses constraints but pass them using enviornment variable: docs/.github/workflows/build_docs.yml Lines 46 to 48 in de3c3e0
Also make uses constraints docs/.github/workflows/build_docs.yml Lines 57 to 63 in de3c3e0
When deploy do not use this: docs/.github/workflows/deploy_docs.yml Lines 59 to 66 in de3c3e0
|
Thanks but I do not follow what docs/.github/workflows/build_docs.yml Lines 57 to 60 in de3c3e0
since in "Install Dependencies" step above we used the constraints?
I'll make another issue to see if we can use the same workflow for both. |
Ahhh i see we changed the way we scraped images right after 0.4.18 release: #207 @aganders3 could this be why the |
Eek I'm just catching up on this but yes, it's a possibility. I can take a look at this tomorrow. |
We use that scraper in the CircleCI docs which look fine so I dont think that's it. Note they use the update workflow like build_docs. |
What is the update workflow? What is the difference in the environment between the "build docs" and "build and deploy"? So I can try to replicate locally. To me they both seem to use the same constraints..? |
Sorry I wasn't clear, this PR updated the build_docs and the circle ci workflows, but not the deploy one: Line 24 in de3c3e0
So without the env variable, that can install different versions of stuff than the previous steps with constraints, which is what Grzegorz was pointing out. |
Ahhh I did not think the Makefile would have an install step! This setup seems odd? Why do we need the "Install Dependencies" step in |
I'm just poking around this morning. Docs look okay for me when built locally, but I will say I am a little confused still how that first magicgui (non-napari) image works at all.
This might be a red herring as it's actually just...in the doc? Line 51 in de3c3e0
|
Okay now I am understanding more. This has nothing to do with the scraper because that is for the gallery only. These screenshots come from myst-nb, which renders the output of the cells in that file because they use the The first widget shows in the notebook because it provides The rest of the widgets are rendered more manually by combining two code blocks: one with Lines 110 to 131 in de3c3e0
It looks like maybe Qt was in some weird state here. Each screenshot sets its own size but in the output they successively shrink for some reason. edit: maybe adding some |
We had a sprint for alt-text once and marked this for someone to write something since IIRC the screenshot for magicgui does not support alt-text out of the box. If someone can add a description that would be great 😄 |
To be honest, ideally I would love for the dependency install to be de-coupled from the docs build command. I understand the convenience but I feel like it's confusing to have them together. But that's a discussion for another time 😅 |
The reason is that those two workflows were similar but one was updated and the other wasn't. So +1 to getting deploy_docs to be the same as build_docs! |
+1 here. I think it would be great if using (I'll start an issue anyway so we can have a discussion) |
Yes it is probably safer to do something like this. The annoying part though is that we haven't been able to replicate this problem locally. I guess we will need to try installing from requirements as is/was in Edit: of note, the docs look fine in CI, so it's not a change in napari that has cause this. |
@melissawm do you know if there is a reason we use sphinx-gallery for code outputs in the gallery but myst-nb elsewhere in the doc? It would be nice to consistently use one tool? Edit: I guess it would involve a lot of re-arranging to use sphinx gallery for non-gallery docs, especially as they use RST. Is myst-nb an option for gallery docs? |
So I'm pretty sure that the deploy workflow worked properly now that #290 was merged. |
I spot two differences between GH and CircleCI (and my local build): we use Talleys QT action: docs/.github/workflows/build_docs.yml Line 40 in 0c7029e
This action seems to run: https://github.com/tlambert03/setup-qt-libs/blob/b66de97cf84c0684fa084b8487cfd4ae2c622f40/dist/index.js#L2982 While in CircleCI we install manually: Lines 22 to 23 in 0c7029e
The difference appears that the Talley action also has libxcb-cursor0 libopengl0 libegl1-mesa while circleci has xvfb .But looking at the log it looks like xvfb does pull libegl-mesa0 (note the 0, not sure it's important) but not the others :https://app.circleci.com/pipelines/github/napari/docs/413/workflows/b7d5ed05-1315-4de4-8689-9ed1ee574100/jobs/403?invite=true#step-103-3065_45 (And locally obviously I have macOS stuff) Then in GH workflow we use the @aganders3 headless run: docs/.github/workflows/build_docs.yml Line 56 in 0c7029e
while CircleCI uses xvfb: Line 43 in 0c7029e
and locally I get the windows dancing. |
I thought I was off the hook when we determined it wasn't the scraper 😆. Buuuut - this action runs a tiling window manager by default, so maybe this could cause the shrinking screenshots. I don't really know how it would mess up that initial screenshot but who knows. So my previous suggestion of using - name: Build Docs
uses: aganders3/headless-gui@v1
env:
GOOGLE_CALENDAR_ID: ${{ secrets.GOOGLE_CALENDAR_ID }}
GOOGLE_CALENDAR_API_KEY: ${{ secrets.GOOGLE_CALENDAR_API_KEY }}
PIP_CONSTRAINT: ${{ github.workspace }}/napari/resources/constraints/constraints_py3.10_docs.txt
with:
run: make -C docs docs
+ linux-pkgs: ""
+ linux-setup: "" |
See napari#283 (comment) for more details.
I may be reading it wrong but it also looks like the CircleCI build is using PySide and the GH-Actions build is using PyQt5 (from |
Good catch. I'm using pyqt6 locally, which is also fine, so a glitch in pyqt5 specifically is also possible? |
Could still be specific to headless too. Also I can see there's a different code path for this rendering code in magicgui depending on PySide/PyQt. I'm otherwise running low on ideas 😬. |
I tried PySide in my PR and get no image now but an exception instead (in the docs output):
Here's the run: https://github.com/napari/docs/actions/runs/7108661085 |
Okay I have another theory now that this is related to the bit-depth of the xvfb (virtual) screen. In my In CircleCI it just uses I will see if I can figure out a reasonable way to test this theory tomorrow 😓. |
Ooo! Bit depth difference could maybe explain the funky colors? |
# References and relevant issues ~~Hopefully f i x e s~~ Pretty sure now this fixes both #283 and #285 # Description This configures the [headless-gui](https://github.com/aganders3/headless-gui) action to not run the tiling window manager it uses by default. My thinking is the tiling behavior in the window manager is causing issues with certain screenshots. See #283 (comment) for more details. This also updates the action to a new version with a more common default screen size. This change in bit-depth fixes the messed up magicgui screenshot. Edit: I'm still not _totally_ clear why the stable docs would look okay but I think this is worth trying. --------- Co-authored-by: Peter Sobolewski <[email protected]>
Fixed by #294 |
🐛 Bug
Widget screenshot in
magicgui.md
(in dev docs: https://napari.org/dev/guides/magicgui.html) looks wrong:Not familiar with
magicgui
so not sure if this is due to our example or the screenshot tool?The text was updated successfully, but these errors were encountered: