- Module Description
- Module Structure
- Setting up GitHub Codespaces
- Settings in VS Code
- Sync origin with upstream
- Solving merge conflicts
- Using GitHub Copilot in VS-Code
- Run OLLAMA in your Codespace
- Get the Kaggle API-key
This module teaches the fundamentals of scientific programming. The focus is on scientific programming for data science applications. The programming language is Python. Python as an object-oriented programming language has caught up with other programming languages in terms of popularity and distribution in recent years and is thus becoming increasingly important. Students learn the most important programming paradigms. Due to the application-oriented nature of the module, students acquire the necessary knowledge that allows them to apply Python in practice.
NOTICE: Please note that the weekly material will continously provided and always be available shortly before the course starts. In the course, we will use the following folder structure:
|--scientific_programming
|--Week_01
|--exercises
|--challenge
...
...
...
|--Week_14
- Go to GitHub.
- Click on "Sign up" and follow the instructions to create a new account.
- Navigate to the repository: https://github.com/mario-gellrich-zhaw/scientific_programming
- Click the "Fork" button at the top right of the repository page.
- Select your GitHub account as the destination for the fork.
- Go to your forked repository on GitHub.
- Click the "Code" button.
- Select the "Codespaces" tab.
- Click "Create codespace on master".
- Wait for the Codespace to initialize. This may take a few minutes.
- Also wait for the postcreate command to be finshed (installs additional Python libraries from the requirements.txt file).
- Once the Codespace is ready, you will be taken to a VS Code environment in your browser.
- Configure your environment as needed.
Make the following settings using the VS Code Command Palette (CTRL+SHIFT+P) and VS Code settings.
In VS Code Command Palette (CTRL+SHIFT+P):
- Python: Select Interpreter -> select the suggested (default) Python interpreter
- Configure Display Language -> change to 'en' (English)
- Preferences: Toggle between Light/Dark Themes
In VS Code Settings (CTRL+,):
-
Search for Editor:Rulers -> click on 'edit in settings.json' and change the entry to:
"editor.rulers": [80],
This will add a vertical line to the editor area showing when the max. number of characters in the code is reached.
First, make sure the upstream has been added and the origin's url is set.
# In the VS Code Terminal type ...
git remote -v
# The output should look like (YOUR-USERNAME should be your user name on GitHub) ...
# origin [email protected]:YOUR-USERNAME/scientific_programming.git (fetch)
# origin [email protected]:YOUR-USERNAME/scientific_programming.git (push)
# upstream https://github.com/mario-gellrich-zhaw/scientific_programming.git (fetch)
# upstream https://github.com/mario-gellrich-zhaw/scientific_programming.git (push)
# If this is not set correctly, type (replace YOUR-USERNAME with your user name on GitHub) ...
git remote add upstream https://github.com/mario-gellrich-zhaw/scientific_programming.git
git remote set-url origin https://github.com/YOUR-USERNAME/scientific_programming.git
To sync your fork (origin) and GitHub Codespaces environment with the upstream repository you can use the following Git commands:
# Option (1): Sync your fork/clone to exactly match the upstream (your local changes will be overwritten)
git fetch upstream
git checkout master
git reset --hard upstream/master
git push origin master --force
# Option (2): Sync your fork/clone with the upstream (your local changes are preserved but merge conflicts may have to be resolved)
git fetch upstream
git checkout master
git merge upstream/master
git push origin master
Later in the course you will modify the Python code provided on GitHub. When you modify Python code, merge conflicts may occur which is when two or more changes conflict with each other. This usually happens when multiple people are working on the same project and they try to merge their changes into a common codebase.
In VS Code, you can use the Merge Editor to solve merge conflics.
The following video explains how this works: https://www.youtube.com/watch?v=KuB6hYoLozw
The Copilot extension is already installed in VS-Code. To activate it, you must log in into your GitHub account and then activate the ZHAW GitHub Global campus licence:
Ollama is software designed to simplify the process of running open-source large language models (LLMs) on your local computer / in your Codespace. It acts as a local model manager and runtime, handling everything from downloading the model files to setting up a local environment where you can interact with them.
Ollama has already been installed in your codespace (see file devcontainer.json).
For an overview of available LLMs see: https://ollama.com/search.
To run ollama on GitHub Codespaces, import LLMs etc., open a new Terminal and type:
# Start ollama (keep Terminal open)
ollama serve
# Import and run LLM 'Llama 3.2' (2.0 GB) --> open a new Terminal
ollama run llama3.2:latest
# Quit the model
/bye
# Find running ollama processes
ps aux | grep ollama
# Stop all ollama processes
pkill -f ollama
- Create a Kaggle account on https://www.kaggle.com.
- On https://www.kaggle.com/settings -> API -> Create New Token
- This will trigger the download of kaggle.json, a file containing your API credentials.