From 425a624a8b3234cdaabc6e09ac3c7784ccadeb4d Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Wed, 11 Sep 2024 11:18:28 +0200 Subject: [PATCH] Move from jupyter hub to jupyter lab, improve comments. --- travo/jupyter_course.py | 12 ++++++------ travo/nbgrader_utils.py | 6 +++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/travo/jupyter_course.py b/travo/jupyter_course.py index 1690417..91f2e1f 100644 --- a/travo/jupyter_course.py +++ b/travo/jupyter_course.py @@ -75,7 +75,7 @@ quality_report = """ jupyterhub_host = "https://jupyterhub.ijclab.in2p3.fr" -def jupyter_notebook_in_hub( +def jupyter_lab_in_hub( path: str, debug: bool = False, background: bool = False ) -> Optional[str]: """ @@ -106,12 +106,12 @@ def jupyter_notebook_in_hub( command = [ "jupyter", - "notebook", + "lab", "--no-browser", - f"--NotebookApp.base_url={prefix}proxy/absolute/{port}/", + f"--LabApp.base_url={prefix}proxy/absolute/{port}/", f"--port={port}", f"--log-level={log_level}", - "--NotebookApp.allow_remote_access=True", + "--LabApp.allow_remote_access=True", ] if background: subprocess.Popen(command) @@ -128,7 +128,7 @@ def jupyter_notebook(path: str) -> None: This works both in the command line or within a JupyterHub """ if "JUPYTERHUB_SERVICE_PREFIX" in os.environ: - jupyter_notebook_in_hub(path) + jupyter_lab_in_hub(path) else: subprocess.run( [ @@ -897,7 +897,7 @@ class JupyterCourse(Course): if "JUPYTERHUB_SERVICE_PREFIX" in os.environ: print("Launching formgrader in the background") - jurl = jupyter_notebook_in_hub(path=url, background=True) + jurl = jupyter_lab_in_hub(path=url, background=True) assert ( jurl is not None ) # TODO check if jurl can be None and what it means diff --git a/travo/nbgrader_utils.py b/travo/nbgrader_utils.py index cfc80ab..8a07258 100644 --- a/travo/nbgrader_utils.py +++ b/travo/nbgrader_utils.py @@ -67,7 +67,11 @@ def merge_submission_gradebook( args, kwargs = to_args(submission, ["student"]) del kwargs["first_name"] del kwargs["last_name"] - target.update_or_create_submission(assignment.name, *args, **kwargs) + # Don't pass in kwargs, because only the student name is + # relevant to be able to create a submission, while + # updating an attribute like the id in the database may + # wreak havoc + target.update_or_create_submission(assignment.name, *args) # , **kwargs) for notebook in submission.notebooks: for grade in notebook.grades: -- GitLab