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

Is it possible to make the notebooks executable? #55

Open
robertodr opened this issue Feb 2, 2021 · 13 comments
Open

Is it possible to make the notebooks executable? #55

robertodr opened this issue Feb 2, 2021 · 13 comments

Comments

@robertodr
Copy link
Contributor

I would like to be able to launch the notebooks on MyBinder from within the lesson à la Executable Book: https://jupyterbook.org/interactive/launchbuttons.html Is it possible? If not, could it be possible?

@rkdarst
Copy link
Member

rkdarst commented Feb 2, 2021 via email

@robertodr
Copy link
Contributor Author

Thanks! Yes, I'll try it out (later today) and report. I'll add documentation on how to do it.

@robertodr
Copy link
Contributor Author

Not much luck. https://github.com/ENCCS/veloxchem-workshop/blob/master/content/conf.py jupyter-book wants to read toc.yml and I'm not sure how to convince it not to do that :/

@rkdarst
Copy link
Member

rkdarst commented Feb 2, 2021 via email

@robertodr
Copy link
Contributor Author

sphinx-thebe would work, but I'd need to write the whole content in rst. I wanted to keep the ipynb files separate, such that they could be reused separately from the lesson. I need to dig a bit deeper.

@rkdarst
Copy link
Member

rkdarst commented Feb 3, 2021 via email

@robertodr
Copy link
Contributor Author

Here it is: https://github.com/ENCCS/veloxchem-workshop I've managed to add a cell on the main page and it works. But the notebook in the "First VeloxChem calculation" is static.

@rkdarst
Copy link
Member

rkdarst commented Feb 4, 2021 via email

@robertodr
Copy link
Contributor Author

Thanks for taking the time to look into this!

What I would like to achieve I would like to be able to use the Sphinx website as I would other lessons without interactive content, while being able to execute the cells without the need to share another browser tab. I feel this would be more engaging for the audience, since they can execute cells at the same time as I do and tinker around without losing (too much) focus on what I am sharing.

  1. Just using sphinx-thebe would be enough. But that requires that one works on the content of the executable cells separately and once that work is converged, copy-pastes them in markdown or restructuredtext.
  2. Adding the button "by hand" is no problem and, in fact, was the first thing I was going to do, before remembering about executable book. It would be great if the launch binder button could be added to sphinx-lesson through parameters in conf.py.
  3. Third option is useful to not duplicate effort between developing the notebook and developing the lesson.

For my use case, I think I need 2+3: execute cells within the lesson, but provide an "escape hatch" to the mybinder.org instance behind it.

@robertodr
Copy link
Contributor Author

And by the way, the course will take place in 3 months. I started setting it up early because there's a few moving parts I need to figure out (running quantum chemical calculations, visualizing molecules, and molecular orbitals)

@robertodr
Copy link
Contributor Author

OK, it seems using sphinx-book-theme does exactly what I want out of the box. I can write the content as notebooks and the theme will take care of rendering it and providing the launch buttons: https://enccs.github.io/veloxchem-workshop/ I've configured two buttons: to redirect to MyBinder or to start Thebe. What remains to be fixed is the styling of custom directives, which is somewhat related to #45.

@rkdarst
Copy link
Member

rkdarst commented Apr 7, 2021

I think that matched what I saw: somehow, the theme would label everything on the whole-page level. I think that someone clever enough with javascript could probably get the same effect, but I'm not sure when I would get to it. Is that theme compatible enough to recommend in general for this use case?

@rkdarst
Copy link
Member

rkdarst commented Jan 25, 2022

With sphinx_rtd_theme I was able to make a whole notebook executable:

  • start from a Jupyter notebook (thus it needs myst, not rst)

  • add config
    `extensions.append('sphinx_thebe')
    This config makes it detect output and link it properly, you could do other things depending on your interest:

     "selector": "div.cell",
     "selector_input": "div.cell_input",
     "selector_output": "div.cell_output",
     }
    
  • Add a launch button to a cell:

     ```{thebe-button}
     ```
    
  • Every cell in the notebook becomes executable

  • Other config likely needed, both in the page metadata and in the conf.py (setting kernels, repos to launch, etc): https://sphinx-thebe.readthedocs.io/en/latest/configure.html

... perhaps still need some debugging. (And in case of difficulties, I used the latest unreleased version of sphinx_thebe, but I think that shouldn't matter. However, somehow sphinx-autobuild didn't work with it, I didn't have time to figure out why...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants