Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced submission evaluation (docker) #149

Merged
merged 88 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
cfb17b3
add simple submission volume mount test script
axellorreyne May 5, 2024
c725904
add evaluation functionality to submission model
axellorreyne May 5, 2024
5e9d10c
add makefile shortcut for submission volume test
axellorreyne May 5, 2024
30beaa8
fix submission id pass to container
axellorreyne May 5, 2024
511b304
add migrations
axellorreyne May 5, 2024
9dd5d2c
fix lint
axellorreyne May 5, 2024
6b9b4c4
remove evaluation container on completion
axellorreyne May 5, 2024
bde5301
print docker api error
axellorreyne May 5, 2024
97795c5
remove container upon fail
axellorreyne May 5, 2024
b4cdbe6
production submission path env variable
robinpdev May 6, 2024
be26062
add submission bind to development (DONT FORGET ENV VAR)
robinpdev May 6, 2024
49a9bee
use submission id path volume
axellorreyne May 13, 2024
a8c2412
use custom dockerfile as evaluation image
axellorreyne May 13, 2024
bec848e
write eval output to variable + fix eval status
axellorreyne May 13, 2024
c0cfec4
fix migrations and makefile
robinpdev May 19, 2024
f807bb2
Merge branch 'develop' into 148-advanced-tests
robinpdev May 19, 2024
ab953f4
fix error messages on submit page
robinpdev May 19, 2024
e35446c
use test_files as entrypoint field
axellorreyne May 19, 2024
701be17
Merge remote-tracking branch 'origin/148-advanced-tests' into 148-adv…
axellorreyne May 19, 2024
1d756b5
fix remove test_files for refactor
axellorreyne May 19, 2024
6231db0
add migrations
axellorreyne May 19, 2024
dcf8d05
uploading dockerfile in ui
robinpdev May 19, 2024
cc42b7e
Merge branch '148-advanced-tests' of github.com:SELab-2/UGent-1 into …
robinpdev May 19, 2024
3781698
registry experiment
robinpdev May 20, 2024
fdf753f
test for traefik config
robinpdev May 20, 2024
06e55d8
correction to port?
robinpdev May 20, 2024
90c9b76
fix duplicate port?
robinpdev May 20, 2024
f83d1cb
host wrong?
robinpdev May 20, 2024
6294472
add address and change position
robinpdev May 20, 2024
2295026
wrong port lmao
robinpdev May 20, 2024
1ad49bf
hosting behind slash prefix
robinpdev May 20, 2024
3b8c5ac
container name
robinpdev May 20, 2024
e3ba7dd
try 2002 last time
robinpdev May 20, 2024
a28e301
comon
robinpdev May 20, 2024
c532b24
is it joever?
robinpdev May 20, 2024
7c3a5cd
huh?
robinpdev May 20, 2024
c3168a0
address fix
robinpdev May 20, 2024
a72cd63
i forgor
robinpdev May 20, 2024
097d708
example advanced test
robinpdev May 20, 2024
02aacef
add docker cli to backend
robinpdev May 20, 2024
6e7089e
registry login in backend entrypoint
robinpdev May 20, 2024
189b548
UI and database changes for registry model
robinpdev May 20, 2024
37e961a
Merge branch 'develop' into 148-advanced-tests
PJDeSmijter May 21, 2024
55f4666
fix lint
axellorreyne May 22, 2024
d0fb8f8
fix lint
axellorreyne May 22, 2024
de2e3b2
fix mount path
axellorreyne May 22, 2024
02a3fd2
Merge branch 'develop' into 148-advanced-tests
robinpdev May 22, 2024
24c8eec
clean up project edit old stuff
robinpdev May 22, 2024
9251271
add switch for forwarded host to env to get debug messages on production
robinpdev May 22, 2024
91375d3
fix bug in docker-py by changing affected requests package
robinpdev May 22, 2024
9e2334b
fix eval method in model
robinpdev May 22, 2024
60d6149
change example to reflect volumes on backend
robinpdev May 22, 2024
4f0faaa
fix distinction between hostside and dockerside paths
robinpdev May 22, 2024
45681d1
lint
axellorreyne May 22, 2024
797aff9
fix production submissions volume bind
robinpdev May 22, 2024
01c727e
typo smh
robinpdev May 22, 2024
1dab329
fix production docker cli install
robinpdev May 22, 2024
298cf03
remove container again
robinpdev May 22, 2024
af8dd23
Merge branch 'develop' into 148-advanced-tests
robinpdev May 22, 2024
246a2fc
Merge branch 'refs/heads/develop' into 148-advanced-tests
axellorreyne May 22, 2024
c2830e0
Merge branch '148-advanced-tests' of github.com:SELab-2/UGent-1 into …
robinpdev May 22, 2024
28d80c9
fix admin panel and saving for evaluation
robinpdev May 22, 2024
4856879
Merge branch 'develop' into 148-advanced-tests
robinpdev May 22, 2024
228b980
lint fix
robinpdev May 22, 2024
1ee2647
Merge branch 'develop' into 148-advanced-tests
robinpdev May 22, 2024
155a065
add local registry for development
robinpdev May 22, 2024
84e631d
add push registry command to makefile
axellorreyne May 22, 2024
9d18c8b
Fix admin submission tests for advanced evaluation
axellorreyne May 22, 2024
985df71
add registry entry for image that always succeeds
axellorreyne May 22, 2024
9a19dd2
fix always succeed image
axellorreyne May 22, 2024
e98c318
fix + clean teacher, amdin and unauth tests
axellorreyne May 22, 2024
791c345
fix + clean student submission view tests
axellorreyne May 22, 2024
0705be6
add fibonacci evaluation example + solution
axellorreyne May 23, 2024
6ff69f0
add submit test script
axellorreyne May 23, 2024
b27c366
fix evaluation result saving on succeed and fail
axellorreyne May 23, 2024
1e04b9c
Merge branch 'refs/heads/develop' into 148-advanced-tests
axellorreyne May 23, 2024
6570721
add artifacts + update example
axellorreyne May 23, 2024
50180c8
add artifacts download view
axellorreyne May 23, 2024
5293c04
fix submission test view
axellorreyne May 23, 2024
d13851d
add production registry push command in makefile
robinpdev May 23, 2024
d4d7653
try to fix production testing env vars
robinpdev May 23, 2024
7ee0059
Merge branch 'develop' into 148-advanced-tests
robinpdev May 23, 2024
8681700
merge migrations
robinpdev May 23, 2024
0d958db
default values for env vars to get github actions working
robinpdev May 23, 2024
643cc88
fix some stuff in submission detail but still broken
robinpdev May 23, 2024
182bfa7
fix advanced testing logic and submission details GUI
robinpdev May 23, 2024
f1b3a9d
more info on failed tests and listview result fix
robinpdev May 23, 2024
51fb8e0
gyatt damn lint fix
robinpdev May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
pip install -r ./backend/requirements.txt
- name: Running Django tests
run: |
source /home/selab2/hosting/.env.test
sh ./backend/runtests.sh

