jupyter-book / thebe

Turn static HTML pages into live documents with Jupyter kernels.
https://thebe.readthedocs.io
BSD 3-Clause "New" or "Revised" License
395 stars 68 forks source link

mybinder + thebe + gitlab pages #628

Open jeremyneveu opened 1 year ago

jeremyneveu commented 1 year ago

Describe the bug

context I want to make gitlab pages with jupyter-book, with thebe to have interactivity through mybinder, the start of the kernel fails. The binder is working well (repo here on my university gitlab https://gitlab.dsi.universite-paris-saclay.fr/MethNum/ComputerLab)

expectation I expected some interactivity in my website, and being able to click on the binder button to open a mybinder tab, for instance on this web page https://methnum.gitlab.dsi.universite-paris-saclay.fr/L2/release/Seance2/SEANCE_2.html

bug But when clicking on Live Code, the widget "Lauching from mybinder.org" ends in "failed". Another symptom is that, when clicking on the binder button, I get correctly redirected to mybinder.org page but the build fails with this error message, which looks like a bad url format:

Error resolving ref for git:https%3A//gitlab.dsi.universite-paris-saclay.fr/MethNum/ComputerLab/master: Unable to run git ls-remote to get the `resolved_ref`: ssh: Could not resolve hostname https: Temporary failure in name resolution
fatal: Could not read from remote repository.

which is a different log from what I get when clicking on the "launch binder" button of my ComputerLab repo.

problem It's a problem for people relying on a institional gitlab to share their projects as gitlab pages.

Reproduce the bug

To see the bug, you can go to any page on this website : https://methnum.gitlab.dsi.universite-paris-saclay.fr/L2/

List your environment

My base environment is described here https://gitlab.dsi.universite-paris-saclay.fr/MethNum/scripts/-/blob/master/environment.yml and used to make the ComputerLab binder. Then in the gitlab CI process to build the website, I add jupyter-book with pip and get : Successfully installed accessible-pygments-0.0.4 alabaster-0.7.13 docutils-0.18.1 imagesize-1.4.1 jupyter-book-0.15.1 jupyter-cache-0.6.1 latexcodec-2.0.1 linkify-it-py-2.0.2 myst-nb-0.17.2 myst-parser-0.18.1 pybtex-0.24.0 pybtex-docutils-1.0.2 pydata-sphinx-theme-0.13.3 snowballstemmer-2.2.0 sphinx-5.0.2 sphinx-book-theme-1.0.1 sphinx-comments-0.0.3 sphinx-copybutton-0.5.2 sphinx-design-0.3.0 sphinx-external-toc-0.3.1 sphinx-jupyterbook-latex-0.5.2 sphinx-multitoc-numbering-0.1.3 sphinx-thebe-0.2.1 sphinx_togglebutton-0.3.2 sphinxcontrib-applehelp-1.0.4 sphinxcontrib-bibtex-2.5.0 sphinxcontrib-devhelp-1.0.2 sphinxcontrib-htmlhelp-2.0.1 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.3 sphinxcontrib-serializinghtml-1.1.5 tabulate-0.9.0 uc-micro-py-1.0.2

welcome[bot] commented 1 year ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

stevejpurves commented 1 year ago

Thanks for reporting this @jeremyneveu

It's worth noting that the binder option is configured via jupyterbook and not thebe, and that is also malformed -- so I'd like to see the jupyterbook configuration where you are supplying yout gitlab repository information. I could not see that in the repo you linked to, also how are you building your jbook? i could not see it in CI.

jeremyneveu commented 1 year ago

The jupyterbook is not compiled in the ComputerLab repo, but in another repo which is private. The ComputerLab repo is only there to provide a working environment for students with mybinder. The jupyterbook is build with CI with the file .gitlab-ci.yml :

  stage: pages
  script:
    - conda install -y -c conda-forge nbconvert jupyter jupyter_client pandoc # jupyter-book
    - pip install jupyter-book
    - jupyter kernelspec list
    - jupyter-book build . -v
    - mv _build/html/ public/
  artifacts:
    paths:
      - public
  only:
    - master

and the _config.yml file is:

title                       : Méthodes Numériques   L2  # The title of the book. Will be placed in the left navbar.
author                      : Jérémy Neveu, et al.  # The author of the book
copyright                   : "2021 Licence libre Creative Commons CC-BY-SA"  # Copyright year to be placed in the footer
logo                        : scripts/figures/methnum_logo.png  # A path to the book logo

repository:
  url                       : https://gitlab.dsi.universite-paris-saclay.fr/MethNum/ComputerLab  # The URL to your book's repository
  path_to_book              : ""  # A path to your book's folder, relative to the repository root.
  branch                    : master  # Which branch of the repository should be used when creating links

only_build_toc_files: true

exclude_patterns:
  - _build
  - __pycache__
  - .pytest_cache
  - "**.ipynb_checkpoints"
  - .pytest_cache
  - "L2-**"
  - "CR-**"
  - scripts
  - binder
  - Examen
  - "source**"
  - "submitted**"
  - "autograded**"
  - "feedback**"
  - "**.sty"
  - gradebook.db
  - "**.xlsx"
  - CONDUCT.md
  - CONTRIBUTING.md

parse:
  myst_enable_extensions:  # default extensions to enable in the myst parser. See https://myst-parser.readthedocs.io/en/latest/using/syntax-optional.html
    - html_image
    - amsmath
    - colon_fence
    # - deflist
    - dollarmath
    - html_admonition
    - linkify
    # - replacements
    # - smartquotes
    - substitution

execute:
  execute_notebooks: auto
  allow_errors: true

launch_buttons:
  notebook_interface        : classic  # The interface interactive links will activate ["classic", "jupyterlab"]
  binderhub_url             : "https://mybinder.org" # https://mybinder.org  # The URL of the BinderHub (e.g., https://mybinder.org)
  jupyterhub_url            : "https://jupyterhub.ijclab.in2p3.fr/"  # The URL of the JupyterHub (e.g., https://datahub.berkeley.edu)
  thebe                     : true  # Add a thebe button to pages (requires the repository to run on Binder)
  colab_url                 : "" # The URL of Google Colab (https://colab.research.google.com)

html:
  use_edit_page_button      : false  # Whether to add an "edit this page" button to pages. If `true`, repository information in repository: must be filled in
  use_repository_button     : true  # Whether to add a link to your repository button
  use_issues_button         : false
stevejpurves commented 1 year ago

ok if i correctly plug the following options into thebe (using 0.9.0-rc.x), then we get a well formed url of: https://mybinder.org/build/git/https%3A%2F%2Fgitlab.dsi.universite-paris-saclay.fr%2FMethNum%2FComputerLab/HEAD

the thebe options are:

{
        useBinder: true,
        binderOptions: {
          repo: 'https://gitlab.dsi.universite-paris-saclay.fr/MethNum/ComputerLab',
          ref: 'HEAD',
          binderUrl: 'https://mybinder.org',
          repoProvider: 'git',
        }
}

So I think that this bug originates in sphinx-thebe, and will need a fix there -- this also agrees with the fact that the Binder launch button is also broken, as that's happening over in the jbook build and is independent of thebe afaik.

Probably that fix will also work with thebe@0.8.2

stevejpurves commented 1 year ago

The binder issue originates here: https://github.com/executablebooks/sphinx-book-theme/blob/master/src/sphinx_book_theme/header_buttons/launch.py where I think there is also the issue of gitlab on other domains not being supported yet

jeremyneveu commented 1 year ago

Thank you @stevejpurves for investigating this ! What kind of action should we take to solve this issue then ?

stevejpurves commented 1 year ago

I think sphinx-thebe needs to be extended in order to let you set some additional options. Until that's done, there is not much you can do... i'll open an issue there and tag you.