TU-Wien-dataLAB / Grader-Labextension

BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Cannot release assignment with version `0.3.0` #22

Closed ZelphirKaltstahl closed 6 months ago

ZelphirKaltstahl commented 6 months ago

Description

Using the released grader labextension 0.3.0, an instructor cannot release an assignment. There might be more factors contributing to this bug, as we have a different setup, that uses DockerSpawner instead of the local system process spawner in our JupyterHub setup, but bear with me:

The error happens when setting the commit message when releasing and clicking "COMMIT AND RELEASE":

image

The logs of the corresponding user docker container show the following error:

[E 2024-01-26 15:06:36.749 SingleUserLabApp web:1871] Uncaught exception PUT /user/e8dd08a7-09b1-441d-b9fd-f3c8fe0c0c4b/grader_labextension/lectures/1/assignments/1/push/release (::ffff:172.19.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8004', method='PUT', uri='/user/e8dd08a7-09b1-441d-b9fd-f3c8fe0c0c4b/grader_labextension/lectures/1/assignments/1/push/release', version='HTTP/1.1', remote_ip='::ffff:172.19.0.1')
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.11/site-packages/tornado/web.py", line 1786, in _execute
        result = await result
                 ^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/grader_labextension/handlers/version_control.py", line 423, in put
        git_service.set_author(author=self.user_name)
                                      ^^^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/grader_labextension/handlers/base_handler.py", line 90, in user_name
        return self.current_user['name']
               ~~~~~~~~~~~~~~~~~^^^^^^^^
    TypeError: 'User' object is not subscriptable
[W 2024-01-26 15:06:36.751 SingleUserLabApp base_handler:133] wrote error: 'Unhandled error'    Traceback (most recent call last):
      File "/opt/conda/lib/python3.11/site-packages/tornado/web.py", line 1786, in _execute
        result = await result
                 ^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/grader_labextension/handlers/version_control.py", line 423, in put
        git_service.set_author(author=self.user_name)
                                      ^^^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/grader_labextension/handlers/base_handler.py", line 90, in user_name
        return self.current_user['name']
               ~~~~~~~~~~~~~~~~~^^^^^^^^
    TypeError: 'User' object is not subscriptable
[E 2024-01-26 15:06:36.752 SingleUserLabApp log:183] {
      "X-Forwarded-Host": "localhost:8004",
      "X-Forwarded-Proto": "http",
      "X-Forwarded-Port": "8004",
      "X-Forwarded-For": "::ffff:172.19.0.1",
      "Content-Length": "0",
      "Sec-Fetch-Site": "same-origin",
      "Sec-Fetch-Mode": "cors",
      "Sec-Fetch-Dest": "empty",
      "Cookie": "jupyterhub-user-e8dd08a7-09b1-441d-b9fd-f3c8fe0c0c4b=[secret]; _xsrf=[secret]; jupyterhub-session-id=[secret]",
      "Connection": "close",
      "Dnt": "1",
      "Origin": "http://localhost:8004",
      "Content-Type": "application/json",
      "X-Xsrftoken": "2|f4077f98|93d8348c78bf82bc491461a7d44309c5|1706274560",
      "Authorization": "token [secret]",
      "Referer": "http://localhost:8004/user/e8dd08a7-09b1-441d-b9fd-f3c8fe0c0c4b/lab",
      "Accept-Encoding": "gzip, deflate, br",
      "Accept-Language": "en-US,en;q=0.5",
      "Accept": "*/*",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0",
      "Host": "localhost:8004"
    }

A clear and concise description of what the bug is.

How to reproduce

I might be able to share the complete setup with dockerfiles and so on later, but that is not a certainty. But I will try to describe how to reproduce this.

  1. Open a launcher in JupyterLab.
  2. Click the "Course Management" button: image
  3. Click on the predefined lecture lect1: image
  4. Click the "+ NEW" assignment button at the top right.
  5. Create an arbitrarily named assignment. The assignment details are not important.
  6. Click on the newly created assignment.
  7. Click on the "RELEASE" button: image
  8. Click "AGREE".
  9. Enter an arbitrary commit message.
  10. Click "COMMIT AND RELEASE".
  11. See the error at the bottom left: image

Expected behavior

The assignment should be successfully released.

Screenshots

(see above)

Desktop

  1. Ubuntu 22.04.3 LTS
    • OS: GNU/Linux, but actually all dockerized containers
    • Browser: Firefox
    • Version: 115.7.0esr (64-bit)
  2. MacOS Apple M1 Pro, MacOS 14.2.1
    • Browser: Chrome
    • Version: Version 109.0.5414.87 (Official Build) (arm64)

Additional context

We have separated out the spawned JupyterLab instances from the JupyterHub container into separate user containers using the DockerSpawner. This means, that the setup is significantly different. However, we already found the apparent fix for the problem. Will post in this issue.

ZelphirKaltstahl commented 6 months ago

Solution

While searching in old issues in the grader-service for "release", we found an old issue: https://github.com/TU-Wien-dataLAB/Grader-Service/issues/93. In this issue there is a fix for apparently the same error or at least very similar error: https://github.com/TU-Wien-dataLAB/Grader-Service/commit/944d312fa6bf9527f6b9aeca122e700cb4c4db09#diff-2d8ae30c5ae615a4861bdadd5c45be1e79750c5a31f3effe721f57e0e7f7e4b6

At first we thought that we had a different issue, because the fix was merged already 6 months ago. However, we still saw the old way of accessing the self.current_user, instead of using self.current_user.name, our code seemed to use self.current_user['name'] still. This made us question, whether we had the commit of that fix in our version of the grader labextension. So we checked the code that gets installed with:

RUN pip install --no-cache-dir \
    nbclassic==0.3.7 \
    grader-convert==0.2.3 \
    grader-service==0.3.0 \
    grader-labextension==0.3.0

in our Dockerfile. Trying to install the extension in editable (pip install -e) mode was too cumbersome, because of the dependency to npm or yarn. So instead we checked the code installed in the Python environment's .../lib/python3.11/site-packages/grader_labextension/handlers/base_handler.py.

Indeed, it was still using the old way of accessing the name attribute.

So we edited that code to also use self.current_user.name instead of self.current_user['name'].

Then we restarted the docker container, so that the Python process reads these files anew, when the labextension becomes active.

And then things seem to work =)

image

So it seems, that while splitting out the labextension recently this fix of https://github.com/TU-Wien-dataLAB/Grader-Service/commit/944d312fa6bf9527f6b9aeca122e700cb4c4db09#diff-2d8ae30c5ae615a4861bdadd5c45be1e79750c5a31f3effe721f57e0e7f7e4b6 was not taken with the labextension to the new labextension repository.

ZelphirKaltstahl commented 6 months ago

Solved, merge request merged.