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
Nikola Balog
erp5
Commits
bd4eebcf
Commit
bd4eebcf
authored
Mar 05, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
data_notebook: fix remaining print statement
parent
cb2155c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
28 deletions
+28
-28
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
...teItem/portal_components/extension.erp5.JupyterCompile.py
+2
-2
bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py
...ateItem/portal_components/test.erp5.testExecuteJupyter.py
+26
-26
No files found.
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
View file @
bd4eebcf
...
@@ -305,12 +305,12 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
...
@@ -305,12 +305,12 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
# Whenever we have new imports we need to warn the user about the
# Whenever we have new imports we need to warn the user about the
# environment
# environment
if
(
import_fixer
.
warning_module_names
!=
[]):
if
(
import_fixer
.
warning_module_names
!=
[]):
warning
=
(
"print '"
warning
=
(
"print
(
'"
"WARNING: You imported from the modules %s without "
"WARNING: You imported from the modules %s without "
"using the environment object, which is not recomended. "
"using the environment object, which is not recomended. "
"Your import was automatically converted to use such method. "
"Your import was automatically converted to use such method. "
"The setup functions were named as *module*_setup. "
"The setup functions were named as *module*_setup. "
"'"
)
%
(
', '
.
join
(
import_fixer
.
warning_module_names
))
"'
)
"
)
%
(
', '
.
join
(
import_fixer
.
warning_module_names
))
tree
=
ast
.
parse
(
warning
)
tree
=
ast
.
parse
(
warning
)
tree
.
body
[
0
].
lineno
=
ast_node
.
body
[
-
1
].
lineno
+
5
tree
.
body
[
0
].
lineno
=
ast_node
.
body
[
-
1
].
lineno
+
5
ast_node
.
body
.
append
(
tree
.
body
[
0
])
ast_node
.
body
.
append
(
tree
.
body
[
0
])
...
...
bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py
View file @
bd4eebcf
...
@@ -102,7 +102,7 @@ class TestExecuteJupyter(ERP5TypeTestCase):
...
@@ -102,7 +102,7 @@ class TestExecuteJupyter(ERP5TypeTestCase):
python_script
=
"""
python_script
=
"""
portal = context.getPortalObject()
portal = context.getPortalObject()
portal.setTitle('%s')
portal.setTitle('%s')
print
an_undefined_variable
print
(an_undefined_variable)
"""
%
new_test_title
"""
%
new_test_title
# Create python_script object with the above given code and containers
# Create python_script object with the above given code and containers
...
@@ -254,7 +254,7 @@ portal.%s()
...
@@ -254,7 +254,7 @@ portal.%s()
"""
"""
portal
=
self
.
portal
portal
=
self
.
portal
self
.
login
(
'dev_user'
)
self
.
login
(
'dev_user'
)
python_expression
=
"print
52
"
python_expression
=
"print
(52)
"
reference
=
'Test.Notebook.AddNewNotebookLine %s'
%
time
.
time
()
reference
=
'Test.Notebook.AddNewNotebookLine %s'
%
time
.
time
()
title
=
'Test NB Title %s'
%
time
.
time
()
title
=
'Test NB Title %s'
%
time
.
time
()
...
@@ -313,7 +313,7 @@ portal.%s()
...
@@ -313,7 +313,7 @@ portal.%s()
"""
"""
portal
=
self
.
portal
portal
=
self
.
portal
self
.
login
(
'dev_user'
)
self
.
login
(
'dev_user'
)
python_expression
=
'a=2; b=3; print
a+b
'
python_expression
=
'a=2; b=3; print
(a+b)
'
reference
=
'Test.Notebook.ExecutePythonExpressionWithVariables %s'
%
time
.
time
()
reference
=
'Test.Notebook.ExecutePythonExpressionWithVariables %s'
%
time
.
time
()
title
=
'Test NB Title %s'
%
time
.
time
()
title
=
'Test NB Title %s'
%
time
.
time
()
...
@@ -340,7 +340,7 @@ portal.%s()
...
@@ -340,7 +340,7 @@ portal.%s()
"""
"""
portal
=
self
.
portal
portal
=
self
.
portal
self
.
login
(
'dev_user'
)
self
.
login
(
'dev_user'
)
python_expression
=
'a=2; b=3; print
a+b
'
python_expression
=
'a=2; b=3; print
(a+b)
'
reference
=
'Test.Notebook.ExecutePythonExpressionWithVariables %s'
%
time
.
time
()
reference
=
'Test.Notebook.ExecutePythonExpressionWithVariables %s'
%
time
.
time
()
title
=
'Test NB Title %s'
%
time
.
time
()
title
=
'Test NB Title %s'
%
time
.
time
()
...
@@ -351,7 +351,7 @@ portal.%s()
...
@@ -351,7 +351,7 @@ portal.%s()
)
)
self
.
tic
()
self
.
tic
()
python_expression
=
'x=5; b=4; print
a+b+x
'
python_expression
=
'x=5; b=4; print
(a+b+x)
'
result
=
portal
.
Base_executeJupyter
(
result
=
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
python_expression
=
python_expression
python_expression
=
python_expression
...
@@ -379,7 +379,7 @@ import sys
...
@@ -379,7 +379,7 @@ import sys
)
)
self
.
tic
()
self
.
tic
()
jupyter_code
=
"print imh.__name__
"
jupyter_code
=
"print(imh.__name__)
"
result
=
portal
.
Base_executeJupyter
(
result
=
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
python_expression
=
jupyter_code
)
python_expression
=
jupyter_code
)
...
@@ -454,7 +454,7 @@ context.Base_renderAsHtml(image)
...
@@ -454,7 +454,7 @@ context.Base_renderAsHtml(image)
# Call Base_executeJupyter to check for the name of module and match it with
# Call Base_executeJupyter to check for the name of module and match it with
# namespace 'ss1'
# namespace 'ss1'
jupyter_code2
=
"print
ss1.__name__
"
jupyter_code2
=
"print
(ss1.__name__)
"
result
=
portal
.
Base_executeJupyter
(
result
=
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
python_expression
=
jupyter_code2
python_expression
=
jupyter_code2
...
@@ -488,8 +488,8 @@ environment.define(create_sum_machines, 'creates sum function and class')
...
@@ -488,8 +488,8 @@ environment.define(create_sum_machines, 'creates sum function and class')
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
sum_function(1, 1
)
print
(sum_function(1, 1)
)
print
Calculator().sum(2, 2
)
print
(Calculator().sum(2, 2)
)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
...
@@ -517,7 +517,7 @@ environment.define(x='couscous')
...
@@ -517,7 +517,7 @@ environment.define(x='couscous')
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
jupyter_code
=
'print
x
'
jupyter_code
=
'print
(x)
'
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
python_expression
=
jupyter_code
python_expression
=
jupyter_code
...
@@ -566,8 +566,8 @@ environment.undefine('creates sum function and class')
...
@@ -566,8 +566,8 @@ environment.undefine('creates sum function and class')
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
'sum_function' in locals(
)
print
('sum_function' in locals()
)
print
'Calculator' in locals(
)
print
('Calculator' in locals()
)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
...
@@ -603,7 +603,7 @@ environment.define(x='couscous')
...
@@ -603,7 +603,7 @@ environment.define(x='couscous')
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
jupyter_code
=
"print
'x' in locals(
)"
jupyter_code
=
"print
('x' in locals()
)"
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
python_expression
=
jupyter_code
python_expression
=
jupyter_code
...
@@ -630,7 +630,7 @@ import random
...
@@ -630,7 +630,7 @@ import random
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
random.randint(1,1
)
print
(random.randint(1,1)
)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
...
@@ -721,7 +721,7 @@ import random as rand
...
@@ -721,7 +721,7 @@ import random as rand
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
self
.
assertEqual
(
json
.
loads
(
result
)[
'status'
],
'ok'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
rand.randint(1,1
)
print
(rand.randint(1,1)
)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
...
@@ -750,7 +750,7 @@ iframe = context.Base_erp5PivotTableUI(my_df)
...
@@ -750,7 +750,7 @@ iframe = context.Base_erp5PivotTableUI(my_df)
context.Base_renderAsHtml(iframe)
context.Base_renderAsHtml(iframe)
'''
'''
reference
=
'Test.Notebook.PivotTableJsIntegration %s'
%
time
.
time
()
reference
=
'Test.Notebook.PivotTableJsIntegration %s'
%
time
.
time
()
notebook
=
self
.
_newNotebook
(
reference
=
reference
)
self
.
_newNotebook
(
reference
=
reference
)
result
=
portal
.
Base_executeJupyter
(
result
=
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
python_expression
=
jupyter_code
python_expression
=
jupyter_code
...
@@ -783,7 +783,7 @@ from string import ascii_lowercase, ascii_uppercase, digits
...
@@ -783,7 +783,7 @@ from string import ascii_lowercase, ascii_uppercase, digits
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
ascii_lowercase
print
(ascii_lowercase)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
...
@@ -796,7 +796,7 @@ print ascii_lowercase
...
@@ -796,7 +796,7 @@ print ascii_lowercase
self
.
assertEqual
(
result
[
'code_result'
].
strip
(),
'abcdefghijklmnopqrstuvwxyz'
)
self
.
assertEqual
(
result
[
'code_result'
].
strip
(),
'abcdefghijklmnopqrstuvwxyz'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
ascii_uppercase
print
(ascii_uppercase)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
...
@@ -809,7 +809,7 @@ print ascii_uppercase
...
@@ -809,7 +809,7 @@ print ascii_uppercase
self
.
assertEqual
(
result
[
'code_result'
].
strip
(),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
)
self
.
assertEqual
(
result
[
'code_result'
].
strip
(),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
digits
print
(digits)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
...
@@ -840,7 +840,7 @@ from string import *
...
@@ -840,7 +840,7 @@ from string import *
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
ascii_lowercase
print
(ascii_lowercase)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
...
@@ -871,7 +871,7 @@ from string import digits as dig
...
@@ -871,7 +871,7 @@ from string import digits as dig
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
dig
print
(dig)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
...
@@ -893,7 +893,7 @@ print dig
...
@@ -893,7 +893,7 @@ print dig
notebook_title
=
u''
.
join
(
random
.
choice
(
string
.
ascii_lowercase
)
for
_
in
range
(
30
))
notebook_title
=
u''
.
join
(
random
.
choice
(
string
.
ascii_lowercase
)
for
_
in
range
(
30
))
notebook_module
=
self
.
portal
.
getDefaultModule
(
portal_type
=
'Data Notebook'
)
notebook_module
=
self
.
portal
.
getDefaultModule
(
portal_type
=
'Data Notebook'
)
data_notebook
=
notebook_module
.
DataNotebookModule_addDataNotebook
(
notebook_module
.
DataNotebookModule_addDataNotebook
(
title
=
notebook_title
,
title
=
notebook_title
,
reference
=
notebook_reference
,
reference
=
notebook_reference
,
batch_mode
=
True
)
batch_mode
=
True
)
...
@@ -921,7 +921,7 @@ import numpy as np
...
@@ -921,7 +921,7 @@ import numpy as np
result
=
json
.
loads
(
result
)
result
=
json
.
loads
(
result
)
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
np.random.rand(256, 256, 256
)
print
(np.random.rand(256, 256, 256)
)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
...
@@ -934,7 +934,7 @@ print np.random.rand(256, 256, 256)
...
@@ -934,7 +934,7 @@ print np.random.rand(256, 256, 256)
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
np.random.randint(low = 2 ** 63 - 1, size = (256, 256, 256), dtype = 'int64'
)
print
(np.random.randint(low = 2 ** 63 - 1, size = (256, 256, 256), dtype = 'int64')
)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
...
@@ -974,7 +974,7 @@ import datetime
...
@@ -974,7 +974,7 @@ import datetime
self
.
assertEqual
(
result
[
'code_result'
].
strip
(),
expected_result
)
self
.
assertEqual
(
result
[
'code_result'
].
strip
(),
expected_result
)
jupyter_code
=
'''
jupyter_code
=
'''
print
np.array([1, 2, 3]
)
print
(np.array([1, 2, 3])
)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
...
@@ -1005,7 +1005,7 @@ import os.path
...
@@ -1005,7 +1005,7 @@ import os.path
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
self
.
assertEqual
(
result
[
'status'
],
'ok'
)
jupyter_code
=
'''
jupyter_code
=
'''
print
os.path
print
(os.path)
'''
'''
result
=
self
.
portal
.
Base_executeJupyter
(
result
=
self
.
portal
.
Base_executeJupyter
(
reference
=
reference
,
reference
=
reference
,
...
...
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