Open-Source Project: Introduction to Python

WI-Project: Open-Source Project

Introduction to Python (1)

Prof. Dr. Gerit Wagner
Faculty Information Systems and Applied Computer Sciences
Otto-Friedrich-Universität Bamberg

center

♻️ 🛠️
Open-Source Project: Introduction to Python

Project: Groups, forks and setup

  • Groups formed in the issue feeds
  • Forks were created.
  • Further questions related to GitHub or the setup?
♻️ 🛠️
Open-Source Project: Introduction to Python

Learning objectives:

  • Familiarize with Python syntax
  • Learn good debugging and development practices
  • Understand how to extend a Python package (CoLRev)

Information on this session:

  • Form groups of three to four participants to collaborate on the tasks, solve them together, and engage in meaningful discussions about your solutions.
  • Over the course of two sessions, we will focus on refining a single module using the colrev run command, progressively enhancing it with each iteration.
♻️ 🛠️
Open-Source Project: Introduction to Python

Start the Codespace

Open the Notebook: Open Notebook

Start the Codespace in the tutorial_python branch of the CoLRev upstream repository.

The setup can run in the background, while we focus on the concepts.

♻️ 🛠️
Open-Source Project: Introduction to Python

Python

  • Supports multiple paradigms: object-oriented, procedural, or functional
  • Python is an interpreted language: no need to compile (build jars) before running
  • Uses indentation instead of brackets to separate blocks (such as if statements)
  • Is strongly, dynamically typed
  • Provides access to many packages on PyPI, covering machine learning, data science, web scraping, etc.
  • Python is actively developed, with new versions introducing changes in functionality and old versions no longer receiving security updates
♻️ 🛠️
Open-Source Project: Introduction to Python

What we will learn in the Python session(s)

center

♻️ 🛠️
Open-Source Project: Introduction to Python

Writing and running Python code

center

♻️ 🛠️
Open-Source Project: Introduction to Python

Python packages

center

♻️ 🛠️
Open-Source Project: Introduction to Python

Best practices

  • Carefully read tutorials, vignettes, and code examples (e.g., on GitHub)
  • Start with small code segments, try whether they work, and extend them
  • Add or commit working code frequently
  • Use code linters to ensure high code quality (run pre-commit run --all)
  • To debug code, check whether variables have the expected values (use assert or print statements)
  • When exceptions are thrown, read the Traceback:

center

♻️ 🛠️
Open-Source Project: Introduction to Python

Next steps

  • Read the package development documentation.
  • Study code of related CoLRev packages.
  • Take notes on the CoLRev-objects or libraries that will be needed.

Note: These tutorials may be helpful to continue practicing Python

♻️ 🛠️

--- For the tutorial, we switch to the `tutorial_2024_04` branch: ``` git clone https://github.com/CoLRev-Environment/colrev cd colrev pip install -e .[dev] git fetch git checkout tutorial_2024_04 git reset --hard ca9902e666518af1d33a368adf055c9809004433 ``` - As the session progresses, you can checkout the current commits. - Whenever you see a `git reset --hard ...` command on the following slides, you can use it to set your repository to the required state (commit).