Skip to content

Commit 93ff101

Browse files
committed
fix #6701 -- cleanup nbgrader temp files
1 parent 04ff852 commit 93ff101

File tree

1 file changed

+58
-44
lines changed
  • src/packages/frontend/course/assignments

1 file changed

+58
-44
lines changed

src/packages/frontend/course/assignments/actions.ts

Lines changed: 58 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,59 +1979,73 @@ ${details}
19791979
this.course_actions.clear_activity(id);
19801980
}
19811981

1982-
if (
1983-
grade_project_id != course_project_id &&
1984-
grade_project_id != student_project_id
1985-
) {
1986-
// Make a fresh copy of the assignment files to the grade project.
1987-
// This is necessary because grading the assignment may depend on
1988-
// data files that are sent as part of the assignment. Also,
1989-
// student's might have some code in text files next to the ipynb.
1990-
await webapp_client.project_client.copy_path_between_projects({
1991-
src_project_id: course_project_id,
1992-
src_path: student_path,
1993-
target_project_id: grade_project_id,
1994-
target_path: student_path,
1995-
overwrite_newer: true,
1996-
delete_missing: true,
1997-
backup: false,
1998-
});
1999-
}
1982+
let ephemeralGradePath;
1983+
try {
1984+
if (
1985+
grade_project_id != course_project_id &&
1986+
grade_project_id != student_project_id
1987+
) {
1988+
ephemeralGradePath = true;
1989+
// Make a fresh copy of the assignment files to the grade project.
1990+
// This is necessary because grading the assignment may depend on
1991+
// data files that are sent as part of the assignment. Also,
1992+
// student's might have some code in text files next to the ipynb.
1993+
await webapp_client.project_client.copy_path_between_projects({
1994+
src_project_id: course_project_id,
1995+
src_path: student_path,
1996+
target_project_id: grade_project_id,
1997+
target_path: student_path,
1998+
overwrite_newer: true,
1999+
delete_missing: true,
2000+
backup: false,
2001+
});
2002+
} else {
2003+
ephemeralGradePath = false;
2004+
}
20002005

2001-
const opts = {
2002-
timeout_ms: store.getIn(
2003-
["settings", "nbgrader_timeout_ms"],
2004-
NBGRADER_TIMEOUT_MS,
2005-
),
2006-
cell_timeout_ms: store.getIn(
2007-
["settings", "nbgrader_cell_timeout_ms"],
2008-
NBGRADER_CELL_TIMEOUT_MS,
2009-
),
2010-
max_output: store.getIn(
2011-
["settings", "nbgrader_max_output"],
2012-
NBGRADER_MAX_OUTPUT,
2013-
),
2014-
max_output_per_cell: store.getIn(
2015-
["settings", "nbgrader_max_output_per_cell"],
2016-
NBGRADER_MAX_OUTPUT_PER_CELL,
2017-
),
2018-
student_ipynb,
2019-
instructor_ipynb,
2020-
path: student_path,
2021-
project_id: grade_project_id,
2022-
};
2023-
/*console.log(
2006+
const opts = {
2007+
timeout_ms: store.getIn(
2008+
["settings", "nbgrader_timeout_ms"],
2009+
NBGRADER_TIMEOUT_MS,
2010+
),
2011+
cell_timeout_ms: store.getIn(
2012+
["settings", "nbgrader_cell_timeout_ms"],
2013+
NBGRADER_CELL_TIMEOUT_MS,
2014+
),
2015+
max_output: store.getIn(
2016+
["settings", "nbgrader_max_output"],
2017+
NBGRADER_MAX_OUTPUT,
2018+
),
2019+
max_output_per_cell: store.getIn(
2020+
["settings", "nbgrader_max_output_per_cell"],
2021+
NBGRADER_MAX_OUTPUT_PER_CELL,
2022+
),
2023+
student_ipynb,
2024+
instructor_ipynb,
2025+
path: student_path,
2026+
project_id: grade_project_id,
2027+
};
2028+
/*console.log(
20242029
student_id,
20252030
file,
20262031
"about to launch autograding with input ",
20272032
opts
20282033
);*/
2029-
const r = await nbgrader(opts);
2030-
/* console.log(student_id, "autograding finished successfully", {
2034+
const r = await nbgrader(opts);
2035+
/* console.log(student_id, "autograding finished successfully", {
20312036
file,
20322037
r,
20332038
});*/
2034-
result[file] = r;
2039+
result[file] = r;
2040+
} finally {
2041+
if (ephemeralGradePath) {
2042+
await webapp_client.project_client.exec({
2043+
project_id: grade_project_id,
2044+
command: "rm",
2045+
args: ["-rf", student_path],
2046+
});
2047+
}
2048+
}
20352049

20362050
if (!nbgrader_grade_project && stop_student_project) {
20372051
const idstop = this.course_actions.set_activity({

0 commit comments

Comments
 (0)