Skip to content

Commit

Permalink
set kernel working dir to notebook resources path
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorcampbell committed Aug 31, 2023
1 parent 2702e2c commit 6964065
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions nbgrader/preprocessors/instantiatetests.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def preprocess(self, nb, resources):
self.log.debug("Found kernel %s", kernel_name)
resources["kernel_name"] = kernel_name

# get the resources path from the notebook
resources_path = resources.get('metadata', {}).get('path', None)

# load the template tests file
self.log.debug('Loading template tests file')
self._load_test_template_file(resources)
Expand All @@ -126,9 +129,9 @@ def preprocess(self, nb, resources):
# set up the sanitizer
self.log.debug('Setting sanitizer for kernel %s', kernel_name)
self.sanitizer = self.sanitizers[kernel_name]
#start the kernel
self.log.debug('Starting client for kernel %s', kernel_name)
km, self.kc = start_new_kernel(kernel_name=kernel_name)
#start the kernel with the specified kernel and in the local path of the notebook
self.log.debug('Starting client for kernel %s at path %s', kernel_name, resources_path if resources_path is not None else '')
km, self.kc = start_new_kernel(kernel_name=kernel_name, cwd=resources_path)

# run the preprocessor
self.log.debug('Running InstantiateTests preprocessor')
Expand Down Expand Up @@ -263,9 +266,9 @@ def preprocess_cell(self, cell, resources, index):

# add the final success code and execute it
if (
is_grade_flag
and self.global_tests_loaded
and (self.autotest_delimiter in cell.source)
is_grade_flag
and self.global_tests_loaded
and (self.autotest_delimiter in cell.source)
and (self.success_code is not None)
):
new_lines.append(self.success_code)
Expand Down

0 comments on commit 6964065

Please sign in to comment.