By email to jack.hale@uni.lu, Subject: Computational Research Workflows Homework.
Please ask questions on the Etherpad.
Deadline: Monday 19th December 2022 1800
You must have attended the course and complete the homework to receive the ECTS credits.
The email should contain a link to a GitHub repository with:
-
a modified version of this file
README.md
file containing the specific commands that you used to complete the exercises. You do not have to include everything, just the key commands. I have left placeholders where these commands should go:# Add your commands here
-
A
wallet.py
file that passes the unit tests. -
A
Dockerfile
. -
A working GitHub Actions file
.github/workflows/test.yml
that runs the unit tests inside the built image.
At the end of this homework, you will have a computational workflow consisting of:
-
A git repository hosted at https://github.com.
-
A
Dockerfile
describing an environment containingpython
and the Python modulepytest
. -
A Docker image built from the
Dockerfile
and uploaded to the Dockerhub. -
A simple Python program describing a simple Wallet class and a set of unit tests.
-
A continuous integration setup using GitHub Actions.
For reference, you can use my notes that I used during the course here and the references listed at the bottom of the main course page.
-
Go to GitHub. Click on the plus icon in the top right hand corner of the screen. Then click on New Repository.
-
Create a public repository called e.g.
jhale/computational-workflows-homework
. -
Clone your repository. In a terminal run, e.g.:
git clone git@github.com:jhale/computational-workflows-homework.git
substituting with the correct location of your repository.
-
Copy this
README.md
text file to your new repository.git add
,git commit
andgit push
it to your repository.
- Create a file
Dockerfile
in the repository containing the following text.
FROM ubuntu:21.04
RUN apt-get -y update && \
apt-get install -y python3-minimal python3-ipython python3-pytest python3-numpy && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
git add
andgit push
the fileDockerfile
to the repository.
$ git add Dockerfile
$ git commit -m "init"
$ git push
docker build
,docker login
anddocker push
the image described by theDockerfile
to the Dockerhub. Tag your Docker image<yourdockerhubusername>/computational-workflows
.
$ docker build .
$ docker login
$ docker tag 3010a4c7ce13 wang422003/computational-workflows
$ docker image push wang422003/computational-workflows
docker run
the image. Use the-v
flag to share the root of the git repository to/root/shared
inside the container. Use the-ti
flag to get an interactive prompt inside the running container.
$ docker run -ti -v "$(pwd):/shared" wang422003/computational-workflows
- In a terminal running on the host (outside the container), copy across the
files
wallet.py
andtest_wallet.py
to the root of your homework repository.git add
,git commit
andgit push
them.
$ cp ~/Documents/computational-workflows-homework-master/*.py ~/Documents/computational-workflows-homework/
$ git add --all
$ git commit -m "add .py files"
$ git push
- Start a Docker container using your image and share your repository into a
directory
/root/shared
into the container.
$ docker run -ti -v "$(pwd):/shared" wang422003/computational-workflows
-
Run the tests inside the container by going to
/root/shared
and running the commandpy.test-3
. The tests should fail. -
In a terminal on the host modify
wallet.py
until the tests intest_wallet.py
all pass. -
git add
,git commit
andgit push
the workingwallet.py
file.
-
Using the example in the class notes make a
.github/workflows/test.yml
file that checks out your repository and runs the unit tests inside the Docker image that you pushed to the DockerHub. -
Push the
.github/workflows/test.yml
file to GitHub. Check that you get the green tick showing that your tests pass.