Show More
@@ -29,12 +29,15 b' class ExecutePreprocessor(Preprocessor):' | |||||
29 | extra_arguments = List(Unicode) |
|
29 | extra_arguments = List(Unicode) | |
30 |
|
30 | |||
31 | def preprocess(self, nb, resources): |
|
31 | def preprocess(self, nb, resources): | |
|
32 | path = resources.get('metadata', {}).get('path', None) | |||
|
33 | ||||
32 | from IPython.kernel import run_kernel |
|
34 | from IPython.kernel import run_kernel | |
33 | kernel_name = nb.metadata.get('kernelspec', {}).get('name', 'python') |
|
35 | kernel_name = nb.metadata.get('kernelspec', {}).get('name', 'python') | |
34 | self.log.info("Executing notebook with kernel: %s" % kernel_name) |
|
36 | self.log.info("Executing notebook with kernel: %s" % kernel_name) | |
35 | with run_kernel(kernel_name=kernel_name, |
|
37 | with run_kernel(kernel_name=kernel_name, | |
36 | extra_arguments=self.extra_arguments, |
|
38 | extra_arguments=self.extra_arguments, | |
37 |
stderr=open(os.devnull, 'w') |
|
39 | stderr=open(os.devnull, 'w'), | |
|
40 | cwd=path) as kc: | |||
38 | self.kc = kc |
|
41 | self.kc = kc | |
39 | self.kc.allow_stdin = False |
|
42 | self.kc.allow_stdin = False | |
40 | nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources) |
|
43 | nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources) |
@@ -79,9 +79,10 b' class TestExecute(PreprocessorTestsBase):' | |||||
79 | current_dir = os.path.dirname(__file__) |
|
79 | current_dir = os.path.dirname(__file__) | |
80 | input_files = glob.glob(os.path.join(current_dir, 'files', '*.ipynb')) |
|
80 | input_files = glob.glob(os.path.join(current_dir, 'files', '*.ipynb')) | |
81 | for filename in input_files: |
|
81 | for filename in input_files: | |
82 |
with io.open( |
|
82 | with io.open(filename) as f: | |
83 | input_nb = nbformat.read(f, 4) |
|
83 | input_nb = nbformat.read(f, 4) | |
84 | res = self.build_resources() |
|
84 | res = self.build_resources() | |
|
85 | res['metadata']['path'] = os.path.dirname(filename) | |||
85 | preprocessor = self.build_preprocessor() |
|
86 | preprocessor = self.build_preprocessor() | |
86 | cleaned_input_nb = copy.deepcopy(input_nb) |
|
87 | cleaned_input_nb = copy.deepcopy(input_nb) | |
87 | for cell in cleaned_input_nb.cells: |
|
88 | for cell in cleaned_input_nb.cells: |
General Comments 0
You need to be logged in to leave comments.
Login now