Commit 36290703 authored by Hardik Juneja's avatar Hardik Juneja Committed by Hardik Juneja

some cleanup

parent 049fdd57
......@@ -30,8 +30,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)
result.signature = 12345
result = ActiveResult(result=result, signature=12345)
active_process.postResult(result)
log("joblib activity result", result)
return result
......@@ -87,8 +86,7 @@ def example_random_forest_function(self, active_process_path):
score = final_model.score(X_test, y_test)
# Set result value and an id to the active result and post it
result = ActiveResult(result=score)
result.signature = 123
result = ActiveResult(result=score, signature=123)
active_process.postResult(result)
log('ok', len(final_model.estimators_))
return 'ok', len(final_model.estimators_), score
......
......@@ -49,7 +49,6 @@ class Test(ERP5TypeTestCase):
script.ZPythonScript_edit('**kw', """import time
active_process = context.portal_activities.newActiveProcess()
active_process.useBTree()
active_process_id = active_process.getId()
path = active_process.getPhysicalPath()
......@@ -59,8 +58,8 @@ return path""")
path = portal_skins.erp5_joblib.Base_driverScriptRandomForest()
self.tic(1)
active_process = portal_skins.erp5_joblib.portal_activities.unrestrictedTraverse(path)
result = active_process.getResult(123)
self.assertEquals(0.98444444444444446, result.result)
result = active_process.getResultDict()
self.assertEquals(0.98444444444444446, result[123].result)
def test_UnderRootOfSquaresFunction(self):
portal_skins = self.getPortal().portal_skins
......@@ -75,7 +74,6 @@ return path""")
script.ZPythonScript_edit('**kw', """import time
active_process = context.portal_activities.newActiveProcess()
active_process.useBTree()
active_process_id = active_process.getId()
path = active_process.getPhysicalPath()
......@@ -85,6 +83,6 @@ return path""")
path = portal_skins.erp5_joblib.Base_driverScriptSquareRoot()
self.tic(1)
active_process = self.portal.portal_activities.unrestrictedTraverse(path)
result = active_process.getResult(12345)
self.assertEquals([0.0, 1.0, 2.0, 3.0, 4.0], result.result)
result = active_process.getResultDict()
self.assertEquals([0.0, 1.0, 2.0, 3.0, 4.0], result[12345].result)
......@@ -87,7 +87,6 @@ from Products.ERP5Type.patches import ZopePageTemplate
from Products.ERP5Type.patches import ZSQLMethod
from Products.ERP5Type.patches import MimetypesRegistry
from Products.ERP5Type.patches import users
from Products.ERP5Type.patches import JoblibParallelPrint
# These symbols are required for backward compatibility
from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager
......
ENABLE_PATCH = True
try:
import sklearn
#from sklearn.externals import joblib
#from sklearn.externals.joblib.parallel import Parallel
from joblib.parallel import Parallel
except ImportError:
ENABLE_PATCH = False
if ENABLE_PATCH:
from zLOG import LOG, WARNING
def _print(self, msg, msg_args):
msg = msg % msg_args
LOG('Parallel._print', WARNING, '[%s]: %s\n' % (self, msg))
Parallel._print = _print
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment