Skip to content
Snippets Groups Projects
Verified Commit bdc49fa5 authored by Laurent Heirendt's avatar Laurent Heirendt :airplane:
Browse files

copy of git course from previous

parent a2634d99
No related branches found
No related tags found
No related merge requests found
# Quality of computer code is relevant for everyone.
`This does not concern me – I am only writing documentation or a script for generating a figure that I want to publish!`
[Anonymous researcher]
<div class="fragment">
**Great**, but ...
- Figure may not be reproducible
- Figure looks different when the input data changes
- Documentation will become outdated
… actually, **EVERYONE** writing documentation, a script, or code is concerned!
<div align="center">
<img src="slides/img/snoopy.png" height="400px">
</div>
# Attributes of high-quality computer code
**Quality** of computer code can be seen as a **group of various attributes**.
High-quality computer code should be:
1. <font color="#A52A2A">**Versioned**</font>: incremental code
2. <font color="#FFA500">**Well-written**</font> (formatted, documented, commented): easy to read by a human
3. <font color="#008931">**Tested**</font>: extensively tested code
<div align="center">
<img src="slides/img/qualitybadge.png">
</div>
\ No newline at end of file
# Reproducibility crisis
<div align="center">
<img src="slides/img/reproCrisis.png">
</div>
*Baker, M., <a href="https://www.nature.com/news/1-500-scientists-lift-the-lid-on-reproducibility-1.19970">1,500 scientists lift the lid on reproducibility</a>, Nature 533, 452–454, 2016. doi:10.1038/533452a*
\ No newline at end of file
# Synchronize your fork
![bulb](slides/img/bulb.png) Remember, we have to regularly update our own copy of the code.
Add the `upstream` address (original/protected repository)
```bash
$ git remote add upstream git@github.com:LCSB-BioCore/basic-git-practice.git
```
![bulb](slides/img/bulb.png) Note the change in the URL.
You can then check whether the remote address is set correctly
```bash
$ git remote -v
```
<div class="fragment">
Fetch the changes from upstream (similar to pull)
```bash
$ git fetch upstream
```
Merge the retrieved changes on the `master` branch:
```bash
$ git checkout master
$ git merge upstream/master
$ git push origin master
```
<div class="fragment">
Do the same for the `develop` branch.
<img src="slides/img/icon-live-demo.png" height="100px">
\ No newline at end of file
# Let's refresh our memories
<div class="fragment">
- What is a **fork**?
<div class="fragment">
- What are **branches**?
<div class="fragment">
- Can I have **multiple branches** in my fork?
<div class="fragment">
- What is a good **development scheme**?
<div class="fragment">
- What are the **5 essential commands**?
# References & Cheat sheet
[1]: Git Book: https://git-scm.com/book/en/v2
[2]: GitHub training services: https://services.github.com/training/
[3]: Cheat sheet: http://rogerdudler.github.io/git-guide
# Thank you.
<img src="slides/img/r3-training-logo.png" height="200px">
Contact us if you need help:
r3lab.core@uni.lu
# The editor(s)
Recommended editors:
- **Visual Studio Code** (https://code.visualstudio.com)
- **Atom** (https://atom.io)
*Note*: Other editors such as IntelliJ IDEA (https://www.jetbrains.com/idea) or Sublime Text (https://www.sublimetext.com) can, of course, also be used.
<img src="slides/img/icon-live-demo.png" height="100px">
\ No newline at end of file
# PART II
<br><br><h1>Basic git course</h1>
# The terminal (shell)
**macOS users:**
Start the Terminal from your `/Applications` directoy.
![bulb](slides/img/bulb.png) Install iTerm2: `https://www.iterm2.com`
**Windows users:**
Install Git Bash: <br>`https://git-scm.com/download/win`
**Linux users:**
Launch default terminal.<br>
![bulb](slides/img/bulb.png) Install Terminator: `https://launchpad.net/terminator`
# First steps in the terminal
Starting the terminal presents itself with a line where you can enter a command
```bash
cesar@myComputer>
```
Often written, for covenience, as
```bash
$
```
When you open your terminal (shell), you are located
in your home directory (unless otherwise configured), denoted as `~/`.
# Essential Linux commands
List the contents of a directory
```bash
$ ls #-lash
```
Create a directory
```bash
$ mkdir myNewDirectory
```
Change the directory to a specific folder
```bash
$ cd myNewDirectory
```
Change the directory 1 level and 2 levels up
```bash
$ cd ..
# 1 level up
$ cd ../..
# 2 levels up
```
Move a file or a directory
```bash
$ mv myFile.m myNewDirectory/.
```
Rename a file or a directory
```bash
$ mv myFile.m myNewFile.m
$ mv myNewDirectory myDirectory
```
\ No newline at end of file
# What is `git`?
<!-- ![](slides/img/git_definition.png) -->
`git` is a **version control system** (VCS) for tracking changes in computer files and coordinating work on those files among multiple people [1].
Designed and implemented in 2005 by **Linus Torvalds**
<div align="center">
<img src="slides/img/linus.jpg">
</div>
[1] *https://en.wikipedia.org/wiki/Git*
# The inventor of `git`
<div align="center">
<img src="slides/img/git_definition.png">
</div>
`I'm an egotistical bastard, and I name all my projects after myself.
First Linux, now git.`
Linus Torvald (2007-06-14)
# What is the use of `git`?
* No need to fully rewrite code; **reuse code** and **save time**
* Keep the changes you made over time (**history**)
* Allows you to **backtrack** (if necessary) and undo unwanted changes
* Easily **add contributions** of your collaborators to the main code base
note:
Other points to mention:
* git shall not be considered as a nuisance, but as a tool that should help to track and trace the code.
* git is not to track performance. Not using it shows exactly the opposite.
# What is computer code?
**Computer code**: Set of instructions executed by a computer
**Programming language:**: Style of writing the set of instructions (e.g., C, C++, Fortran, Python, R, Matlab, Julia, …)
**Example:**
<div align="center">
<img src="slides/img/computerCode.png">
</div>
<div class="fragment">
<div align="center"><font color="#A52A2A"><span class="fas fa-arrow-right"></span> Maybe this is not so relevant … or even, why should I care?</font></div>
# PART I
<br><br><h1>Quality of computer code.</h1><br>
<h1>Should you care? What if you didn't?</h1>
# A true story ...
<div align="center">
<img src="slides/img/wheel.png">
</div>
<table style="width:100%">
<tr>
<th width="33%" align="center">Researcher who cares about<br>quality of his code</th>
<th width="33%" align="center">Fellow researcher</th>
<th width="33%" align="center">Pi or Manager</th>
</tr>
</table>
\ No newline at end of file
# Why you should care (1)
<div align="center">
<video width="40%" controls>
<source src="slides/img/arianeLaunch.mov" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
**Aerospace Application**: First launch of Ariane 5, 1996
<font color="#A52A2A"><span class="fas fa-times-circle"></span></font> **Problem**: Rocket exploded shortly after liftoff.
<font color="#FFA500"><span class="fas fa-exclamation-triangle"></span></font> **Root cause of disaster - Software error:**
Horizontal velocity of the rocket exceeded the limits of the 16-bit signed integer value and led to overflow
Ariane 5 launched with the same software as Ariane 4 - **the code had not been tested**
# Why you should care (2)
<div align="center">
<img src="slides/img/therac.png">
</div>
**Biotechnology Application**: Therac-25 – computer controlled radiation therapy machine
<font color="#A52A2A"><span class="fas fa-times-circle"></span></font> **Problem**: Device malfunctions and delivers a lethal dose of radiation - several patients died.
<font color="#FFA500"><span class="fas fa-exclamation-triangle"></span></font> **Root cause of disaster - Software error:**
**No testing** of software before release, **lack of documentation**
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment