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

enable cell number print when verbose logging activates #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion treon/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def run_tests(self):
LOG.info("Triggered test for %s", self.file_path)

try:
self.is_successful, console_output = execute_notebook(self.file_path)
self.is_successful, console_output = execute_notebook(self.file_path, _is_verbose())
result = self.result_string()

if not self.is_successful or _is_verbose():
Expand Down
9 changes: 8 additions & 1 deletion treon/test_execution.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import os
import logging
import textwrap
import nbformat

from nbformat.v4 import new_code_cell
from nbconvert.preprocessors import ExecutePreprocessor

LOG = logging.getLogger('treon.task')

def execute_notebook(path):
def execute_notebook(path, verbose=False):
notebook = nbformat.read(path, as_version=4)
notebook.cells.extend([unittest_cell(), doctest_cell()])
processor = ExecutePreprocessor(timeout=-1, kernel_name='python3')

if verbose:
def print_executed_cell_index(cell, cell_index):
LOG.debug(f"Start executing cell {cell_index}")
processor.on_cell_start = print_executed_cell_index
processor.preprocess(notebook, metadata(path))
return parse_test_result(notebook.cells)

Expand Down