Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chaofan Chen
ogs
Commits
7efdcda7
Verified
Commit
7efdcda7
authored
2 years ago
by
Lars Bilke
Browse files
Options
Downloads
Patches
Plain Diff
[T,nb] Handle DeadKernelError in testrunner.
parent
5e21e586
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/Data/Notebooks/testrunner.py
+11
-1
11 additions, 1 deletion
Tests/Data/Notebooks/testrunner.py
with
11 additions
and
1 deletion
Tests/Data/Notebooks/testrunner.py
+
11
−
1
View file @
7efdcda7
import
nbformat
from
nbconvert.preprocessors
import
ExecutePreprocessor
,
CellExecutionError
from
nbclient.exceptions
import
DeadKernelError
from
nbconvert
import
HTMLExporter
import
argparse
import
os
...
...
@@ -87,12 +88,22 @@ for notebook_file_path in args.notebooks:
# 1. Run the notebook
notebook_filename
=
os
.
path
.
basename
(
notebook_file_path
)
convert_notebook_file
=
os
.
path
.
join
(
notebook_output_path
,
notebook_filename
)
print
(
f
"
[Start]
{
notebook_filename
}
"
)
start
=
timer
()
try
:
ep
.
preprocess
(
nb
,
{
"
metadata
"
:
{
"
path
"
:
os
.
path
.
dirname
(
notebook_file_path
)}}
)
except
DeadKernelError
:
out
=
None
msg
=
'
Error executing the notebook
"
%s
"
.
\n\n
'
%
notebook_filename
msg
+=
'
See notebook
"
%s
"
for the traceback.
'
%
convert_notebook_file
print
(
msg
)
notebook_success
=
False
success
=
False
with
open
(
convert_notebook_file
,
mode
=
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
nbformat
.
write
(
nb
,
f
)
except
CellExecutionError
:
notebook_success
=
False
success
=
False
...
...
@@ -108,7 +119,6 @@ for notebook_file_path in args.notebooks:
(
body
,
resources
)
=
html_exporter
.
from_notebook_node
(
nb
)
# 4. Write new notebook
convert_notebook_file
=
os
.
path
.
join
(
notebook_output_path
,
notebook_filename
)
with
open
(
convert_notebook_file
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
nbformat
.
write
(
nb
,
f
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment