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

Add notebook execution buttons to the sphinx gallery notebook pages #764

Open
romanlutz opened this issue May 2, 2021 · 17 comments · May be fixed by #870
Open

Add notebook execution buttons to the sphinx gallery notebook pages #764

romanlutz opened this issue May 2, 2021 · 17 comments · May be fixed by #870
Assignees
Labels
easy Relatively simple issues, harder than "good first issue" help wanted

Comments

@romanlutz
Copy link
Member

Our notebook pages on the website (such as this one) have download buttons, but we can't execute them directly on Binder, Azure Notebooks, Google Colab, etc.

Scikit-learn has a button for Binder (e.g., in this example) so this should be possible to add since we're using a similar set of sphinx extensions such as sphinx-gallery.

The way scikit-learn achieves this is by adding the following lines to the sphinx gallery configuration: https://github.com/scikit-learn/scikit-learn/blob/309f135c3284d7db6e23ca81a87948c7066a3949/doc/conf.py#L338
... and there's a dedicated requirements.txt file.

Other than adding that requirements file and the configuration for sphinx gallery, this would require building the website. Instructions are on this page, but I suggest going with the "simple" method rather than building the website for all versions. After all, we wouldn't expect the button to show up in past versions.

@romanlutz romanlutz added help wanted easy Relatively simple issues, harder than "good first issue" labels May 2, 2021
@kurianbenoy
Copy link
Contributor

Hi I would like to work on this issue.

@romanlutz
Copy link
Member Author

I expect the config values needed will be

'binder': {
        'org': 'fairlearn',
        'repo': 'fairlearn', 
        'binderhub_url': 'https://mybinder.org', 
        'branch': binder_branch, 
        'dependencies': './binder/requirements.txt', 
        'use_jupyter_lab': True    
    }

As you can tell the branch changes depending on the version since the documentation is built in multiple versions. I'm hoping the same version parsing will work for us (https://github.com/scikit-learn/scikit-learn/blob/309f135c3284d7db6e23ca81a87948c7066a3949/doc/conf.py#L282 and following), but it's not clear that it will. You may have to try it out. If that doesn't work, just use "main" as the branch. The dependencies file is a new file (which is mentioned in the issue description). I have no particular opinion on jupyter lab, but you can try it with False and True and see if it works.

@kurianbenoy
Copy link
Contributor

Thanks @romanlutz for your quick reply. Is the requirements.txt used in dependencies pointing to a folder binder/requirements.txt in our case?

If you look at scikit docs, the requirements.txt requirements.txt there is actually nothing. So what should be there in requirements.txt in our case?

Also it would be very helpful if you can point to some link which you used to setup sphinx_gallery configuration for our project, to get a better idea of the library used.

@romanlutz
Copy link
Member Author

romanlutz commented May 24, 2021

Seems like scikit-learn has a special setup with a separate repo for this. You can check their binder repo to see what's in the requirements file. Probably just the main dependencies we have in our requirements.txt plus the package itself. I'd just try it out by pointing at an empty file and if it fils try adding dependencies. Binder is free so there's no real cost associated with trying this.

You can check the Sphinx Gallery docs https://sphinx-gallery.github.io/stable/index.html
It's a very cool tool with lots of functionality that we're not even using right now.

@romanlutz
Copy link
Member Author

@kurianbenoy I just wanted to check in how it's going. There's no particular time pressure, but if you need help let us know. Also, if you're not planning to continue we can make this available to someone else. We're also starting to do pair programming sometimes, so if that's interesting to you please don't hesitate to ask.

@kurianbenoy
Copy link
Contributor

@romanlutz, was a bit busy the past few weeks. I couldn't work on it for a few weeks now, but I would definitely like to continue doing this if there is no time pressure.

@romanlutz
Copy link
Member Author

@kurianbenoy there is no pressure at all! Good to know, and let us know if there's any way we can help.

@kurianbenoy
Copy link
Contributor

kurianbenoy commented Jun 19, 2021

@romanlutz how can I bring the docs website up? Is it by the command: make doc?

Also another question, does the team prefer to use Jupyter labs or Jupyter notebooks?

@romanlutz
Copy link
Member Author

https://fairlearn.org/main/contributor_guide/contributing_documentation.html should help 🙂

I don't have a preference between lab and notebook. How does it affect the task?

@kurianbenoy
Copy link
Contributor

kurianbenoy commented Jun 19, 2021

Yeah it doesn't affect the task in hand. One issue, I am facing now is when passing dependencies in binder config, I am getting the below error

image

Any idea why, I am getting this error?

@kurianbenoy
Copy link
Contributor

Also another thing is I am able to get the run binder button:
image

Yet on selecting it, I am getting this error

image

I will be trying to debug these issue for a couple of hours more and see if I can get a solution. If any help is available it would be great as well :)

@kurianbenoy
Copy link
Contributor

kurianbenoy commented Jun 19, 2021

@romanlutz just noticed when checking our docs/conf.py that the copyright is hardcoded. Can we make it dynamic like the Scikit-learn docs configuration [1] ? Also should we give a start year like scikit docs?

Can I create a ticket for it?

[1] https://github.com/scikit-learn/scikit-learn/blob/309f135c3284d7db6e23ca81a87948c7066a3949/doc/conf.py#L88

@kurianbenoy kurianbenoy linked a pull request Jun 19, 2021 that will close this issue
@kurianbenoy
Copy link
Contributor

I am a bit confused on what should we give for the notebook_dir parameter in binder configuration. In case of scikit-learn and sphinx-gallery configuration, they don't have any folder named notebooks in their repo. But that is not the case of fairlearn which has a notebooks folder.

Reference link:
https://sphinx-gallery.github.io/stable/configuration.html#binder-links

@adrinjalali
Copy link
Member

maybe this would be of some help? https://github.com/scikit-learn/scikit-learn/tree/main/.binder

@kurianbenoy
Copy link
Contributor

I will check it out. Maybe the postbuild file maybe helpful to solve the issue.

@romanlutz
Copy link
Member Author

A few clarifications:

  • Ignore the notebooks directory. These are only notebooks that existed before we started using sphinx-gallery. Eventually they'll either be migrated to the gallery format (basically using .py files with the magic markers to separate cells) or deleted.
  • Examples/notebooks to render on the webpage are in the examples directory. So you can use whatever scikit-learn specifies for notebook directory (which may just be nothing in case they use a default). This should fix the path issue for plot_quickstart_selection_rate.py
  • Copyright: I don't particularly care to be honest, but if you like feel free to make the year dynamic. I guess the start year would be 2018.
  • In the issue description I referred to the requirements.txt file from scikit-learn. Did you add one for Fairlearn? That might explain the binder/requirements.txt issue.

@kurianbenoy
Copy link
Contributor

Ok, I am ignoring the notebooks section and using default value for notebooks. Also I have added requirements.txt in .binder folder.

@romanlutz romanlutz linked a pull request Jun 23, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy Relatively simple issues, harder than "good first issue" help wanted
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants