Commit 16edca33 authored by Janez K's avatar Janez K

faster subprocess and cross validation execution

parent a0824f74
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain about missing debug-only code:
def __repr__
if self\.debug
if settings\.DEBUG
# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError
# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:
\ No newline at end of file
......@@ -28,3 +28,5 @@ build/
/mothra/mothra.db-journal
celerybeat-schedule
.coverage
htmlcov
\ No newline at end of file
coverage run --source='.' manage.py test
coverage html --omit=workflows/segmine/data/mappings.py
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -21,4 +21,4 @@ class HarfLearner(orngRFCons.RandomForestLearner):
self.learner
class HarfClassifier(orngRFCons.RandomForestClassifier):
#class HarfClassifier(orngRFCons.RandomForestClassifier):
......@@ -19,6 +19,8 @@ if USE_CONCURRENCY:
from workflows.tasks import executeWidgetFunction, executeWidgetProgressBar, executeWidgetStreaming, executeWidgetWithRequest, runWidget, executeWidgetPostInteract
from workflows.engine import WidgetRunner, WorkflowRunner
class WidgetException(Exception):
pass
......@@ -794,16 +796,9 @@ class Widget(models.Model):
""" else run abstract widget function """
outputs = function_to_call(input_dict)
else:
if self.workflow_link.is_for_loop():
""" if this is object is a for loop than true and run;
else false and run workflow """
#print("proper_run_is_for_loop")
self.workflow_link.run_for_loop()
#print self.outputs.all()[0].value
elif self.workflow_link.is_cross_validation():
self.workflow_link.run_cross_validation()
else:
self.workflow_link.run()
wr = WidgetRunner(self,workflow_runner=WorkflowRunner(self.workflow,clean=False),standalone=True)
wr.run()
return
except:
self.error=True
self.running=False
......@@ -885,16 +880,23 @@ class Widget(models.Model):
elif self.type == 'cv_output':
""" if object is an output widget for cross validation,
then read output values and configure parameters"""
print "smo v cv_output"
for i in self.inputs.all():
if not i.parameter:
""" if there is a connection than true and read the output value """
if i.connections.count() > 0:
if i.value is None:
print "1"
i.value = [i.connections.all()[0].output.value]
else:
print "2"
i.value = [i.connections.all()[0].output.value] + i.value
print i.value
#print i.value
i.save()
print "----"
print i.outer_output.value
print "----"
i.outer_output.value.append(i.value)
i.outer_output.save()
self.finished=True
......
......@@ -6,11 +6,46 @@ Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
from workflows.engine import WorkflowRunner, WidgetRunner
from workflows.models import Workflow, Widget
import time
class WorkflowEngineTest(TestCase):
fixtures = ['test_data',]
def test_fast_workflow_runner(self):
w = Workflow.objects.get(name='For loop test')
wr = WorkflowRunner(w)
wr.run()
wid = Widget.objects.get(id=6)
o = wid.outputs.all()[0].value
self.assertEqual(o,[20,40,60,80])
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
def test_fast_workflow_runner_cv(self):
w = Workflow.objects.get(name='Cross test')
wr = WorkflowRunner(w)
wr.run()
wid = Widget.objects.get(id=16)
o = wid.outputs.all()[0].value
self.assertEqual(o,[[[[u'2'], [u'1']], [u'3'], 1],
[[[u'3'], [u'1']], [u'2'], 1],
[[[u'3'], [u'2']], [u'1'], 1]])
class WidgetEngineTest(TestCase):
fixtures = ['test_data2',]
def test_fast_widget_runner(self):
w = Widget.objects.get(id=6)
wr = WidgetRunner(w,workflow_runner=WorkflowRunner(w.workflow,clean=False),standalone=True)
wr.run()
wid = Widget.objects.get(id=6)
o = wid.outputs.all()[0].value
self.assertEqual(o,[20,40,60,80])
def test_fast_widget_runner_cv(self):
w = Widget.objects.get(id=16)
wr = WidgetRunner(w,workflow_runner=WorkflowRunner(w.workflow,clean=False),standalone=True)
wr.run()
wid = Widget.objects.get(id=16)
o = wid.outputs.all()[0].value
self.assertEqual(o,[[[[u'2'], [u'1']], [u'3'], 1],
[[[u'3'], [u'1']], [u'2'], 1],
[[[u'3'], [u'2']], [u'1'], 1]])
\ No newline at end of file
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