Skip to content
Snippets Groups Projects
Commit 2493cfe2 authored by Stefano Borini's avatar Stefano Borini
Browse files

Introduced result object and readapted interface for it.

parent a72b036c
No related branches found
No related tags found
Loading
...@@ -35,6 +35,7 @@ class CoreMCODriver(Plugin): ...@@ -35,6 +35,7 @@ class CoreMCODriver(Plugin):
def application_started(self): def application_started(self):
workflow = self.application.workflow workflow = self.application.workflow
if self.application.evaluate: if self.application.evaluate:
ds_results = []
for requested_ds in workflow.data_sources: for requested_ds in workflow.data_sources:
ds_bundle = self._find_data_source_bundle_by_name( ds_bundle = self._find_data_source_bundle_by_name(
requested_ds.name) requested_ds.name)
...@@ -42,7 +43,7 @@ class CoreMCODriver(Plugin): ...@@ -42,7 +43,7 @@ class CoreMCODriver(Plugin):
ds_model = ds_bundle.create_model(requested_ds.model_data) ds_model = ds_bundle.create_model(requested_ds.model_data)
data_source = ds_bundle.create_data_source( data_source = ds_bundle.create_data_source(
self.application, ds_model) self.application, ds_model)
print(data_source.run()) ds_results.append(data_source.run())
else: else:
raise Exception("Requested data source {} but don't know " raise Exception("Requested data source {} but don't know "
"to find it.".format(requested_ds.name)) "to find it.".format(requested_ds.name))
......
import csv import csv
import numpy
from force_bdss.data_sources.base_data_source import BaseDataSource from force_bdss.data_sources.base_data_source import BaseDataSource
from force_bdss.data_sources.data_source_result import DataSourceResult
class CSVExtractorDataSource(BaseDataSource): class CSVExtractorDataSource(BaseDataSource):
...@@ -11,9 +13,11 @@ class CSVExtractorDataSource(BaseDataSource): ...@@ -11,9 +13,11 @@ class CSVExtractorDataSource(BaseDataSource):
continue continue
if rowindex == self.model.row: if rowindex == self.model.row:
return { return DataSourceResult(
self.model.cuba_type: row[self.model.column] originator=self,
} value_types = [self.model.cuba_type],
values=numpy.array(row[self.model.column]).reshape(1,1)
)
return None return None
return None return None
from traits.api import HasTraits, Array, List, String, Instance from traits.api import HasTraits, Array, ArrayOrNone, List, String, Instance
from .base_data_source import BaseDataSource from .base_data_source import BaseDataSource
...@@ -12,9 +12,8 @@ class DataSourceResult(HasTraits): ...@@ -12,9 +12,8 @@ class DataSourceResult(HasTraits):
quality is the level of accuracy of the (e.g.c omputational) method, as quality is the level of accuracy of the (e.g.c omputational) method, as
the importance and reliability of that value. It should be an enumeration the importance and reliability of that value. It should be an enumeration
value such as HIGH, MEDIUM, POOR""" value such as HIGH, MEDIUM, POOR"""
originator = Instance(BaseDataSource) originator = Instance(BaseDataSource)
value_types = List(String) value_types = List(String)
results = Array(shape=(None, None)) values = Array(shape=(None, None))
accuracy = Array(shape=(None, None)) accuracy = ArrayOrNone(shape=(None, None))
quality = Array(shape=(None, None)) quality = ArrayOrNone(shape=(None, None))
...@@ -2,3 +2,4 @@ envisage==4.6.0 ...@@ -2,3 +2,4 @@ envisage==4.6.0
click==6.7 click==6.7
six==1.10.0 six==1.10.0
stevedore==1.24.0 stevedore==1.24.0
numpy=1.12.0
...@@ -21,6 +21,7 @@ setup( ...@@ -21,6 +21,7 @@ setup(
"envisage >= 4.6.0", "envisage >= 4.6.0",
"click >= 6.7", "click >= 6.7",
"stevedore >= 1.24.0", "stevedore >= 1.24.0",
"six >= 1.10.0" "six >= 1.10.0",
"numpy >= 1.12.0",
] ]
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment