Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
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
Hamza
erp5-Boxiang
Commits
39c85c8b
Commit
39c85c8b
authored
Jan 24, 2017
by
Yusei Tahara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Jupyter: Support matplotlib inline display. (style is needed to be updated)"
This reverts commit
6b6f1fe0
.
parent
cf20478d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
67 deletions
+11
-67
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
...teItem/portal_components/extension.erp5.JupyterCompile.py
+5
-61
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 @
39c85c8b
...
@@ -17,18 +17,6 @@ import Acquisition
...
@@ -17,18 +17,6 @@ import Acquisition
import
astor
import
astor
from
Products.ERP5Type.Log
import
log
from
Products.ERP5Type.Log
import
log
# Display matplotlib figure automatically like
# the original python kernel
import
matplotlib
import
matplotlib.pyplot
as
plt
from
IPython.utils.decorators
import
flag_calls
from
IPython.core.pylabtools
import
print_figure
from
IPython.core.display
import
_pngxy
from
ipykernel.jsonutil
import
json_clean
,
encode_images
import
threading
display_data_wrapper_lock
=
threading
.
Lock
()
plt
.
plot
=
flag_calls
(
plt
.
plot
)
def
Base_executeJupyter
(
self
,
python_expression
=
None
,
reference
=
None
,
\
def
Base_executeJupyter
(
self
,
python_expression
=
None
,
reference
=
None
,
\
title
=
None
,
request_reference
=
False
,
**
kw
):
title
=
None
,
request_reference
=
False
,
**
kw
):
# Check permissions for current user and display message to non-authorized user
# Check permissions for current user and display message to non-authorized user
...
@@ -80,7 +68,7 @@ def Base_executeJupyter(self, python_expression=None, reference=None, \
...
@@ -80,7 +68,7 @@ def Base_executeJupyter(self, python_expression=None, reference=None, \
# Pass all to code Base_runJupyter external function which would execute the code
# Pass all to code Base_runJupyter external function which would execute the code
# and returns a dict of result
# and returns a dict of result
final_result
=
displayDataWrapper
(
lambda
:
Base_runJupyterCode
(
self
,
python_expression
,
old_notebook_context
)
)
final_result
=
Base_runJupyterCode
(
self
,
python_expression
,
old_notebook_context
)
new_notebook_context
=
final_result
[
'notebook_context'
]
new_notebook_context
=
final_result
[
'notebook_context'
]
...
@@ -90,9 +78,7 @@ def Base_executeJupyter(self, python_expression=None, reference=None, \
...
@@ -90,9 +78,7 @@ def Base_executeJupyter(self, python_expression=None, reference=None, \
u'evalue'
:
final_result
[
'evalue'
],
u'evalue'
:
final_result
[
'evalue'
],
u'traceback'
:
final_result
[
'traceback'
],
u'traceback'
:
final_result
[
'traceback'
],
u'status'
:
final_result
[
'status'
],
u'status'
:
final_result
[
'status'
],
u'mime_type'
:
final_result
[
'mime_type'
],
u'mime_type'
:
final_result
[
'mime_type'
]}
u'extra_data_list'
:
final_result
[
'extra_data_list'
],
}
# Updates the context in the notebook with the resulting context of code
# Updates the context in the notebook with the resulting context of code
# execution.
# execution.
...
@@ -142,49 +128,6 @@ def mergeTracebackListIntoResultDict(result_dict, error_result_dict_list):
...
@@ -142,49 +128,6 @@ def mergeTracebackListIntoResultDict(result_dict, error_result_dict_list):
result_dict
[
'status'
]
=
error_result_dict
[
'status'
]
result_dict
[
'status'
]
=
error_result_dict
[
'status'
]
return
result_dict
return
result_dict
def
matplotlib_pre_run
():
matplotlib
.
interactive
(
True
)
rc
=
{
'figure.figsize'
:
(
6.0
,
4.0
),
'figure.facecolor'
:
(
1
,
1
,
1
,
0
),
'figure.edgecolor'
:
(
1
,
1
,
1
,
0
),
'font.size'
:
10
,
'figure.dpi'
:
36
,
'figure.subplot.bottom'
:
.
125
}
for
key
,
value
in
rc
.
items
():
matplotlib
.
rcParams
[
key
]
=
value
plt
.
gcf
().
clear
()
plt
.
plot
.
called
=
False
def
matplotlib_post_run
(
data_list
):
png_data
=
None
if
plt
.
plot
.
called
:
plt
.
plot
.
called
=
False
figure
=
plt
.
gcf
()
png_data
=
print_figure
(
figure
,
fmt
=
'png'
)
figure
.
clear
()
if
png_data
is
not
None
:
width
,
height
=
_pngxy
(
png_data
)
data
=
encode_images
({
'image/png'
:
png_data
})
metadata
=
{
'image/png'
:
dict
(
width
=
width
,
height
=
height
)}
data_list
.
append
(
json_clean
(
dict
(
data
=
data
,
metadata
=
metadata
)))
def
displayDataWrapper
(
function
):
with
display_data_wrapper_lock
:
# pre run
matplotlib_pre_run
()
result
=
function
()
extra_data_list
=
result
.
get
(
'extra_data_list'
,
[])
# post run
matplotlib_post_run
(
extra_data_list
)
result
[
'extra_data_list'
]
=
extra_data_list
return
result
def
Base_runJupyterCode
(
self
,
jupyter_code
,
old_notebook_context
):
def
Base_runJupyterCode
(
self
,
jupyter_code
,
old_notebook_context
):
"""
"""
Function to execute jupyter code and update the context dictionary.
Function to execute jupyter code and update the context dictionary.
...
@@ -460,7 +403,7 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
...
@@ -460,7 +403,7 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
if
inject_variable_dict
.
get
(
'_print'
)
is
not
None
:
if
inject_variable_dict
.
get
(
'_print'
)
is
not
None
:
output
=
inject_variable_dict
[
'_print'
].
getCapturedOutputString
()
output
=
inject_variable_dict
[
'_print'
].
getCapturedOutputString
()
result
=
{
result
=
{
'result_string'
:
output
,
'result_string'
:
output
,
'notebook_context'
:
notebook_context
,
'notebook_context'
:
notebook_context
,
...
@@ -1056,4 +999,5 @@ def erp5PivotTableUI(self, df):
...
@@ -1056,4 +999,5 @@ def erp5PivotTableUI(self, df):
storeIFrame
(
self
,
html_string
,
key
)
storeIFrame
(
self
,
html_string
,
key
)
iframe_host
=
self
.
REQUEST
[
'HTTP_X_FORWARDED_HOST'
].
split
(
','
)[
0
]
iframe_host
=
self
.
REQUEST
[
'HTTP_X_FORWARDED_HOST'
].
split
(
','
)[
0
]
url
=
"https://%s/erp5/Base_displayPivotTableFrame?key=%s"
%
(
iframe_host
,
key
)
url
=
"https://%s/erp5/Base_displayPivotTableFrame?key=%s"
%
(
iframe_host
,
key
)
return
IFrame
(
src
=
url
,
width
=
'100%'
,
height
=
'500'
)
return
IFrame
(
src
=
url
,
width
=
'100%'
,
height
=
'500'
)
\ No newline at end of file
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.xml
View file @
39c85c8b
...
@@ -46,12 +46,12 @@
...
@@ -46,12 +46,12 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<value>
<tuple>
<tuple>
<string>
W:3
69
, 10: Use of exec (exec-used)
</string>
<string>
W:3
12
, 10: Use of exec (exec-used)
</string>
<string>
W:
412
, 10: Use of exec (exec-used)
</string>
<string>
W:
355
, 10: Use of exec (exec-used)
</string>
<string>
W:
425
, 10: Use of exec (exec-used)
</string>
<string>
W:
368
, 10: Use of exec (exec-used)
</string>
<string>
W:
510
, 6: No exception type(s) specified (bare-except)
</string>
<string>
W:
453
, 6: No exception type(s) specified (bare-except)
</string>
<string>
W:7
63
, 6: Use of exec (exec-used)
</string>
<string>
W:7
06
, 6: Use of exec (exec-used)
</string>
<string>
W:9
89
, 2: Redefining name \'IFrame\' from outer scope (line 4) (redefined-outer-name)
</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>
<string>
W: 18, 0: Unused log imported from Products.ERP5Type.Log (unused-import)
</string>
</tuple>
</tuple>
</value>
</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