Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set kernel working directory properly #19

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading