[Edu-sig] Re: Online introductory Python course
On Tue, Feb 2, 2021 at 3:54 PM Whipp, David M 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
[Edu-sig] Re: Online introductory Python course
Hi Wes, I’ll respond where I can add something useful (hopefully). > 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). 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. > # 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. > # 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). 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. > 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! > 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. > 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. Thanks again for the input! Best, Dave -- David M. Whipp, Professor Institute of Seismology | Dept. of Geoscienc
[Edu-sig] Re: Online introductory Python course
Hi Kirby, Thanks for the positive feedback! > 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. I think that among the researchers I mix with we’re using a mix of Python scripts and Jupyter notebooks. For beginners, however, the notebooks do seem to be quite handy, especially when we ask the students to explain what they’re doing with some kind of data analysis. I’ve even had students writing their final project reports in some courses using Jupyter notebooks. They’re able to include text like a more typical Word document (or whatever), but also the code to produce the plots they are asked to include. Very nice way to show them that the notebook contains everything for someone to be able to reproduce your work. Open science and reproducibility are being promoted across the sciences in Finland. > 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. Indeed. For us, we have students who often see themselves as unable to learn programming in the way it might be taught in computer science or physics, for example. The notebooks and our approach using data they’re familiar with seems to provide a bit of motivation, as well as helping them see that most anyone can learn the basic programming concepts. Some take off and run with it, while others just aim to pass the course, but I feel that many of the students enjoy the course in general, and also that the notebook format is a good one to help them get started. > 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). Since I expect them to make Notebooks, I want them > to have complete localhost control. Yes, this is indeed a good way to go. We’re fortunate here that our national computing organisation has worked with us and we now have a cloud platform with persistent storage that is available to all Finnish university students. Binder is great for demonstrations, but it is no fun when your instance dies unexpectedly. Similar to you, however, we do encourage the students to go ahead and install some Python + Jupyter things locally on their computers so they have an even lower threshold for tinkering :). 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 18.30, kirby urner 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). > > 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. > > 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). Since I expect them to make Notebooks, I want them > to have complete localhost control. > > 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: arch...@mail-archive.com
[Edu-sig] Re: Friendly-traceback: useful tool for those teaching Python
On Tue, Feb 2, 2021 at 2:37 PM kirby urner wrote: > On Tue, Feb 2, 2021 at 5:48 AM André Roberge > wrote: > >> Hello everyone, >> >> For about 20 months now, I have been working on a Python package intended >> to help beginners figure out what went wrong when their program generates a >> traceback. This package is called Friendly-traceback; you can find the >> fairly extensive documentation at >> https://aroberge.github.io/friendly-traceback-docs/docs/html/ >> >> > Hi André -- > > I'm reading your docs now. > > When I start into Python with beginners, I'll typically start with: > > >>> dir( ) # how will HyperKitty mangle this? > > showing what's in the namespace, the names Python > knows when "in" the namespace. > > But then the question right away arises: where are > print, hex, str, dict... all these names Python knows? > > Answer (as we all know): __builtins__ > > So then I do a dir(__builtins__) > I think you mean simply __builtins__, without the dir(). I use "pretty" from Rich ( https://rich.readthedocs.io/en/latest/introduction.html?highlight=pretty#python-in-the-repl) so that dicts are nicely formatted. > > [ pray to HyperKitty for no mangling ] and they see: > > Wow! Lots and Lots of names (so that's where > everyone has been hiding), many with Error > and/or Warning in them. Those come at the top > as dir returns string elements alphabetically and > capitalized Exceptions list up top (or leftmost). > > This will be my bridge to your Friendly-Traceback > utility i.e. here would be an (early, introductory) > example of a 3rd party project aimed at helping > a beginner get the most out of the Python experience. > > Tracebacks themselves have that purpose already, > and you're enhancing that existing capability, which is > easy for beginners to understand. Make a good thing > better. > > A current weakness in my curriculum is I don't spend > enough time on IDE features relating to debugging and > live inspecting of what's in the namespace. I demonstrate > a lot using Spyder, assuring them a different IDE is just > fine. Spyder has features that make it great for screen > sharing Python, such as scrollback, the %magics, embedded > plots... > > Anyway, my point is Exceptions and the Tracebacks they > occasion, deserve a direct and early discussion, as any > beginner is likely to stumble across both in the course of > ordinary REPL use. > > I'm still adding pages to my most recent iteration of an Elite > School (and I do have synchronous students -- we meet once a > week). We'll be discussing your innovative enhancements. > Ideally, at least one of us (most likely me) will install it and > do Show & Tell (a Lightning Talk). > > Back to reading the docs... > > 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: arch...@mail-archive.com
[Edu-sig] Re: Friendly-traceback: useful tool for those teaching Python
On Tue, Feb 2, 2021 at 5:48 AM André Roberge wrote: > Hello everyone, > > For about 20 months now, I have been working on a Python package intended > to help beginners figure out what went wrong when their program generates a > traceback. This package is called Friendly-traceback; you can find the > fairly extensive documentation at > https://aroberge.github.io/friendly-traceback-docs/docs/html/ > > Hi André -- I'm reading your docs now. When I start into Python with beginners, I'll typically start with: >>> dir( ) # how will HyperKitty mangle this? showing what's in the namespace, the names Python knows when "in" the namespace. But then the question right away arises: where are print, hex, str, dict... all these names Python knows? Answer (as we all know): __builtins__ So then I do a dir(__builtins__) [ pray to HyperKitty for no mangling ] and they see: Wow! Lots and Lots of names (so that's where everyone has been hiding), many with Error and/or Warning in them. Those come at the top as dir returns string elements alphabetically and capitalized Exceptions list up top (or leftmost). This will be my bridge to your Friendly-Traceback utility i.e. here would be an (early, introductory) example of a 3rd party project aimed at helping a beginner get the most out of the Python experience. Tracebacks themselves have that purpose already, and you're enhancing that existing capability, which is easy for beginners to understand. Make a good thing better. A current weakness in my curriculum is I don't spend enough time on IDE features relating to debugging and live inspecting of what's in the namespace. I demonstrate a lot using Spyder, assuring them a different IDE is just fine. Spyder has features that make it great for screen sharing Python, such as scrollback, the %magics, embedded plots... Anyway, my point is Exceptions and the Tracebacks they occasion, deserve a direct and early discussion, as any beginner is likely to stumble across both in the course of ordinary REPL use. I'm still adding pages to my most recent iteration of an Elite School (and I do have synchronous students -- we meet once a week). We'll be discussing your innovative enhancements. Ideally, at least one of us (most likely me) will install it and do Show & Tell (a Lightning Talk). Back to reading the docs... 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: arch...@mail-archive.com
[Edu-sig] Re: Online introductory Python course
On Tue, Feb 2, 2021, 11:30 kirby urner 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
[Edu-sig] Re: Online introductory Python course
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). 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. 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). Since I expect them to make Notebooks, I want them to have complete localhost control. 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: arch...@mail-archive.com
[Edu-sig] Friendly-traceback: useful tool for those teaching Python
Hello everyone, For about 20 months now, I have been working on a Python package intended to help beginners figure out what went wrong when their program generates a traceback. This package is called Friendly-traceback; you can find the fairly extensive documentation at https://aroberge.github.io/friendly-traceback-docs/docs/html/ Friendly-traceback can be used to run programs from the command line, or from an editor; it also comes with its own REPL. Jupyter notebooks are also supported. While there is still much to be added to it (I don't know if I'll ever reach a "complete enough" version to be designated as version 1.0), I would appreciate feedback from those of you who teach beginners (or advanced beginners), including any suggestion as to how it could be made more useful. All the best and stay safe, André Roberge ___ 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
[Edu-sig] Online introductory Python course
Hi all, I’ve been silently following this mailing list for a few years now and wanted to share an online course that some colleagues and I have developed at the University of Helsinki, Finland. The course is intended for Bachelor’s and Master’s students in Geology and Geography, but introduces Python programming assuming no previous programming experience. In other words, it could likely be adapted for use by many different groups, even advanced high school students. All of the course lesson materials and exercises are available freely online (and in English), and you’re also most welcome to fork our GitHub repository with the course materials and adapt them for your use. Below are a few links you might find useful if you want to check it out. Course website: https://geo-python.github.io Course GitHub organisation: https://github.com/Geo-Python We’re also currently working on a textbook that builds on the basic Python materials and applies them to geographic data analysis. The book is expected to be published later this year or in early 2022. It will also be available online, and you’re welcome to check out the work in progress at https://python-gis-book.readthedocs.io/en/develop/. Just thought you folks might be interested, and if you have any questions or feedback on the course (and book), please feel free to contact us via email. Kind regards, Dave Whipp - david.wh...@helsinki.fi Henrikki Tenkanen - henrikki.tenka...@aalto.fi Vuokko Heikinheimo - vuokko.heikinhe...@helsinki.fi -- 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 ___ 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