Skip to content
Snippets Groups Projects
Commit 9f13d9cf authored by Stefano Borini's avatar Stefano Borini Committed by GitHub
Browse files

Merge pull request #12 from force-h2020/data-source-result

Data source result
parents 07538967 0d088f2d
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@ class CoreMCODriver(Plugin):
def application_started(self):
workflow = self.application.workflow
if self.application.evaluate:
ds_results = []
for requested_ds in workflow.data_sources:
ds_bundle = self._find_data_source_bundle_by_name(
requested_ds.name)
......@@ -42,7 +43,7 @@ class CoreMCODriver(Plugin):
ds_model = ds_bundle.create_model(requested_ds.model_data)
data_source = ds_bundle.create_data_source(
self.application, ds_model)
print(data_source.run())
ds_results.append(data_source.run())
else:
raise Exception("Requested data source {} but don't know "
"to find it.".format(requested_ds.name))
......
import csv
import numpy
from force_bdss.data_sources.base_data_source import BaseDataSource
from force_bdss.data_sources.data_source_result import DataSourceResult
class CSVExtractorDataSource(BaseDataSource):
......@@ -11,9 +13,12 @@ class CSVExtractorDataSource(BaseDataSource):
continue
if rowindex == self.model.row:
return {
self.model.cuba_type: row[self.model.column]
}
return DataSourceResult(
originator=self,
value_types=[self.model.cuba_type],
values=numpy.array(
row[self.model.column]).reshape(1, 1)
)
return None
return None
......@@ -12,5 +12,8 @@ class BaseDataSource(six.with_metaclass(abc.ABCMeta)):
def name(self):
return self.bundle.name
@abc.abstractmethod
def run(self):
"""Executes the data source evaluation/fetching and returns
the list of results as a DataSourceResult instance."""
pass
from traits.api import HasTraits, Array, ArrayOrNone, List, String, Instance
from .base_data_source import BaseDataSource
class DataSourceResult(HasTraits):
"""Represents the result of a simulator.
It contains the resulting cuba key, the associated uncertainty and the
originating simulator.
Difference between uncertainty and quality: uncertainty is a numerical
value of the value, as in the case of an experimental simulation.
quality is the level of accuracy of the (e.g. computational) method, as
the importance and reliability of that value. It should be an enumeration
value such as HIGH, MEDIUM, POOR"""
originator = Instance(BaseDataSource)
value_types = List(String)
values = Array(shape=(None, None))
accuracy = ArrayOrNone(shape=(None, None))
quality = ArrayOrNone(shape=(None, None))
......@@ -2,3 +2,4 @@ envisage==4.6.0
click==6.7
six==1.10.0
stevedore==1.24.0
numpy==1.12.0
......@@ -21,6 +21,7 @@ setup(
"envisage >= 4.6.0",
"click >= 6.7",
"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