How to debug a containerΒΆ

Problem: sometimes python-grader-utils will just return: "Something went wrong with the grader tests... Please contact course staff." Trying exec 2>> /feedback/err in does not help. In this case, you have to run the grading container manually and see what goes wrong.


Find out the image id of the grade-python container. The repository and tag must match the one in the config.yaml file of the exercise directory.

$ docker image ls
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
apluslms/grade-python      3.5-2.2             fa937c720836        13 days ago         188MB
apluslms/grading-base      2.2                 a3112e45cc52        13 days ago         174MB
apluslms/grading-base      latest              e4ad231b939c        2 weeks ago         174MB
bokeh                      latest              7fd091aa6822        3 weeks ago         275MB
apluslms/grade-python      3.5-2.1u1           f46d6a864f86        4 weeks ago         189MB
apluslms/grade-python      3.5                 985bf93588fe        4 weeks ago         189MB
hello-world                latest              e38bc07ac18e        6 weeks ago         1.85kB
apluslms/run-aplus-front   latest              54b9cd98d92d        3 months ago        433MB
apluslms/run-mooc-grader   latest              66a4d60254d9        4 months ago        729MB
apluslms/compile-rst       latest              0024d657c5e5        7 months ago        510MB

Go to the directory where the programming exercise is.

$ cd traky-docker/exercises/palindrome

Print the absolute path.

$ pwd

Start the grading container. Replace the X in with your absolute path of working directory (output of pwd command) and Y with the image id.

$ docker run --name grade_python_test --mount type=bind,source=X,destination=/exercise --rm -i -t Y bash

(example: $ docker run --name grade_python_test --mount type=bind,source=/u/79/atilante/unix/ohj/a-ole/traky-docker/exercises/programming/palindrome,destination=/exercise --rm -i -t fa937c720836 bash)

In another terminal:

$ docker exec -it grade_python_test bash

Now you are in a shell inside the container. The exercise files are in /exercise.

You can replicate the commands of one by one.

# cd /exercise
# cat
# cat config.yaml

File config.yaml defines what files the mooc-grader has received.

  - field: file1

In this case the submitted file would be placed in /submission/user/ However, because now you are not running mooc- grader, you have to create that file by yourself. Let's say there is already file /exercise/, which has the correct answer. In this case, copy this to /submission/user.

# mkdir /submission/user
# cp /exercise/ /submission/user

Next, replicate the actions of Let's assume you need two unit test files from /exercise : and

# cd /submission/user
# cp /exercise/{grader_tests,tests}.py .

Then execute the unit tests. Do it without capture to actually print all error messages instantly:

# python3 -m graderutils.main /exercise/test_config.yaml

If you still see the message "Something went wrong with the grader tests... Please contact course staff.", try next commenting out some parts of test_config.yaml with # characters. For example, run only one unit test module at a time.

  - module: tests
    description: Local tests
#  - module: grader_tests
#    description: Grader tests

  - type: python_import
  - type: python_syntax
  - type: python_blacklist
    message: "You are not allowed to reverse sequence"
      sequence_reverse: reverse string

You can also run individual unit tests without python-grader-utils. In the example, there is still files and

# python3
test_with_empty_string (__main__.TestIsPalindrome)
Empty strings are palindromes. (1p) ... ok
test_with_length_one_strings (__main__.TestIsPalindrome)
Strings containing one character are palindromes. (1p) ... ok
test_with_palindromes_and_non_palindromes (__main__.TestIsPalindrome)
is_palindrome returns True for a palindrome and False for a non-palindrome. (1p) ... ok

Ran 3 tests in 0.000s


# python3
Traceback (most recent call last):
  File "", line 12, in <module>
    from constants import update_settings_profile
ImportError: No module named 'constants'

Now we clearly see that executes nicely, but has an error.

You can exit from the container by simply:

# exit

In the other terminal, where you gave the docker run command, just press Ctrl+C to terminate the container.

Posting submission...