mitiq icon indicating copy to clipboard operation
mitiq copied to clipboard

Reconsider adding Google Colab links for interactive notebooks

Open nathanshammah opened this issue 2 years ago • 5 comments

Issue Description

This is an improvement proposal, following an AI Summer school I attended where everyone seemed to use Google Colab for sharing notebooks. I propose to investigate how we could support Colab, which, by the way, I believe added some features in the past years, integrating with Github.

We currently only support My Binder which has the following pros:

  • one can specify environment in a requirement file, so that once the notebook renders it already has Mitiq installed
  • hence can support .myst files
  • does not require a google account

My binder cons:

  • installation can take quite some time and generally prompts one to a "wait page"
  • probably by now less popular than colab

Colab pros:

  • You can easily copy the notebook in your account – hence it may be more probable one gets back to that
  • changes (especially relevant for personal copies) are persistent
  • Favors tinkering and collaboration

Colab cons:

  • Does not support pre-installed packages, so one would need to include some "pip install mitiq" commented lines in notebooks
  • Does not support myst-nb which we use for the documentation as it's much cleaner to review .md files.
  • Requires a google account.

All above statements may be incorrect/not updated, so we'd better investigate if this is the case

Proposed Solution

Add google colab support/links (without dropping My Binder). Exact implementation to be found. Not clear at this time how to integrate this with Mitiq's docs.

Additional References

This readme could contain useful links to copy a basic Colab implementation. Pinging @nickdgardner and @Misty-W who also participated to the discussion in the Mitiq community call.

nathanshammah avatar Sep 28 '22 13:09 nathanshammah

Just brainstorming some potentially useful models for how to support Colab (if we decide to):

•Peter Norvig's pytudes (markdown on github, very nice interface allowing you to run the notebook on Colab, DeepNote MyBinder, SageMaker Studio Lab; and to view the notebook on NBViewer): https://github.com/norvig/pytudes#index-of-jupyter-ipython-notebooks

•The notebooks for this online intro data science textbook (made in Jupyter Book): https://allendowney.github.io/ElementsOfDataScience/README.html#the-notebooks

nickdgardner avatar Oct 05 '22 22:10 nickdgardner

Thanks @nickdgardner!

nathanshammah avatar Oct 06 '22 15:10 nathanshammah

Another possible reference: • Notebooks accompanying Kevin Murphy's "Probabilistic Machine Learning" books (with a helpful intro to colab): https://github.com/probml/pyprobml

nickdgardner avatar Oct 12 '22 18:10 nickdgardner

@nathanshammah can you comment on where you'd like to see google colab used? We don't have any binder links on the examples pages, which is what I originally thought you were referring to when reading this issue.

natestemen avatar Oct 13 '22 03:10 natestemen

@nathanshammah @Misty-W @natestemen @andreamari Here's my attempt at making a colab version of the example I have been working on (qiskit adaptation of this) https://colab.research.google.com/drive/1BQRT_TxbZ7HiYt_fF0HFJ8yz5U2c6JBL?usp=sharing

I think this should work for anyone with a google account. The only difference between the colab version of the notebook compared to the myst version is that I added the code below for installing the necessary libraries that don't already come with the default colab environment (in this case, mitiq and qiskit).

try:
  import mitiq
except ImportError:
  !pip install mitiq

try:
  import qiskit
except ImportError:
  !pip install qiskit

nickdgardner avatar Oct 14 '22 03:10 nickdgardner

Follow up in #1820.

Misty-W avatar Aug 18 '23 16:08 Misty-W