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
Add Custom Timeout - Closes #8 #14
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,13 @@ | |
|
||
import nbconvert | ||
|
||
TIMEOUT = "120" | ||
|
||
def build_cmd(notebook): | ||
cmd = [ | ||
"jupyter", "nbconvert", | ||
"--log-level=ERROR", | ||
"--ExecutePreprocessor.timeout=120", | ||
"--ExecutePreprocessor.timeout=" + TIMEOUT, | ||
"--execute", | ||
"--inplace", | ||
"--to", "notebook" | ||
|
@@ -49,9 +51,12 @@ def print_cmd_line(s, targets, sources, env): | |
sys.stdout.write("%s --> %s\n"% (str(sources[0]), str(target))) | ||
|
||
|
||
def setup(env, directories): | ||
def setup(env, directories, timeout=None): | ||
env['PRINT_CMD_LINE_FUNC'] = print_cmd_line | ||
env.Decider('timestamp-newer') | ||
if timeout is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, it would be nice if we could come up with a way to do this without using global variables (see here for an explanation of why avoiding globals is a good idea). One way this might be possible is to create a class, say called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the next commit, intead of using classes, I chose a more functional approach and use only pure functions and define a default value for Because of the nature of |
||
global TIMEOUT | ||
TIMEOUT = str(timeout) | ||
DEPENDENCIES = json.loads(sp.check_output([sys.executable, "-m", "nbflow"] + directories).decode('UTF-8')) | ||
for script in DEPENDENCIES: | ||
deps = DEPENDENCIES[script] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this is something that would be handled by the nbflow code, rather than something users have to put in the SConstruct file. Maybe pass the
ARGUMENTS
variable to thesetup
function directly and letsetup
parse the timeout?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next commit fixes this parsing the
ARGUMENTS
insidesetup