On Tue, Feb 2, 2021 at 3:54 PM Whipp, David M <david.wh...@helsinki.fi> wrote:
> Hi Wes, > > I’ll respond where I can add something useful (hopefully). > Hey thanks! > > > #### Questions for comprehension: > > > > ##### When is it better to write code as a module and/or a Jupyter > notebook? > > > > (Note that e.g. the fastai/nbdev template repo makes it easy to mark > .ipynb notebook input cells as for export to a .py python module) > > I suppose this varies from user to user and application to application. > Personally, I like notebooks when doing data-oriented work, typically > involving reading data files, cleaning them, processing the data in some > way, and producing plots or writing files as outputs. I like being able to > describe the steps of the analysis, as well as assumptions I’m making, and > having the option to give links to relevant sources online (journal > articles, websites, or whatever). > For when the output should be a document composed of source code, Markdown, static and interactive data visualizations with HTML/JS > > I also do write scripts as well. Typically, these are things where I am > computation oriented, such as solving equations numerically, or small tools > I want to be able to use from a command line interface on a computer > cluster, for example. Notebooks could also be used for this kind of task, > but I (personally) don’t see the benefit. > With IPython: %logstart? %logstart without.output.py %logstart -o with.output.py %run -i with.output.py > > > ##### How do I test a notebook and a module? > > - module: pytest > > - notebook: > > - nbdev > > - Pytest + Jupyter-specific plugin > > - `assert` statements to verify assumptions > > This is indeed a good question. For our course we use a combination of > nbgrader (which is designed for automating grading of notebook assignments) > and tests the students can see in individual code cells (using nose, for > example). We introduce assertions as well, but we don’t have the students > do much with them in our introductory course (it only runs for 7 weeks). > > Somehow, I feel like I’ve not come across nbdev before… That looks like it > indeed could be a useful thing for us to consider. > - https://github.com/fastai/nbdev_template - https://github.com/topics/cookiecutter - cookiecutter-pylibrary - https://github.com/drivendata/cookiecutter-data-science - https://github.com/mkrapp/cookiecutter-reproducible-science - getting these paths correct so that notebooks can import in-development code is difficult without just using `pip install -e .` to add the symlink to site-packages/ > > > ##### When I share my repo, will people be able to run the code? > > > > If your dependencies are specified in REES-compatible way > (/requirements.txt, /environment.yml), users and BinderHub can use > repo2docker to generate a container with a current - and thus > security-updated - version of JupyterLab and also the [exact versions of] > the software dependencies you've specified. > > I think some of my colleagues have used repo2docker previously, but that > should be possible as well for our course materials (we provide Binder > links and use the requirements.txt file for the Binder instances). > https://github.com/jupyterhub/repo2docker : pip install jupyter-repo2docker jupyter-repo2docker https://github.com/norvig/pytudes REES config files: https://repo2docker.readthedocs.io/en/latest/config_files.html > > On the course website we’re using two options as quick ways to make the > lessons interactive: Binder and Thebelab. At the top of the page there is a > rocket ship icon, and you can use it to open the lesson you’re viewing on > Binder, or use the “Live code” option to start a Python kernel using > Thebelab. This allows the code cells on the course page itself to be > interactive, which is a quick way to work through a lesson and test things. > Of course, you’ll lose your work if the kernel dies, but the Binder option > does allow you to download the notebooks. > Nice. IIRC Thebe was initially developed for/by O'Reilly ( https://github.com/oreillymedia/thebe ). Cool to hear of real world applications! The Jupyter-book docs mention: Binder buttons for your pages JupyterHub buttons for your pages Google Colab buttons for your pages Live interactive pages with ThebeLab https://jupyterbook.org/interactive/launchbuttons.html Saving notebooks from transient cloud instances could be better. Possible solutions: - https://github.com/jupyterlab/jupyterlab-google-drive - https://github.com/jupyterlab/jupyterlab-github - e.g. localStorage - Native Filesystem Access https://wicg.github.io/file-system-access/ - https://web.dev/file-system-access/ > > > #### add'l resources > > https://github.com/quobit/awesome-python-in-education > > > > https://github.com/quobit/awesome-python-in-education#jupyter > > > > - "jupyter-education: Teaching with Jupyter Notebooks mailing list" > > https://groups.google.com/forum/#!forum/jupyter-education > > > > - github.com/jupyter4edu - best practices and content for teaching with > Jupyter notebooks > > - jupyter4edu/jupyter-edu-book - open source of the "Teaching and > Learning with Jupyter" book > > - https://jupyter4edu.github.io/jupyter-edu-book/ - "Teaching and > Learning with Jupyter" book > > These are great. Some I have seen, but others not. Thanks! > Yw! > > > https://classroom.github.com/ can run tests for students in order to > "grade" > > > > There's probably a way to run nbgrader "tests" with e.g. GitHub > Classroom CI? > > > We do indeed use GitHub Classroom, but we have not yet found an easy way > to run the nbgrader tests using their CI system. Perhaps it is possible, > but for now we are using our own “graderbot”, which pulls the student > repos, clones the solution repositories, runs nbgrader, and posts a > feedback summary in the README.md file for each student’s exercise repo. > The graderbot is currently in a private repository since we have students’s > GitHub usernames in some of the files used by it and we want to protect > their privacy. If anyone would like, I can make a public version without > the personal info. > It would probably be useful to call for similar notebook grading workflow descriptions, at least. There are a number of past threads. Posting to README.md is a good idea. How does this compare with a Pull Request bot feedback workflow in terms of archivability and otherwise? Something like git-crypt with a CI env var secret is one way to factor out auth/authz config. > > > FWIU, you can install Docker and/or Conda on an ARM64 e.g. Raspberry Pi > with Miniforge now, because the conda-forge repos have ARM64 packages now > (whereas if you install from PyPI on an ARM64 box, you'll be waiting for > builds to compile because there are very few ARM64 wheels on PyPI). > > > > Mamba (c++ port of the slow parts of conda) is much faster on a Pi, as > well. > > > Very cool. It’s really quite impressive what the Raspberry Pi machines can > do in such small packages. The conda-forge packages should also work with containers in e.g. crouton on ARM chromebooks. > > Thanks again for the input! > > Best, > Dave > > -- > David M. Whipp, Professor > > Institute of Seismology | Dept. of Geosciences and Geography | Univ. of > Helsinki > Seismologian instituutti | Geotieteiden ja maantieteen osasto | Helsingin > yliopisto > +358 (0)2 941 51617 | www.helsinki.fi/en/researchgroups/geodynamics | > twitter.com/HUGeodynamics > > > On 2. Feb 2021, at 19.56, Wes Turner <wes.tur...@gmail.com> wrote: > > > > > > > > On Tue, Feb 2, 2021, 11:30 kirby urner <kirby.ur...@gmail.com> wrote: > > > > Hi Dave -- > > > > Thank you for this excellent online course material re Python and the > geosciences. > > > > I've added a section to my evolving "elite school" repo listing courses > and curriculum > > using Jupyter Notebooks, as I want to impress upon my students that this > is how > > some of the better schools / teachers are currently sharing material. > > > > I want to impress them with the fact that we're learning some best > practices. > > > > > https://nbviewer.jupyter.org/github/4dsolutions/elite_school/blob/master/Home.ipynb > > (scroll to bottom for a link to your GeoPython). > > > > > https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks > > > > > > In contrast, many high schools do nothing with Jupyter Notebooks. Given > our > > "elite school" status, it's legit to point this out. Parents like to > know what their > > kids are learning is "ahead of the curve" vis-a-vis your run of the mill > high school. > > > > #### Questions for comprehension: > > > > ##### When is it better to write code as a module and/or a Jupyter > notebook? > > > > (Note that e.g. the fastai/nbdev template repo makes it easy to mark > .ipynb notebook input cells as for export to a .py python module) > > > > ##### How do I test a notebook and a module? > > - module: pytest > > - notebook: > > - nbdev > > - Pytest + Jupyter-specific plugin > > - `assert` statements to verify assumptions > > > > ##### When I share my repo, will people be able to run the code? > > > > If your dependencies are specified in REES-compatible way > (/requirements.txt, /environment.yml), users and BinderHub can use > repo2docker to generate a container with a current - and thus > security-updated - version of JupyterLab and also the [exact versions of] > the software dependencies you've specified. > > > > #### add'l resources > > https://github.com/quobit/awesome-python-in-education > > > > https://github.com/quobit/awesome-python-in-education#jupyter > > > > - "jupyter-education: Teaching with Jupyter Notebooks mailing list" > > https://groups.google.com/forum/#!forum/jupyter-education > > > > - github.com/jupyter4edu - best practices and content for teaching with > Jupyter notebooks > > - jupyter4edu/jupyter-edu-book - open source of the "Teaching and > Learning with Jupyter" book > > - https://jupyter4edu.github.io/jupyter-edu-book/ - "Teaching and > Learning with Jupyter" book > > > > > > The workflow I encourage with my students is to establish their own > presence > > on Github and to learn how to clone a repo so they can run the Notebooks > > locally (vs in the cloud). > > > > https://classroom.github.com/ can run tests for students in order to > "grade" > > > > There's probably a way to run nbgrader "tests" with e.g. GitHub > Classroom CI? > > > > Since I expect them to make Notebooks, I want them > > to have complete localhost control. > > > > FWIU, you can install Docker and/or Conda on an ARM64 e.g. Raspberry Pi > with Miniforge now, because the conda-forge repos have ARM64 packages now > (whereas if you install from PyPI on an ARM64 box, you'll be waiting for > builds to compile because there are very few ARM64 wheels on PyPI). > > > > Mamba (c++ port of the slow parts of conda) is much faster on a Pi, as > well. > > > > ```bash > > conda install -c conda-forge -y mamba; > > mamba install -c conda-forge python=3.8 jupyterlab pandas dask > matplotlib seaborn altair > > ``` > > > > You can use `jupyter console` to run Jupyter kernels for additional > languages like JS and TS in a REPL just like IPython: > > > > ```bash > > mamba install -c conda-forge -y jupyter-console jupyter-client nodejs > > npm install -g ijavascript > > npm install -g itypescript > > ijsinstall > > its --install=local > > jupyter kernelspec list > > jupyter console --kernel python3 > > ``` > > > > > > Kirby > > > > _______________________________________________ > > Edu-sig mailing list -- edu-sig@python.org > > To unsubscribe send an email to edu-sig-le...@python.org > > https://mail.python.org/mailman3/lists/edu-sig.python.org/ > > Member address: wes.tur...@gmail.com > >
_______________________________________________ Edu-sig mailing list -- edu-sig@python.org To unsubscribe send an email to edu-sig-le...@python.org https://mail.python.org/mailman3/lists/edu-sig.python.org/ Member address: arch...@mail-archive.com