Skip to content

Commit

Permalink
Merge pull request #67 from hsf-training/gfidalgo/Videos
Browse files Browse the repository at this point in the history
gfidalgo/Videos
  • Loading branch information
GuillermoFidalgo authored Feb 26, 2024
2 parents c893864 + 8692dea commit a0ee8f1
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 31 deletions.
3 changes: 2 additions & 1 deletion _episodes/01-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ keypoints:
- CI/CD is crucial for any reproducibility and testing
- Take advantage of automation to reduce your workload
---
<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/dTuVEL5-sSw?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/6gQTE2djdr4?si=PSlNzYPdkwZc1bot" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# What is CI/CD?

Continuous Integration (CI) is the concept of literal continuous integration of code changes. That is, every time a contributor (student, colleague, random bystander) provides new changes to your codebase, those changes are tested to make sure they don't "break" anything. Continuous Deployment (CD), similarly, is the literal continuous deployment of code changes. That means that, assuming the CI passes, you'd like to automatically deploy those changes.
Expand Down
3 changes: 2 additions & 1 deletion _episodes/02-enter-sandman.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ keypoints:

As we enter the first episode of the Continuous Integration / Continuous Deployment (CI/CD) session, we learn how to exit.

<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/NpJcaQPvLC0?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/Z7aVq3DNH6U?si=QVvru9yRjsYkupA9" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# Start by Exiting

How does a general task know whether or not a script finished correctly or not? You could parse (`grep`) the output:
Expand Down
3 changes: 2 additions & 1 deletion _episodes/03-understanding-yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ keypoints:
- YAML is a superset of JSON, so it contains additional features like comments and anchors, while still supporting JSON.
---

<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/c2sUhK3pDGo?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/7DPDBeMWWkU?si=2ixLz8YfEo-3VlOc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# YAML

