Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexander Emmerich
erp5
Commits
46a32afb
Commit
46a32afb
authored
Jan 17, 2017
by
Yusei Tahara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jupyter: make jupyter environment recoverable even if setup function does not work.
parent
5c999848
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
16 deletions
+25
-16
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
...teItem/portal_components/extension.erp5.JupyterCompile.py
+19
-10
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.xml
...eItem/portal_components/extension.erp5.JupyterCompile.xml
+6
-6
No files found.
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
View file @
46a32afb
...
...
@@ -119,6 +119,15 @@ def Base_executeJupyter(self, python_expression=None, reference=None, \
return
serialized_result
def
mergeTracebackListIntoResultDict
(
result_dict
,
error_result_dict_list
):
if
error_result_dict_list
:
if
result_dict
[
'traceback'
]
is
None
:
result_dict
[
'traceback'
]
=
[]
for
error_result_dict
in
error_result_dict_list
:
result_dict
[
'traceback'
].
append
(
error_result_dict
[
'traceback'
])
result_dict
[
'status'
]
=
error_result_dict
[
'status'
]
return
result_dict
def
Base_runJupyterCode
(
self
,
jupyter_code
,
old_notebook_context
):
"""
Function to execute jupyter code and update the context dictionary.
...
...
@@ -178,7 +187,8 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
inject_variable_dict
=
{}
current_var_dict
=
{}
current_setup_dict
=
{}
setup_error_return_dict_list
=
[]
# Execute only if jupyter_code is not empty
if
jupyter_code
:
# Create ast parse tree
...
...
@@ -305,14 +315,11 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
except
Exception
as
e
:
if
value
[
'func_name'
]
in
user_context
:
del
user_context
[
value
[
'func_name'
]]
error_return_dict
=
getErrorMessageForException
(
self
,
e
,
notebook_context
)
error_return_dict
=
getErrorMessageForException
(
self
,
e
,
notebook_context
)
additional_information
=
"An error happened when trying to run the one of your setup functions:"
error_return_dict
[
'traceback'
].
insert
(
0
,
additional_information
)
# As in any other user's code execution, transaction needs to be
# aborted.
transaction
.
abort
()
return
error_return_dict
setup_error_return_dict_list
.
append
(
error_return_dict
)
# Iterating over envinronment.define calls captured by the environment collector
# that are functions and saving them as setup functions.
for
func_name
,
data
in
current_setup_dict
.
iteritems
():
...
...
@@ -350,7 +357,8 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
# Abort the current transaction. As a consequence, the notebook lines
# are not added if an exception occurs.
transaction
.
abort
()
return
getErrorMessageForException
(
self
,
e
,
notebook_context
)
return
mergeTracebackListIntoResultDict
(
getErrorMessageForException
(
self
,
e
,
notebook_context
),
setup_error_return_dict_list
)
# Execute the interactive nodes with 'single' mode
for
node
in
to_run_interactive
:
...
...
@@ -362,7 +370,8 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
# Abort the current transaction. As a consequence, the notebook lines
# are not added if an exception occurs.
transaction
.
abort
()
return
getErrorMessageForException
(
self
,
e
,
notebook_context
)
return
mergeTracebackListIntoResultDict
(
getErrorMessageForException
(
self
,
e
,
notebook_context
),
setup_error_return_dict_list
)
mime_type
=
display_data
[
'mime_type'
]
or
mime_type
inject_variable_dict
[
'_print'
].
write
(
"
\
n
"
.
join
(
removed_setup_message_list
)
+
display_data
[
'result'
])
...
...
@@ -403,7 +412,7 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
'evalue'
:
evalue
,
'ename'
:
ename
,
'traceback'
:
tb_list
}
return
result
return
mergeTracebackListIntoResultDict
(
result
,
setup_error_return_dict_list
)
class
EnvironmentUndefineError
(
TypeError
):
...
...
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.xml
View file @
46a32afb
...
...
@@ -46,12 +46,12 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W:3
0
2, 10: Use of exec (exec-used)
</string>
<string>
W:3
48
, 10: Use of exec (exec-used)
</string>
<string>
W:36
0
, 10: Use of exec (exec-used)
</string>
<string>
W:4
44
, 6: No exception type(s) specified (bare-except)
</string>
<string>
W:
697
, 6: Use of exec (exec-used)
</string>
<string>
W:9
23
, 2: Redefining name \'IFrame\' from outer scope (line 4) (redefined-outer-name)
</string>
<string>
W:3
1
2, 10: Use of exec (exec-used)
</string>
<string>
W:3
55
, 10: Use of exec (exec-used)
</string>
<string>
W:36
8
, 10: Use of exec (exec-used)
</string>
<string>
W:4
53
, 6: No exception type(s) specified (bare-except)
</string>
<string>
W:
706
, 6: Use of exec (exec-used)
</string>
<string>
W:9
32
, 2: Redefining name \'IFrame\' from outer scope (line 4) (redefined-outer-name)
</string>
<string>
W: 18, 0: Unused log imported from Products.ERP5Type.Log (unused-import)
</string>
</tuple>
</value>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment