Render nbgitpuller on voila

Hello Jupyter people.

I am trying to use nbgitpuller to render a Voilà notebook in a separate Jupyter environment while keeping the environment repository and content repository separate. However, when I click on the Binder link generated, I encounter a “404 : Not Found” error. The link doesn’t seem to work as expected.

Steps to Reproduce:

  1. Go to the following link:
    Binder

Expected Behavior:
The Binder environment should be created using the env_plotly_voila repository, and the specified notebook draft_plotting.ipynb from the main branch of the track_OD600 repository should be rendered using Voilà.

Actual Behavior:
Instead of rendering the notebook, a “404 : Not Found” error page is displayed, indicating that the requested page does not exist.

Additional Information:

It can be very tricky to draftt Voila launch URLs exactly correct. And also very tricky to draft nbgitpuller URLs exactly right. There are forms to help you with each. I’d imagine that combining these two may be your issue. I’d need to look more in depth at what you provide later. You saying, “when I click on the Binder link generated,” makes me wonder where you generated this? When I do it, I usually need hand editing to get either type to work and I imagine that need is compounded when trying to wedge both Voila and nbgitpuller calls in one URL.

1 Like

Result of closer inspection:

Try the following:

https://mybinder.org/v2/gh/ZarulHanifah/env_plotly_voila/main?urlpath=git-pull%3Frepo%3Dhttps%253A%252F%252Fgithub.com%252FZarulHanifah%252Ftrack_OD600%26urlpath%3Dvoila%252Frender%252Ftrack_OD600%252Fdraft_plotting.ipynb%26branch%3Dmain

That works for me.

You were close. You definitely picked up that you needed the equivalent of voila/render/, but you had a couple of specific things off in your syntax. I studied what the link generator made for opening the RetroLab application, particularly the end for guiding me. Compare what you had in your original post with what I provide:

  • You overlooked that your notebook is inside the directory track_OD600 that gets copied in by nbgitpuller. The way to trouble shoot that some so you can investigate yourself, is to open the default nbgitpuller link and then see what is there and how the URL changes if you open the correct notebook.
  • You had %2F near the end of the URL, when it should still be %252F, like earlier in the the URL you had & how the form provides for RetroLab, for fully escaping the / in the complex URL situation.
1 Like

Thank you so much @fomightez ! It works!

Oh man, I wasn’t familiar with url encodings, I had a look, and now I understand things a bit. Actually the link I generated was made by chatGPT, I was cheating a bit :stuck_out_tongue: .

I wrote something to put together the nbgitpuller and voila to write the correct url:

def create_voila_render_url(e_repo, c_repo, c_repo_path, branch = "main"):
    r = urllib.parse.quote_plus(c_repo)
    r = f"git-pull?repo={r}"
    
    u = urllib.parse.quote_plus(c_repo_path)
    u = f"urlpath={u}"
    
    b = f"branch={branch}"
    c_part = f"{r}&{u}&{b}"
    c_part = urllib.parse.quote_plus(c_part)
    c_part = f"?urlpath={c_part}"

    vlink = e_repo + c_part
    return vlink

e_repo = "https://mybinder.org/v2/gh/ZarulHanifah/env_plotly_voila/main"
c_repo = "https://github.com/ZarulHanifah/track_OD600"
c_repo_path = "voila/render/track_OD600/draft_plotting.ipynb"
branch = "main"

create_voila_render_url(e_repo, c_repo, c_repo_path, branch)
1 Like