INCF/OCNS Software WG

The INCF/OCNS Software Working Group

Software WG tutorials at CNS*2021 Online: Bash, Git, and Python


The Software Working Group is holding three beginner/intermediate level tutorials at the upcoming CNS*2021 Online conference. These will cover using the command line (Bash), using Git and GitHub, and development in the Python programming language.

To attend these, and other tutorials at CNS*2021, please register for the conference here.

Effective use of Bash



Abstract

The purpose of this tutorial is to introduce participants to the tools they need in order to comfortably and confidently work with a Unix/Linux command line terminal. Unlike graphical user interfaces, which are often self-explanatory or have obvious built-in help options, the purely text-based nature of a command line terminal can be intimidating and confusing to novice users. Yet, once mastered, the command line offers more flexibility and smoother workflows for many tasks, while being entirely irreplaceable for things such as cluster access.

In this tutorial, we aim to introduce participants to the concepts and tools they need to confidently operate within a Unix/Linux command line environment. In particular, the tutorial is developed for Bash (as per the title), which should cover most Linux and MacOS* use cases. We hope to provide participants with a firm understanding of the basics of using a shell, as well as an understanding of the advantages of working from a command line.

The tutorial is aimed not only at novices who have rarely or never used a command line, but also at occasional or even regular users of bash who seek to expand or refresh their repertoire of everyday commands and the kinds of quality-of-life tricks and shortcuts that are rarely covered on StackExchange questions.

* While MacOS has switched from bash to zsh as its default shell, zshs operation is sufficiently similar for the purposes of this tutorial.

Prerequisites

A working copy of bash; participants on Linux and MacOS are all set.

Participants on Windows have several options to get hold of a bash environment without leaving familiar territory:

  • Install Git for Windows, which includes a Git Bash emulation with most of the standard tools you might expect in a Linux/Unix environment, plus of course Git.
  • Alternatively, enable WSL2 and install Ubuntu as a virtual machine hosted by Windows. Somewhat ironically, this requires at least one use of a command line terminal (though not bash); on the upside, the Linux-on-Windows experience can be a smooth and safe first step into Linux territory.

Topics

  • Basics to refer back to: Operating your bash shell (with key bindings and patience)
  • The grammar of a shell command line
  • Getting around: navigating within and beyond your computer: ~, pwd, cd, pushd/popd, ssh
  • Seeing what’s there: ls, globbing, and strategies for naming your files
  • File system manipulations: mv, cp/scp, rm, mkdir, rmdir, ln -s, touch
  • Looking into files: cat, head & tail, more or less, grep, diff
  • Text manipulation: sed, sort, uniq, cut, column
  • Putting things together: piping and redirection
  • What to do when stuck: man, I need some help here apropos of this command…

Effective use of Git



Abstract

Version control is a necessary skill that users writing any amount of code should possess. Git is a popular version control tool that is used ubiquitously in software development.

This hands-on session is aimed at beginners who have little or no experience with version control systems and Git. It will introduce the basics of version control and walk through a common daily Git workflow before moving on to show how Git is used for collaborative development on popular Git forges such as GitHub. Finally, it will show some advanced features of Git that aid in debugging code errors.

Prerequisites

The session is intended to be a hands-on session, so all attendees will be expected to run Git commands. A working installation of Git is, therefore, required for this session. We will use GitHub as our Git remote for forking and pull/merge requests. So a GitHub account will also be required.

  • Linux users can generally install Git from their default package manager:
    • Fedora: sudo dnf install git
    • Ubuntu: sudo apt-get install git
  • Windows users should use Git for Windows.
  • MacOS users should use brew to install git: brew install git.

More information on installing Git can be found on the project website: https://git-scm.com/

Topics

  • a brief introduction to Git
    • references, options
    • where to get help
  • using Git on a daily basis:
    • creating a new repository init
    • adding files and staging files: add, add -i
    • ignoring files: .gitingore
    • stashing: stash
    • viewing changes: diff, log
    • committing files: commit
    • using branches to organise the development workflow: branch, checkout
    • tagging: tag
    • creating an archive: archive
  • using Git for collaborative development
    • remotes, forks: remote
    • pushing and pulling: push, pull
    • pull requests and merging: merge
    • merge conflicts and resolving them
  • slightly advanced git
    • Git worktrees: worktree
    • interactive rebasing: rebase -i
    • cherry-picking: cherry-pick
    • debugging with git-bisect: bisect

Python for beginners



Abstract

Python is amongst the most widely used programming languages today, and is increasingly popular in the scientific domain. A large number of tools and simulators in use currently are either implemented in Python, or offer interfaces for their use via Python. Python programming is therefore a very sought after skill in the scientific community.

This tutorial is targeted towards people who have some experience with programming languages (e.g. MATLAB, C, C++, etc), but are relatively new to Python. It is structured to have you quickly up-and-running, giving you a feel of how things work in Python. We shall begin by demonstrating how to setup and manage virtual environments on your system, to help you keep multiple projects isolated. We’ll show you how to install Python packages in virtual environments and how to manage them. This will be followed by a quick overview of very basic Python constructs, leading finally to a neuroscience-themed project that will give you the opportunity to bring together various programming concepts with some hands-on practice.

Prerequisites

  • shell (participants on Linux and MacOS are all set; see below for Windows users)
  • Python 3.6.9 or higher (see below for info on installation)

Participants on Windows have several options to get hold of a shell environment without leaving familiar territory:

  • Install Git for Windows, which includes a Git Bash emulation with most of the standard tools you might expect in a Linux/Unix environment, plus of course Git.
  • Alternatively, enable WSL2 and install Ubuntu as a virtual machine hosted by Windows. This Linux-on-Windows experience can be a smooth and safe first step into Linux territory.

You will find several resources online for info on installing Python. e.g. https://realpython.com/installing-python/

Topics

  • Setting up and managing virtual environments
  • Installing packages using PyPI (pip) and from Git repositories (e.g. GitHub)
  • Quick Python 101 - lists, dicts, if…else, loops, functions, error handling, import, help, numpy, matplotlib
  • Short neuroscience-themed project - modularizing the code
  • Good practices - lint (Flake8)