Skip to content

Commit 0b56237

Browse files
committed
Merge branch 'main' of github.com:SFI-Visual-Intelligence/Collaborative-Coding-Exam into johan/devbranch
2 parents 8d0c07a + 3da72bd commit 0b56237

File tree

10 files changed

+97
-79
lines changed

10 files changed

+97
-79
lines changed

.github/workflows/build-image.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Create and publish a Docker image
2+
3+
# Configures this workflow to run every time a change is pushed to the branch called `main`.
4+
on:
5+
push:
6+
paths:
7+
- "pyproject.toml"
8+
- "Dockerfile"
9+
pull_request:
10+
paths:
11+
- "pyproject.toml"
12+
- "Dockerfile"
13+
14+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
15+
env:
16+
REGISTRY: ghcr.io
17+
IMAGE_NAME: ${{ github.repository }}
18+
19+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
20+
jobs:
21+
build-and-push-image:
22+
runs-on: ubuntu-latest
23+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
24+
permissions:
25+
contents: read
26+
packages: write
27+
attestations: write
28+
id-token: write
29+
#
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
34+
- name: Log in to the Container registry
35+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
36+
with:
37+
registry: ${{ env.REGISTRY }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
41+
- name: Extract metadata (tags, labels) for Docker
42+
id: meta
43+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
tags: |
47+
type=ref,event=branch
48+
type=sha
49+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
50+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
51+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
52+
- name: Build and push Docker image
53+
id: push
54+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
55+
with:
56+
context: .
57+
push: true
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
61+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
62+
- name: Generate artifact attestation
63+
uses: actions/attest-build-provenance@v2
64+
with:
65+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
66+
subject-digest: ${{ steps.push.outputs.digest }}
67+
push-to-registry: true
68+
69+

.github/workflows/format.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
push:
55
paths:
66
- 'CollaborativeCoding/**'
7+
- 'tests/**'
78
pull_request:
89
paths:
910
- 'CollaborativeCoding/**'
11+
- 'tests/**'
1012

1113
jobs:
1214
format:

.github/workflows/test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ name: Test
22

33
on:
44
push:
5-
branches: [ main ]
5+
paths:
6+
- 'CollaborativeCoding/**'
7+
- 'tests/**'
68
pull_request:
7-
branches: [ main ]
9+
paths:
10+
- 'CollaborativeCoding/**'
11+
- 'tests/**'
812

913
jobs:
1014
test:

CollaborativeCoding/metrics/precision.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ def __reset__(self):
124124
None
125125
Returns None
126126
"""
127-
self.y_true = self.y_pred = []
127+
self.y_true = []
128+
self.y_pred = []
128129
return None
129130

130131

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM --platform=linux/amd64 ghcr.io/astral-sh/uv:debian
2+
3+
# Set a temporary working directory (will be switched in the kubectl job anyways...)
4+
WORKDIR /temp
5+
6+
# Copy the pyproject file to the working directory to ensure exact versions
7+
COPY pyproject.toml .
8+
9+
# Make a empty venv
10+
RUN uv venv
11+
12+
# Install all dependencies from the pyproject file
13+
RUN uv add pyproject.toml
14+
15+
# Set the path to the venv
16+
ENV PATH="/temp/.venv/bin:${PATH}"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![test-badge](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/test.yml/badge.svg) ![format](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/format.yml/badge.svg) ![sphinx](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/sphinx.yml/badge.svg)
1+
![test-badge](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/test.yml/badge.svg) ![format](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/format.yml/badge.svg) ![sphinx](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/sphinx.yml/badge.svg) ![build-image](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/build-image.yml/badge.svg)
22

33
# Collaborative-Coding-Exam
44
Repository for final evaluation in the FYS-8805 Reproducible Research and Collaborative coding course

docker/Dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

docker/createdocker.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

docker/requirements.txt

Lines changed: 0 additions & 61 deletions
This file was deleted.

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def main():
145145
for x, y in tqdm(trainloader, desc="Training"):
146146
x, y = x.to(device), y.to(device)
147147
logits = model.forward(x)
148-
loss = criterion(logits, y)
148+
loss = criterion(logits, y)
149149
loss.backward()
150150

151151
optimizer.step()

0 commit comments

Comments
 (0)