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

Attempt to load try_examples configuration file only once per page #240

Open
agriyakhetarpal opened this issue Dec 23, 2024 · 2 comments · May be fixed by #249
Open

Attempt to load try_examples configuration file only once per page #240

agriyakhetarpal opened this issue Dec 23, 2024 · 2 comments · May be fixed by #249
Assignees
Labels
bug Something isn't working

Comments

@agriyakhetarpal
Copy link
Member

Description

On pages where API reference examples to be made interactive are widespread and multiple ones exist, there are a lot of redundant error messages in the console (as noted below).

I'm testing this with scikit-image/scikit-image#7644, and here is an example of a sample page from the preview artifacts: https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/api/skimage.measure.html

I assume this happens because we run the JavaScript file per iframe, but it would be nice to catch the error on the first iframe and cache it if it's being reported more than once, and check it exists in the console already.

Reproduce

Open the developer console when on the aforementioned link

Expected behavior

That we load and generate an error based on the missing config file just once

Context

  • JupyterLite version: 0.17.1 (latest stable release)
  • Operating System and version: macOS Sonoma 14.6.1
  • Browser and version: Arc Version 1.74.0 (57065), running Chromium Engine Version 131.0.6778.205
Browser Output
[PST]: Changed to dark mode using the dark theme.
pydata-sphinx-theme.js:151 [PST]: Scrolled sidebar using stored browser position...
jupyterlite_sphinx.js?v=d6bdf5f8:163 
   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953568 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:3068
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953568 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:3162
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953566 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:718
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:807
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953568 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:3279
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:903
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953568 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:3402
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:1027
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:1299
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:1723
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:1794
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:1849
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:1929
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:1995
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:2063
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:2203
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:2271
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:2400
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:2579
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:2863
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.
jupyterlite_sphinx.js?v=d6bdf5f8:163

   GET https://output.circle-artifacts.com/output/job/048f37f1-2a97-4826-b310-3c66a77deb9c/artifacts/0/doc/build/html/try_examples.json?cb=1734970953567 404 (Not Found)

window.loadTryExamplesConfig @ jupyterlite_sphinx.js?v=d6bdf5f8:163
(anonymous) @ skimage.measure.html:3007
jupyterlite_sphinx.js?v=d6bdf5f8:167 Optional try_examples config file not found.

@agriyakhetarpal agriyakhetarpal added the bug Something isn't working label Dec 23, 2024
@Carreau
Copy link
Collaborator

Carreau commented Jan 6, 2025

That would be there:

jupyterlite_sphinx/jupyterlite_sphinx.js
152:window.loadTryExamplesConfig = async (configFilePath) => {

As far as I can tell we are explicitly retrying on fail:

window.loadTryExamplesConfig = async (configFilePath) => {
  if (tryExamplesConfigLoaded) {
    return;
  }
  try {
    // Add a timestamp as query parameter to ensure a cached version of the
    // file is not used.

But we can likely add a throttled / batched version, or if 404, mark as loaded = true,
note that regardless we may want to batched, as it is likely we trigger concurent requests as this is an async function.

@agriyakhetarpal agriyakhetarpal self-assigned this Jan 10, 2025
@agriyakhetarpal
Copy link
Member Author

Thanks for the suggestion – I've assigned myself to the issue as I have a throttled version ready which seems to do the job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants