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
Hardik Juneja
erp5
Commits
f79085ca
Commit
f79085ca
authored
Dec 20, 2017
by
Hardik Juneja
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_joblib]: create a new portal skins and move all examples there
parent
1186a65a
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
230 additions
and
51 deletions
+230
-51
bt5/erp5_joblib/ExtensionTemplateItem/portal_components/extension.erp5.joblibUseCaseExamples.py
...portal_components/extension.erp5.joblibUseCaseExamples.py
+1
-1
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib/Base_callSafeFunction.py
...ateItem/portal_skins/erp5_joblib/Base_callSafeFunction.py
+6
-2
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples.xml
...ib/SkinTemplateItem/portal_skins/erp5_joblib_examples.xml
+26
-0
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_driverScriptRandomForest.py
...ins/erp5_joblib_examples/Base_driverScriptRandomForest.py
+6
-0
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_driverScriptRandomForest.xml
...ns/erp5_joblib_examples/Base_driverScriptRandomForest.xml
+62
-0
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_driverScriptSquareRoot.py
...skins/erp5_joblib_examples/Base_driverScriptSquareRoot.py
+6
-0
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_driverScriptSquareRoot.xml
...kins/erp5_joblib_examples/Base_driverScriptSquareRoot.xml
+62
-0
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_joblibRandomForestFunction.xml
.../erp5_joblib_examples/Base_joblibRandomForestFunction.xml
+28
-0
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_joblibSimpleFunction.xml
..._skins/erp5_joblib_examples/Base_joblibSimpleFunction.xml
+28
-0
bt5/erp5_joblib/TestTemplateItem/portal_components/test.erp5.testJoblibActivityUseCase.py
.../portal_components/test.erp5.testJoblibActivityUseCase.py
+3
-47
bt5/erp5_joblib/bt/template_skin_id_list
bt5/erp5_joblib/bt/template_skin_id_list
+2
-1
No files found.
bt5/erp5_joblib/ExtensionTemplateItem/portal_components/extension.erp5.joblibUseCaseExamples.py
View file @
f79085ca
...
...
@@ -58,7 +58,7 @@ def example_simple_function(self, active_process_path):
result
=
Parallel
(
n_jobs
=
2
,
pre_dispatch
=
'all'
,
timeout
=
30
,
verbose
=
30
)(
delayed
(
sqrt
)(
i
**
2
)
for
i
in
range
(
5
))
# Set result value and an id to the active result and post it
result
=
ActiveResult
(
result
=
result
,
signature
=
12345
)
result
=
ActiveResult
(
result
=
result
)
active_process
.
postResult
(
result
)
log
(
"joblib activity result"
,
result
)
return
result
...
...
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib/Base_callSafeFunction.py
View file @
f79085ca
if
REQUEST
is
not
None
:
raise
Unauthorized
"""
This script safely executes and return the result of the given safe function
"""
if
callable
(
batch_function
)
is
False
:
raise
Exception
(
'batch_function is not callable'
)
from
Products.CMFActivity.ActiveResult
import
ActiveResult
...
...
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples.xml
0 → 100644
View file @
f79085ca
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Folder"
module=
"OFS.Folder"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_objects
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
erp5_joblib_examples
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_driverScriptRandomForest.py
0 → 100644
View file @
f79085ca
active_process
=
context
.
portal_activities
.
newActiveProcess
()
active_process_id
=
active_process
.
getId
()
path
=
active_process
.
getPhysicalPath
()
context
.
portal_activities
.
activate
(
activity
=
"SQLQueue"
,
after_method_id
=
"Base_callSafeFunction"
,
active_process
=
active_process
).
Base_joblibRandomForestFunction
(
path
)
return
path
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_driverScriptRandomForest.xml
0 → 100644
View file @
f79085ca
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_driverScriptRandomForest
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_driverScriptSquareRoot.py
0 → 100644
View file @
f79085ca
active_process
=
context
.
portal_activities
.
newActiveProcess
()
active_process_id
=
active_process
.
getId
()
path
=
active_process
.
getPhysicalPath
()
context
.
portal_activities
.
activate
(
activity
=
"SQLQueue"
,
after_method_id
=
"Base_callSafeFunction"
,
active_process
=
active_process
).
Base_joblibSimpleFunction
(
path
)
return
path
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_driverScriptSquareRoot.xml
0 → 100644
View file @
f79085ca
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_driverScriptSquareRoot
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_joblibRandomForestFunction.xml
0 → 100644
View file @
f79085ca
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ExternalMethod"
module=
"Products.ExternalMethod.ExternalMethod"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_function
</string>
</key>
<value>
<string>
example_random_forest_function
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
joblibUseCaseExamples
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_joblibRandomForestFunction
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Base_joblibRandomForestFunction
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_joblib/SkinTemplateItem/portal_skins/erp5_joblib_examples/Base_joblibSimpleFunction.xml
0 → 100644
View file @
f79085ca
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ExternalMethod"
module=
"Products.ExternalMethod.ExternalMethod"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_function
</string>
</key>
<value>
<string>
example_simple_function
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
joblibUseCaseExamples
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_joblibSimpleFunction
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Base_joblibSimpleFunction
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_joblib/TestTemplateItem/portal_components/test.erp5.testJoblibActivityUseCase.py
View file @
f79085ca
...
...
@@ -26,7 +26,6 @@
##############################################################################
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ExternalMethod.ExternalMethod
import
manage_addExternalMethod
class
Test
(
ERP5TypeTestCase
):
"""
...
...
@@ -37,59 +36,16 @@ class Test(ERP5TypeTestCase):
return
"TestJoblibUsecases"
def
test_randomForest
(
self
):
portal_skins
=
self
.
getPortal
().
portal_skins
manage_addExternalMethod
(
self
.
portal
,
'Base_joblibRandomForestFunction'
,
'Base_joblibRandomForestFunction'
,
'joblibUseCaseExamples'
,
'example_random_forest_function'
)
skin_folder
=
getattr
(
portal_skins
,
"erp5_joblib"
)
skin_folder
.
manage_addProduct
[
'PythonScripts'
].
manage_addPythonScript
(
id
=
'Base_driverScriptRandomForest'
)
script
=
getattr
(
skin_folder
,
'Base_driverScriptRandomForest'
)
script
.
ZPythonScript_edit
(
'**kw'
,
"""import time
active_process = context.portal_activities.newActiveProcess()
active_process_id = active_process.getId()
path = active_process.getPhysicalPath()
context.portal_activities.activate(activity="SQLQueue", after_method_id="Base_callSafeFunction", active_process=active_process).Base_joblibRandomForestFunction(path)
return path"""
)
path
=
portal_skins
.
erp5_joblib
.
Base_driverScriptRandomForest
()
path
=
self
.
portal
.
Base_driverScriptRandomForest
()
self
.
tic
()
active_process
=
portal_skins
.
erp5_joblib
.
portal_activities
.
unrestrictedTraverse
(
path
)
active_process
=
self
.
portal
.
portal_activities
.
unrestrictedTraverse
(
path
)
result
=
active_process
.
getResultList
()
self
.
assertAlmostEqual
(
0.98444444444444446
,
result
[
0
].
result
)
def
test_UnderRootOfSquaresFunction
(
self
):
portal_skins
=
self
.
getPortal
().
portal_skins
manage_addExternalMethod
(
self
.
portal
,
'Base_joblibSimpleFunction'
,
'Base_joblibSimpleFunction'
,
'joblibUseCaseExamples'
,
'example_simple_function'
)
skin_folder
=
getattr
(
portal_skins
,
"erp5_joblib"
)
skin_folder
.
manage_addProduct
[
'PythonScripts'
].
manage_addPythonScript
(
id
=
'Base_driverScriptSquareRoot'
)
script
=
getattr
(
skin_folder
,
'Base_driverScriptSquareRoot'
)
script
.
ZPythonScript_edit
(
'**kw'
,
"""import time
active_process = context.portal_activities.newActiveProcess()
active_process_id = active_process.getId()
path = active_process.getPhysicalPath()
context.portal_activities.activate(activity="SQLQueue", after_method_id="Base_callSafeFunction", active_process=active_process).Base_joblibSimpleFunction(path)
return path"""
)
path
=
portal_skins
.
erp5_joblib
.
Base_driverScriptSquareRoot
()
path
=
self
.
portal
.
Base_driverScriptSquareRoot
()
self
.
tic
()
active_process
=
self
.
portal
.
portal_activities
.
unrestrictedTraverse
(
path
)
result
=
active_process
.
getResultList
()
self
.
assertEquals
([
0.0
,
1.0
,
2.0
,
3.0
,
4.0
],
result
[
0
].
result
)
def
beforeTearDown
(
self
):
scripts
=
[
'Base_driverScriptSquareRoot'
,
'Base_driverScriptSquareRoot'
,
'Base_joblibRandomForestFunction'
,
'Base_joblibSimpleFunction'
]
for
script
in
scripts
:
try
:
self
.
portal
.
manage_delObjects
([
script
,])
except
Exception
:
continue
bt5/erp5_joblib/bt/template_skin_id_list
View file @
f79085ca
erp5_joblib
erp5_joblib_examples
\ 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