diff --git a/slides.qmd b/slides.qmd index 415a2ba2422c7db5b4b0b237d9d953309e92cd8f..69601047e9b182923a4c2887f15813f90cdb7911 100644 --- a/slides.qmd +++ b/slides.qmd @@ -27,6 +27,10 @@ author:  ::: +:::{.notes} +Python is around for decades and has a immense user community driving the development of various projects. +::: + :::: # Interpreter @@ -42,6 +46,10 @@ author: print("Hello world!") ``` +:::{.notes} +Because python code is not compiled, the result at runtime depends on the script **and** the interpreter. +::: + # Standard library * Python code is organized in [modules](https://docs.python.org/3/tutorial/modules.html) and [packages](https://docs.python.org/3/tutorial/modules.html#packages) @@ -70,12 +78,21 @@ In Python, the term "library" is only used in the context of the standard librar python3 -m pip install numpy ``` +:::{.notes} +It straight-forward to install external packages in addition to the standard library of your interpetor +::: + # Package manager * A package manager helps you to install different versions of packages and their dependencies * General purpose package manager (`brew`, `apt-get`, `conda`, ...) * Python package manager (`pip`, `conda`, ...) +:::{.notes} +While `pip` is **part of** the standard library, you need an interpreter to run it. +General purpose package managers can help to install different python interpreters/versions. +::: + # Virtual environments * Allows you to have a specific combination of libraries/binaries/packages for a project @@ -83,6 +100,12 @@ In Python, the term "library" is only used in the context of the standard librar * [`venv`](https://docs.python.org/3/library/venv.html) (formerly known as `virutalenv`) is shipped with the standard library * Tools to handle general software environments (e.g. `conda`) +:::{.notes} +An increasing number of packages in an environment makes the dependence resolution difficult. +It is best, to have smaller individual environments for a dedicated task. +This makes the environment easier to reproduce, to test, and to maintain. +::: + # (Ana)conda * `conda` is a general purpose package manager @@ -92,6 +115,10 @@ In Python, the term "library" is only used in the context of the standard librar _iv)_ and other software/libraries (e.g. ecCodes, NetCDF, ...) * Due to restricted system permissions, `conda` became quite popular among HPC users +:::{.notes} +`conda` is a general purpose package manager that can handle virutal environments with different python versions. +::: + # The amazing world of snakes {.national} :::: {.columns} @@ -109,7 +136,7 @@ In Python, the term "library" is only used in the context of the standard librar  -* Among the heaviest snakes on Earth +* Heaviest snakes on Earth (up to 90 kg) ::: ::: {.column width="30%"} @@ -151,6 +178,10 @@ In Python, the term "library" is only used in the context of the standard librar python3 -m pip install gribscan ``` +:::{.notes} +`micromamba` is the easiest solution to setup a python environment on any system. +::: + # Recreating an environment Specify environment name, python version and dependencies: @@ -173,6 +204,11 @@ mamba env create -f environment.yaml mamba activate my_env ``` +:::{.notes} +You **should** create environments from an `environment.yaml`. +This approach improves documentation and reproducibility. +::: + # Excursion: Ipython kernels * Make an environment usable in Jupyterhub @@ -187,7 +223,7 @@ mamba activate my_env ``` * The environment is now available as kernel in jupyter -# Conclusions +# Take-office messages * Use virtual environments to organize dependencies for your projects * Keep track of installed packages using an `environment.yaml` file