frontend-test:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ENV PYTHONUNBUFFERED 1

# install psycopg2 dependencies
RUN apk update \
&& apk add postgresql-dev gcc python3-dev musl-dev
&& apk add postgresql-dev gcc python3-dev musl-dev docker-cli

# install dependencies
RUN pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN mkdir $APP_HOME/uploads
WORKDIR $APP_HOME

# install dependencies
RUN apk update && apk add libpq
RUN apk update && apk add libpq docker-cli
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --no-cache /wheels/*
Expand Down
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ superuser:
mockdata:
docker exec -it pigeonhole-backend python manage.py runscript mockdata

registry:
docker build examples/advanced-evaluation/always-succeed -t test-always-succeed
docker tag test-always-succeed localhost:5000/test-always-succeed
docker push localhost:5000/test-always-succeed
docker build examples/advanced-evaluation/helloworld -t test-helloworld
docker tag test-helloworld localhost:5000/test-helloworld
docker push localhost:5000/test-helloworld
docker build examples/advanced-evaluation/fibonacci-python -t fibonacci-python
docker tag fibonacci-python localhost:5000/fibonacci-python
docker push localhost:5000/fibonacci-python

evaltest:
docker exec -it pigeonhole-backend python manage.py runscript eval_test

submit:
docker exec -it pigeonhole-backend python manage.py runscript submit

reset:
docker image prune -af
docker system prune
Expand All @@ -39,3 +56,14 @@ silentcomponenttest:
resetdb:
docker exec pigeonhole-backend python manage.py flush --noinput
docker exec -it pigeonhole-backend python manage.py runscript mockdata

prodregistry:
docker build examples/advanced-evaluation/always-succeed -t test-always-succeed
docker tag test-always-succeed sel2-1.ugent.be:2002/test-always-succeed
docker push sel2-1.ugent.be:2002/test-always-succeed
docker build examples/advanced-evaluation/helloworld -t test-helloworld
docker tag test-helloworld sel2-1.ugent.be:2002/test-helloworld
docker push sel2-1.ugent.be:2002/test-helloworld
docker build examples/advanced-evaluation/fibonacci-python -t fibonacci-python
docker tag fibonacci-python sel2-1.ugent.be:2002/fibonacci-python
docker push sel2-1.ugent.be:2002/fibonacci-python
1 change: 1 addition & 0 deletions backend/entrypoint.prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ python manage.py runscript push_site

python manage.py collectstatic --noinput

docker login $REGISTRY_URL -u $REGISTRY_USER -p $REGISTRY_PASSWORD

exec "$@"
2 changes: 2 additions & 0 deletions backend/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ python manage.py runscript push_site

python manage.py createsuperuser --noinput --email $DJANGO_SUPERUSER_EMAIL

docker login $REGISTRY_URL -u $REGISTRY_USER -p $REGISTRY_PASSWORD

exec "$@"
8 changes: 8 additions & 0 deletions backend/pigeonhole/apps/projects/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ class ProjectAdmin(admin.ModelAdmin):
)
}
),
(
'test docker image',
{
'fields': (
'test_docker_image',
)
}
),
)

raw_id_fields = (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.13 on 2024-05-19 11:35

import backend.pigeonhole.apps.projects.models
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('projects', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='project',
name='test_dockerfile',
field=models.FileField(blank=True, null=True,
upload_to=backend.pigeonhole.apps.projects.models.get_upload_to),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.13 on 2024-05-19 16:38

import backend.pigeonhole.apps.projects.models
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('projects', '0002_project_test_dockerfile'),
]

operations = [
migrations.AlterField(
model_name='project',
name='test_dockerfile',
field=models.FileField(blank=True, null=True,
upload_to=backend.pigeonhole.apps.projects.models.dockerfile_path),
),
migrations.AlterField(
model_name='project',
name='test_files',
field=models.FileField(blank=True, null=True,
upload_to=backend.pigeonhole.apps.projects.models.testfile_path),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.11 on 2024-05-19 14:55

import backend.pigeonhole.apps.projects.models
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('projects', '0002_project_test_dockerfile'),
]

operations = [
migrations.AddField(
model_name='project',
name='test_entrypoint',
field=models.FileField(blank=True, null=True,
upload_to=backend.pigeonhole.apps.projects.models.get_upload_to),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.2.13 on 2024-05-19 16:40

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('projects', '0003_alter_project_test_dockerfile_and_more'),
('projects', '0003_project_test_entrypoint'),
]

operations = [
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 4.2.13 on 2024-05-20 18:31

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('projects', '0004_merge_20240519_1640'),
]

operations = [
migrations.RemoveField(
model_name='project',
name='test_dockerfile',
),
migrations.RemoveField(
model_name='project',
name='test_entrypoint',
),
migrations.RemoveField(
model_name='project',
name='test_files',
),
migrations.AddField(
model_name='project',
name='test_docker_image',
field=models.CharField(blank=True, max_length=1024, null=True),
),
]
22 changes: 20 additions & 2 deletions backend/pigeonhole/apps/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
from backend.pigeonhole.apps.courses.models import Course


def dockerfile_path(self, _):
if not self.pk:
nextpk = Project.objects.order_by('-project_id').first().project_id + 1
self.id = self.pk = nextpk
return f'courses/id_{str(self.course_id.course_id)}/project/id_{str(self.project_id)}/DOCKERFILE'


def testfile_path(self, filename):
if not self.pk:
nextpk = Project.objects.order_by('-project_id').first().project_id + 1
self.id = self.pk = nextpk
return f'courses/id_{str(self.course_id.course_id)}/project/id_{str(self.project_id)}/{filename}'


# legacy code
def get_upload_to(self, filename):
return 'projects/' + str(self.project_id) + '/' + filename

Expand All @@ -21,14 +36,17 @@ class Project(models.Model):
group_size = models.IntegerField(default=1)
file_structure = models.TextField(blank=True, null=True)
conditions = models.TextField(blank=True, null=True)
test_files = models.FileField(blank=True, null=True, upload_to=get_upload_to)

# test_files = models.FileField(blank=True, null=True, upload_to=testfile_path)
# test_dockerfile = models.FileField(blank=True, null=True, upload_to=dockerfile_path)
test_docker_image = models.CharField(max_length=1024, blank=True, null=True)


class ProjectSerializer(serializers.ModelSerializer):
class Meta:
model = Project
fields = ["project_id", "course_id", "name", "description", "deadline", "visible", "number_of_groups",
"group_size", "max_score", "file_structure", "conditions", "test_files"]
"group_size", "max_score", "file_structure", "conditions", "test_docker_image"]


class Test(models.Model):
Expand Down
18 changes: 17 additions & 1 deletion backend/pigeonhole/apps/submissions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,23 @@ class SubmissionAdmin(admin.ModelAdmin):
}
),
(
'Files',
'eval output',
{
'fields': (
'eval_output',
)
}
),
(
'eval result',
{
'fields': (
'eval_result',
)
}
),
(
'file urls',
{
'fields': (
'file_urls',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.11 on 2024-05-05 02:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('submissions', '0004_remove_submissions_file_and_more'),
]

operations = [
migrations.AddField(
model_name='submissions',
name='eval_result',
field=models.BooleanField(default=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.13 on 2024-05-19 11:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('submissions', '0005_submissions_eval_result'),
]

operations = [
migrations.AddField(
model_name='submissions',
name='eval_output',
field=models.TextField(null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.11 on 2024-05-23 02:32

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('submissions', '0006_submissions_eval_output'),
]

operations = [
migrations.AlterField(
model_name='submissions',
name='eval_result',
field=models.BooleanField(default=None, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.2.13 on 2024-05-23 08:23

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('submissions', '0005_submissions_feedback_simple_test_and_more'),
('submissions', '0007_alter_submissions_eval_result'),
]

operations = [
]
Loading
Loading