Skip to content
Snippets Groups Projects
Commit 47e12ba8 authored by tuhe's avatar tuhe
Browse files

updated docker images

parent c5c1a78e
No related branches found
No related tags found
No related merge requests found
Showing
with 598 additions and 152 deletions
...@@ -2,6 +2,7 @@ numpy ...@@ -2,6 +2,7 @@ numpy
tqdm tqdm
jinja2 jinja2
tabulate tabulate
compress_pickle
pyfiglet pyfiglet
colorama colorama
importnb
unitgrade # Perhaps just this and not the other.
No preview for this file type
...@@ -5,6 +5,7 @@ from cs103.report3_complete import Report3 ...@@ -5,6 +5,7 @@ from cs103.report3_complete import Report3
from unitgrade_private.hidden_create_files import setup_grade_file_report from unitgrade_private.hidden_create_files import setup_grade_file_report
from unitgrade_private.deployment import remove_hidden_methods from unitgrade_private.deployment import remove_hidden_methods
from unitgrade_private.docker_helpers import docker_run_token_file from unitgrade_private.docker_helpers import docker_run_token_file
from unitgrade_private.docker_helpers import download_docker_images, compile_docker_image
from snipper.snip_dir import snip_dir from snipper.snip_dir import snip_dir
if __name__ == "__main__": #!s=docker_a if __name__ == "__main__": #!s=docker_a
...@@ -22,14 +23,16 @@ if __name__ == "__main__": #!s=docker_a ...@@ -22,14 +23,16 @@ if __name__ == "__main__": #!s=docker_a
student_token_file = glob.glob(student_directory + "/*.token").pop() #!s student_token_file = glob.glob(student_directory + "/*.token").pop() #!s
# Step 3: Compile the Docker image (obviously you should only do this once). #!s=docker_c # Step 3: Compile the Docker image (obviously you should only do this once). #!s=docker_c
Dockerfile = os.path.dirname(__file__) + "/../../../../docker_images/unitgrade-docker/Dockerfile" download_docker_images(destination="../docker") # Download an up-to-date docker image from gitlab.
os.system(f"cd {os.path.dirname(Dockerfile)} && docker build --tag unitgrade-docker .") #!s Dockerfile = "../docker/unitgrade-docker/Dockerfile" # Location of just downloaded docker file
compile_docker_image(Dockerfile, tag="unitgrade-docker") #!s
# Step 4: Test the students code in the .token file and get the results-token-file: #!s=docker_d # Step 4: Test the students code in the .token file and get the results-token-file: #!s=docker_d
token = docker_run_token_file(Dockerfile_location=Dockerfile, token = docker_run_token_file(Dockerfile_location=Dockerfile,
host_tmp_dir=os.path.dirname(Dockerfile) + "/home", host_tmp_dir=os.path.dirname(Dockerfile) + "/home",
student_token_file=student_token_file, student_token_file=student_token_file,
instructor_grade_script="report3_complete_grade.py") #!s instructor_grade_script="report3_complete_grade.py",
tag="unitgrade-docker") #!s
# Load the two token files and compare their scores #!s=docker_e # Load the two token files and compare their scores #!s=docker_e
checked_token, _ = load_token(token) checked_token, _ = load_token(token)
......
# syntax=docker/dockerfile:1
FROM python:3.8-slim-buster
MAINTAINER Autolab Team <autolab-dev@andrew.cmu.edu>
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
git \
make \
sudo \
python \
procps \
&& rm -rf /var/lib/apt/lists/*
# Install autodriver
WORKDIR /home
RUN useradd autolab
RUN useradd autograde
RUN mkdir autolab autograde output
RUN chown autolab:autolab autolab
RUN chown autolab:autolab output
RUN chown autograde:autograde autograde
RUN git clone --depth 1 https://github.com/autolab/Tango.git
WORKDIR Tango/autodriver
RUN make clean && make
RUN cp autodriver /usr/bin/autodriver
RUN chmod +s /usr/bin/autodriver
# Do the python stuff.
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
# Clean up
WORKDIR /home
RUN apt-get remove -y git && apt-get -y autoremove && rm -rf Tango/
# Check installation
RUN ls -l /home
RUN which autodriver
numpy
tqdm
jinja2
tabulate
pyfiglet
colorama
unitgrade-devel>=0.1.26 # Required to run automatic evaluation (load tokens etc.)
\ No newline at end of file
# syntax=docker/dockerfile:1
FROM python:3.8-slim-buster
RUN apt-get -y update
RUN apt-get -y install git
WORKDIR /home
# Remember to include requirements.
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
# Not required.
# RUN pip install git+https://git@gitlab.compute.dtu.dk/tuhe/unitgrade.git
COPY . .
ADD . /home
# CMD [ "python3", "app.py"]
def reverse_list(mylist):
"""
Given a list 'mylist' returns a list consisting of the same elements in reverse order. E.g.
reverse_list([1,2,3]) should return [3,2,1] (as a list).
"""
# TODO: 1 lines missing.
raise NotImplementedError("Implement function body")
def add(a,b):
""" Given two numbers `a` and `b` this function should simply return their sum:
> add(a,b) = a+b """
# TODO: 1 lines missing.
raise NotImplementedError("Implement function body")
if __name__ == "__main__":
# Example usage:
print(f"Your result of 2 + 2 = {add(2,2)}")
print(f"Reversing a small list", reverse_list([2,3,5,7]))
from unitgrade import UTestCase, Report
from unitgrade.utils import hide
from unitgrade import evaluate_report_student
import cs103
class AutomaticPass(UTestCase):
def test_automatic_pass(self):
self.assertEqual(2, 2) # For simplicity, this test will always pass
class Report3(Report):
title = "CS 101 Report 3"
questions = [(AutomaticPass, 10)] # Include a single question for 10 credits.
pack_imports = [cs103]
if __name__ == "__main__":
evaluate_report_student(Report3())
numpy
tqdm
jinja2
tabulate
compress_pickle
pyfiglet
importnb
colorama
unitgrade
\ No newline at end of file
No preview for this file type
...@@ -101,7 +101,7 @@ def student_token_file_runner(host_tmp_dir, student_token_file, instructor_grade ...@@ -101,7 +101,7 @@ def student_token_file_runner(host_tmp_dir, student_token_file, instructor_grade
return pycom, token_location return pycom, token_location
def docker_run_token_file(Dockerfile_location, host_tmp_dir, student_token_file, tag=None, instructor_grade_script=None, fix_user=True): def docker_run_token_file(Dockerfile_location, host_tmp_dir, student_token_file, tag=None, instructor_grade_script=None, fix_user=None):
""" """
This thingy works: This thingy works:
...@@ -114,9 +114,14 @@ def docker_run_token_file(Dockerfile_location, host_tmp_dir, student_token_file, ...@@ -114,9 +114,14 @@ def docker_run_token_file(Dockerfile_location, host_tmp_dir, student_token_file,
""" """
# A bunch of tests. This is going to be great! # A bunch of tests. This is going to be great!
Dockerfile_location = os.path.abspath(Dockerfile_location)
assert os.path.exists(Dockerfile_location) assert os.path.exists(Dockerfile_location)
start = time.time() start = time.time()
if fix_user is None:
fix_user = os.name != 'nt' # On Linux, this should probably be true to avoid problem with edit-rights of docker-created files.
# with open(student_token_file, 'rb') as f: # with open(student_token_file, 'rb') as f:
# results = pickle.load(f) # results = pickle.load(f)
from unitgrade_private import load_token from unitgrade_private import load_token
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment