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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tomáš Peterka
erp5
Commits
d708bd87
Commit
d708bd87
authored
Jun 16, 2017
by
Iliya Manolov
Committed by
Ivan Tyagov
Jun 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed imports that look like import modulea.moduleb, added test and fixed environment.showSetup().
@Tyagov
@luke
/reviewed-on
nexedi/erp5!288
parent
e79dcdaf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
7 deletions
+48
-7
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
...teItem/portal_components/extension.erp5.JupyterCompile.py
+17
-6
bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py
...ateItem/portal_components/test.erp5.testExecuteJupyter.py
+31
-1
No files found.
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
View file @
d708bd87
...
...
@@ -459,7 +459,7 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
user_context
[
'_volatile_variable_list'
]
+=
variable
if
environment_collector
.
showEnvironmentSetup
():
inject_variable_dict
.
write
(
"%s
\
n
"
%
str
(
notebook_context
[
'setup'
]))
inject_variable_dict
[
'_print'
]
.
write
(
"%s
\
n
"
%
str
(
notebook_context
[
'setup'
]))
# Execute the nodes with 'exec' mode
for
node
in
to_run_exec
:
...
...
@@ -888,12 +888,19 @@ class ImportFixer(ast.NodeTransformer):
# is immediately raised and doesn't block next Jupyter cell execution
exec
(
test_import_string
)
empty_function
=
self
.
newEmptyFunction
(
"%s_setup"
%
result_name
)
dotless_result_name
=
""
for
character
in
result_name
:
if
character
==
'.'
:
dotless_result_name
=
dotless_result_name
+
'_dot_'
else
:
dotless_result_name
=
dotless_result_name
+
character
empty_function
=
self
.
newEmptyFunction
(
"%s_setup"
%
dotless_result_name
)
return_dict
=
self
.
newReturnDict
(
final_module_names
)
empty_function
.
body
=
[
node
,
return_dict
]
environment_set
=
self
.
newEnvironmentSetCall
(
"%s_setup"
%
result_name
)
self
.
newImportWarningCall
(
root_module_name
,
result_name
)
environment_set
=
self
.
newEnvironmentSetCall
(
"%s_setup"
%
dotless_
result_name
)
self
.
newImportWarningCall
(
root_module_name
,
dotless_
result_name
)
return
[
empty_function
,
environment_set
]
else
:
return
node
...
...
@@ -914,7 +921,11 @@ class ImportFixer(ast.NodeTransformer):
"""
return_dict
=
"return {"
for
name
in
module_names
:
return_dict
=
return_dict
+
"'%s': %s, "
%
(
name
,
name
)
if
name
.
find
(
'.'
)
!=
-
1
:
base_name
=
name
[:
name
.
find
(
'.'
)]
else
:
base_name
=
name
return_dict
=
return_dict
+
"'%s': %s, "
%
(
base_name
,
base_name
)
return_dict
=
return_dict
+
'}'
return
ast
.
parse
(
return_dict
).
body
[
0
]
...
...
bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py
View file @
d708bd87
...
...
@@ -961,3 +961,33 @@ print np.array([1, 2, 3])
result
=
json
.
loads
(
result
)
self
.
assertEquals
(
result
[
'status'
],
'ok'
)
self
.
assertEquals
(
result
[
'code_result'
].
strip
(),
u'[1 2 3]'
)
def
testDotImport
(
self
):
'''
This test guarantees that "import modulea.moduleb" works in Jupyter.
'''
self
.
login
(
'dev_user'
)
import_code
=
'''
import os.path
'''
reference
=
'Test.Notebook.EnvironmentObject.Errors.DotImport'
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
python_expression
=
import_code
)
self
.
tic
()
result
=
json
.
loads
(
result
)
self
.
assertEquals
(
result
[
'status'
],
'ok'
)
jupyter_code
=
'''
print os.path
'''
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
python_expression
=
jupyter_code
)
self
.
tic
()
result
=
json
.
loads
(
result
)
self
.
assertEquals
(
result
[
'status'
],
'ok'
)
\ No newline at end of file
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