Skip to article frontmatterSkip to article content

Open Code

Workshop Description

Modern research relies heavily on computational tools, and adopting open coding practices enhances reproducibility, collaboration, and transparency. This workshop provides an introduction to open code principles and practical tools for managing research code efficiently. Participants will learn essential skills in version control, collaborative coding, and project management using Git, GitHub, VS Code, and uv.

This session is designed for researchers, students, and faculty members who want to streamline their coding workflows and embrace best practices in open research software. No prior experience with Git, GitHub, or uv is required, making it an excellent starting point for beginners.

Learning Outcomes

By the end of the workshop, participants will be able to:

Format

This is an interactive, hands-on workshop conducted virtually via Zoom. Participants will follow along with demonstrations and practice key concepts through guided exercises.

Prerequisites

To ensure a smooth learning experience, participants are encouraged to install the following tools before the workshop:

We look forward to seeing you at the workshop and helping you unlock the power of open code in your research!

Date and Time

Instructor

Who Should Attend?

This workshop is ideal for:

No prior experience with Git or GitHub is required, making this session suitable for beginners.

Registration

To attend, please complete the registration form at this link. Once registered, you will receive a confirmation email with the Zoom link and preparation instructions.

Workshop Recording

A recording of the workshop will be available on the Open Geospatial Solutions YouTube channel after the event.


1. Introduction to Open Code

Why Open Code?

Tools for Open Code


2. Introduction to Git

What is Git?

Installing Git

Basic Git Commands

# Configure Git with your name and email
$ git config --global user.name "Your Name"
$ git config --global user.email "your.email@example.com"

# Initialize a Git repository
$ git init

# Check repository status
$ git status

# Add files to staging area
$ git add filename

# Commit changes
$ git commit -m "Your commit message"

# View commit history
$ git log

3. Introduction to GitHub

Setting Up GitHub

Creating a Repository on GitHub

  1. Go to GitHub, click on New Repository.
  2. Name the repository and select visibility (public/private).
  3. Initialize with a README (optional).

Connecting Local Repository to GitHub

# Clone a repository from GitHub
$ git clone https://github.com/your-username/repository-name.git

4. Introduction to VS Code

Visual Studio Code is a free, cross-platform source-code editor developed by Microsoft for Windows, Linux, and macOS. It’s lightweight, highly customizable, and packed with features to make coding efficient and enjoyable. Key features include:

VS Code also supports an extensive library of extensions to enhance functionality, allowing you to tailor the editor to meet your specific needs.

Installation

  1. Download and Install: Visit the Visual Studio Code website and download the installer for your operating system (Windows, macOS, or Linux). Follow the installation instructions provided on the website.
  2. Launch VS Code: After installation, open Visual Studio Code.
  3. Verify Installation: Ensure that VS Code is installed correctly by checking the version. Open the terminal or command prompt and type code --version. You should see the installed version number.

Important Extensions for Software Development

These extensions are critical for Python and Jupyter-based workflows:


VS Code Extension Packs

An extension pack is a curated collection of related extensions bundled together to enhance a specific workflow or domain. These packs save time by providing all the essential tools in a single installation.

The Microsoft Python Data Science Extension Pack is a must-have for data scientists and geospatial analysts. It includes the following powerful tools:

5. Git Integration in VS Code

Setting Up VS Code for Git and GitHub

Using Git in VS Code

Cloning Repositories in VS Code

  1. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P on Mac)
  2. Search for “Git: Clone”
  3. Enter the repository URL from GitHub
  4. Choose a local directory to store the repository
  5. Open the repository in VS Code

6. Introduction to uv

uv is an extremely fast Python package and project manager, written in Rust. For packages that can be installed from PyPI, uv is a great alternative to pip. To install uv, follow the instructions in the official documentation to install uv on your system.

Once installed, you can use uv to create a new environment and install packages as follows:

cd /path/to/your/project
uv venv
uv venv --python 3.12
uv pip install jupyterlab leafmap
uv run jupyter lab

7. Collaborative Workflows

Forking and Pull Requests

Steps for Contributing

  1. Fork a repository
  2. Clone your fork using VS Code
  3. Create a new branch
    $ git checkout -b feature-branch
  4. Make changes and commit
    $ git add .
    $ git commit -m "Added a new feature"
  5. Push to your fork
    $ git push origin feature-branch
  6. Create a Pull Request on GitHub

8. Best Practices for Open Code


9. Hands-on Exercises

Exercise 1: Version Control Basics

  1. Create a new local Git repository.
  2. Add and commit a sample file.
  3. View commit history.

Exercise 2: Using VS Code with Git

  1. Clone a repository using VS Code.
  2. Make changes and use the Source Control panel to commit.
  3. Push the changes using the UI or terminal.

Exercise 3: Collaboration on GitHub

  1. Fork a sample repository.
  2. Make changes in a new branch.
  3. Submit a pull request.

Wrap-up & Q&A


Happy coding! 🎉