YAML (Yet Another Markup Language or sometimes popularly referred to as YAML Ain't Markup Language (a recursive acronym)) is a human-readable data-serialization language. It is commonly used for configuration files and in applications where data is being stored or transmitted. CI systems' modus operandi typically rely on YAML for configuration. We'll cover, briefly, some of the native types involved and what the structure looks like.
Expand Down
24 changes: 7 additions & 17 deletions _episodes/04-understanding-yaml-and-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ keypoints:
- A job is defined by a name and a script, at minimum.
- Other than job names, reserved keywords are the top-level parameters defined in a YAML file.
---
<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/1Kz3VrzYHb0?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/tiAwTKNzjSo?si=u4uQRkNmqLqH13cB" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# GitLab CI YAML

The GitLab CI configurations are specified using a YAML file called `.gitlab-ci.yml`. Here is an example:
Expand Down Expand Up @@ -43,18 +44,12 @@ This YAML configuration represents a basic GitLab CI/CD pipeline with one stage
> Sometimes, `script` commands will need to be wrapped in single or double quotes. For example, commands that contain a colon (`:`) need to be wrapped in quotes so that the YAML parser knows to interpret the whole thing as a string rather than a “key: value” pair. Be careful when using special characters: `:`, `{`, `}`, `[`, `]`, `,`, `&`, `*`, `#`, `?`, `|`, `-`, `<`, `>`, `=`, `!`, `%`, `@`, `\``.
{: .callout}

This is the simplest possible configuration that will work for most code using minimal dependencies with `cmake` and `make`:

1. Define one job `build_code` (the job names are arbitrary) with different commands to be executed.
2. Before every job, the commands defined by `before_script` are executed.

The `.gitlab-ci.yml` file defines sets of jobs with constraints of how and when they should be run. The jobs are defined as top-level elements with a name (in our case `build_code`) and always have to contain the `script` keyword. Let's explore this structure in more depth.

## Overall Structure

Every single parameter we consider for all configurations are keys under jobs. The YAML is structured using job names. For example, we can define three jobs that run in parallel (more on parallel/serial later) with different sets of parameters.

~~~
~~~yml
job1:
param1: null
param2: null
Expand All @@ -68,7 +63,7 @@ job3:
param4: null
param5: null
~~~
{: .language-yaml}


> ## Parallel or Serial Execution?
>
Expand All @@ -89,7 +84,7 @@ What can you not use as job names? There are a few reserved keywords (because th

Global parameters mean that you can set parameters at the top-level of the YAML file. What does that actually mean? Here's another example:

~~~
~~~yml
stages: [build, test, deploy]

<workflow_name>:
Expand All @@ -110,10 +105,6 @@ job_2:
- echo "Commands for the second job - Step 2"

~~~
{: .language-yaml}

where `stages` is the global parameter being used. We will talk about stages later on.


> ## Stages???
>
Expand All @@ -126,16 +117,15 @@ where `stages` is the global parameter being used. We will talk about stages lat

What are some of the parameters that can be used in a job? Rather than copy/pasting from the reference (linked below in this session), we'll go to the [Configuration parameters](https://docs.gitlab.com/ee/ci/yaml/#configuration-parameters) section in the GitLab docs. The most important parameter, and the only one needed to define a job, is `script`

~~~
```yml
job one:
script: make

job two:
script:
- python test.py
- coverage
~~~
{: .language-yaml}
```
> ## Understanding the Reference
>
Expand Down
3 changes: 2 additions & 1 deletion _episodes/06-hello-world-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ keypoints:
- Pipelines are made of stages, stages are made of jobs.
- CI Linters are especially useful to check syntax before pushing changes.
---
<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/LqeJzIYJCwc?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/IvmbDs0qzpo?si=LGV7o7CECIp9BLEZ" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# Adding CI/CD to a project

We've been working on the analysis code which has a lot of work done, but we should be good physicists (and people) by adding tests and CI/CD. The first thing we'll do is create a `.gitlab-ci.yml` file in the project.
Expand Down
3 changes: 2 additions & 1 deletion _episodes/07-adding-ci-to-your-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ keypoints:
- All defined jobs run in parallel by default
- Jobs can be allowed to fail without breaking your CI/CD
---
<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/GiwtSwtMYzg?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/F21FprczK4c?si=JC-wpc-135p7nbp6" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# Time To Skim

## The Naive Attempt
Expand Down
2 changes: 1 addition & 1 deletion _episodes/08-eins-zwei-dry.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keypoints:
- Using job templates allows you to stay DRY!
---
<center>
<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/_cKm7FUTzQs?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/Ai9Vc1e5tB0?si=8j64O61cC1UXdlIC" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
<iframe width="420" height="236" src="https://www.youtube.com/embed/dSy2DcATYUo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</center>

Expand Down
1 change: 1 addition & 0 deletions _episodes/08b-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ keypoints:
- Use Variables whenever it's convenient
---

<iframe width="560" height="315" src="https://www.youtube.com/embed/pdV1nrOvMA8?si=I2nJwEDRGt3Hga4b" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# Parallel and Matrix jobs

Expand Down
2 changes: 1 addition & 1 deletion _episodes/08c-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ hidden: false
keypoints:
- We can shorten a lot of the setup with Docker images
---

<iframe width="560" height="315" src="https://www.youtube.com/embed/mWUyoFwjxto?si=TGVrpH2BZzsS-f80" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# Say "Docker" 🐳

Expand Down
3 changes: 2 additions & 1 deletion _episodes/10-the-worlds-a-stage.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ keypoints:
- Stages allow for a mix of parallel/serial execution.
- Stages help define job dependencies.
---
<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/PBkO3TsdDUA?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/kytbf15fwyA?si=47hr5x3s9WohvQvG" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# Defining Stages

From the last session, we're starting with
Expand Down
2 changes: 1 addition & 1 deletion _episodes/11-skim-milk.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keypoints:
- Artifacts are pretty neat.
- We're too naive.
---
<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/omYX4uRxCKI?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/e2XiBHiSe-U?si=XS-XL6OMFU8LUlWG" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# The First Naive Attempt

Expand Down
1 change: 0 additions & 1 deletion _episodes/12-the-spy-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ keypoints:
- Service accounts provide an extra layer of security between the outside world and your account
- Environment variables in GitLab CI/CD allow you to hide protected information from others who can see your code
---
<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/XNhi1dw6jxI?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->



Expand Down
3 changes: 2 additions & 1 deletion _episodes/13-plotting-to-take-over-the-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ hidden: false
keypoints:
- Another script, another job, another stage, another artifact.
---
<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/BDpqN3nVVVo?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/O3xP_5lE_Hg?si=HD8ds5s5_my0DD5x" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

# On Your Own

So in order to make plots, we just need to take the skimmed file `skim_ggH.root` and pass it through the `histograms.py` code that exists. This can be run with the following code
Expand Down
4 changes: 2 additions & 2 deletions _episodes/14-a-simple-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keypoints:
- This kind of test is a regression test, as we're testing assuming the code up to this point was correct.
- This is not a unit test. Unit tests would be testing individual pieces of the `atlas/athena` or `CMSSW` code-base, or specific functionality you wrote into your algorithms.
---
<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/C9auGFgIHns?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/skHqk7pA2cY?si=_wJCZTm6DdzJm62I" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

So at this point, I'm going to be very hands-off, and just explain what you will be doing. Here's where you should be starting from:

Expand Down Expand Up @@ -73,7 +73,7 @@ plot_ggH:
> 1. Add a `test` stage after the `plot` stage.
> 2. Add a test job, `test_ggH`, part of the `test` stage, and has the right `dependencies`
> - Note: `./skim` needs to be updated to produce a `skim_ggH.log` (hint: `./skim .... > skim_ggH.log`)
> - We also need the hist_ggH.root file produced by the plot job
> - We also need the `hist_ggH.root` file produced by the plot job
> 3. Create a directory called `tests/` and make two python files in it named `test_cutflow_ggH.py` and `test_plot_ggH.py` that uses `PyROOT` and `python3`
> - you might find the following lines (below) helpful to set up the tests
> 4. Write a few different tests of your choosing that tests (and asserts) something about `hist_ggH.root`. Some ideas are:
Expand Down
2 changes: 1 addition & 1 deletion setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ If you're having issues, **please let us know immediately**
since you won't be able to follow this lesson without access to a GitLab
instance.

<!-- <iframe width="420" height="263" src="https://www.youtube.com/embed/NcVGX8zWzQY?list=PLKZ9c4ONm-VmmTObyNWpz4hB3Hgx8ZWSb" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/Pz1gtlQDVyo?si=LcG6YVteCQ38SZ12" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

## Creating a New Project

Expand Down

0 comments on commit a0ee8f1

Please sign in to comment.