Working with the course material

Tools

We use the following main development tools in the course (you can learn them by doing)

  • python for programming - An IDE may be helpful (jupyterlab may suffice, perhaps also VSCode, PyCharm, .. )
  • git - we may want to fork the main project and send commits/branches around - Using git (at least within jupyterlab) is needed
  • jupyter - jupyterlab (e.g. through the gwdg jupyterhub cloud) suffices, but
  • pytest - we want to test implementation and use pytest
  • gitlab - as project management system gitlab provides some further tools such as continuous integration (CI) which we will use

We will clone and setup the project together.

Setting up for the project

Forking the project

Go to the base project and fork it to your own namespace. This should copy many settings such as

  • CI and
  • gitlab pages deployment
  • the docker container registry being active for your fork.

Once, you have forked the project, we can discuss the project together.

Note: Keep the fork updated with the base project. You will be noticed whenever there are important updates!

Cloning the project

To work on the project, you need to git clone it to your local machine (or jupyter hub in the gwdg cloud).

Running the tests

You can see the tests in the tests directory.

  • They run with the CI pipeline (see in gitlab)
  • You can run them locally by installing pytest and running pytest in the tests directory.
  • Many of the existing tests still fail due to a missing implementation - this is left for you to fill up within the course.
  • You should add more tests within the project

Demos

In demos you should add larger examples, test cases, experiments, etc., as python or jupyter files. As of now there is only a single demo.

Some explanation on the code structure

Let us have a look at the code, directories and files together.

Generate simple class diagram (optional - don't care if it does not work)

We generate a class diagram. This requires pylint and graphviz to be installed on your system:

In [1]:
!pip install pylint graphviz --break-system-packages
Collecting pylint
  Downloading pylint-3.3.1-py3-none-any.whl.metadata (12 kB)
Collecting graphviz
  Downloading graphviz-0.20.3-py3-none-any.whl.metadata (12 kB)
Requirement already satisfied: platformdirs>=2.2.0 in /usr/local/lib/python3.13/site-packages (from pylint) (4.3.6)
Collecting astroid<=3.4.0-dev0,>=3.3.4 (from pylint)
  Downloading astroid-3.3.5-py3-none-any.whl.metadata (4.5 kB)
Collecting isort!=5.13.0,<6,>=4.2.5 (from pylint)
  Downloading isort-5.13.2-py3-none-any.whl.metadata (12 kB)
Collecting mccabe<0.8,>=0.6 (from pylint)
  Downloading mccabe-0.7.0-py2.py3-none-any.whl.metadata (5.0 kB)
Collecting tomlkit>=0.10.1 (from pylint)
  Downloading tomlkit-0.13.2-py3-none-any.whl.metadata (2.7 kB)
Collecting dill>=0.3.6 (from pylint)
  Downloading dill-0.3.9-py3-none-any.whl.metadata (10 kB)
Downloading pylint-3.3.1-py3-none-any.whl (521 kB)
Downloading graphviz-0.20.3-py3-none-any.whl (47 kB)
Downloading astroid-3.3.5-py3-none-any.whl (274 kB)
Downloading dill-0.3.9-py3-none-any.whl (119 kB)
Downloading isort-5.13.2-py3-none-any.whl (92 kB)
Downloading mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB)
Downloading tomlkit-0.13.2-py3-none-any.whl (37 kB)
Installing collected packages: tomlkit, mccabe, isort, graphviz, dill, astroid, pylint
Successfully installed astroid-3.3.5 dill-0.3.9 graphviz-0.20.3 isort-5.13.2 mccabe-0.7.0 pylint-3.3.1 tomlkit-0.13.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
[notice] A new release of pip is available: 24.2 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
In [2]:
!pyreverse --colorized -k -opdf ../src/methodsnm && mv classes.pdf ../graphics/classes.pdf
'Graphviz' needs to be installed for your chosen output format.

Now, we can inspect it in the notebook:

In [3]:
from IPython.display import IFrame
IFrame("../graphics/classes.pdf", width="100%", height=500)
#IFrame("../graphics/classes_ref.pdf", width="100%", height=500)
Out[3]:

If displaying does not work (VSCode ?!), just directly navigate to it (or to a reference).