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

Added some documentation

parent cf21e91e
No related branches found
No related tags found
1 merge request!29Extract io layer to writer/reader class
......@@ -3,6 +3,11 @@ import six
class BaseDataSource(six.with_metaclass(abc.ABCMeta)):
"""Base class for the DataSource, any computational engine/retriever
for data.
Inherit from this class for your specific DataSource.
"""
def __init__(self, bundle, application, model):
self.bundle = bundle
self.application = application
......
......@@ -4,6 +4,15 @@ from .i_data_source_bundle import IDataSourceBundle
class BaseDataSourceModel(ABCHasStrictTraits):
"""Base class for the bundle specific DataSource models.
This model will also provide, through traits/traitsui magic the View
that will appear in the workflow manager UI.
In your bundle definition, your bundle-specific model must reimplement
this class.
"""
#: A reference to the creating bundle, so that we can
#: retrieve it as the originating factory.
bundle = Instance(IDataSourceBundle, visible=False, transient=True)
def __init__(self, bundle, *args, **kwargs):
......
......@@ -10,7 +10,12 @@ class IDataSourceBundle(Interface):
name = String()
def create_data_source(self, application, model):
"""Factory method.
Must return the bundle-specific BaseDataSource instance.
"""
pass
def create_model(self, model_data=None):
pass
"""Factory method.
Must return the bundle-specific BaseDataSourceModel instance.
"""
......@@ -3,7 +3,20 @@ from traits.api import HasStrictTraits
class WorkflowWriter(HasStrictTraits):
"""A Writer for writing the Workflow onto disk.
"""
def write(self, workflow, f):
"""Writes the workflow model object to a file f in JSON format.
Parameters
----------
workflow: Workflow
The Workflow instance to write to file
f: File
A file object on which to write the workflow, properly serialized
into JSON.
"""
data = {
"version": "1",
"workflow": {}
......
......@@ -4,6 +4,15 @@ from .i_kpi_calculator_bundle import IKPICalculatorBundle
class BaseKPICalculatorModel(ABCHasStrictTraits):
"""Base class for the bundle specific KPI calculator models.
This model will also provide, through traits/traitsui magic the View
that will appear in the workflow manager UI.
In your bundle definition, your bundle-specific model must reimplement
this class.
"""
#: A reference to the creating bundle, so that we can
#: retrieve it as the originating factory.
bundle = Instance(IKPICalculatorBundle, visible=False, transient=True)
def __init__(self, bundle, *args, **kwargs):
......
......@@ -4,8 +4,18 @@ from .i_multi_criteria_optimizer_bundle import IMultiCriteriaOptimizerBundle
class BaseMCOModel(ABCHasStrictTraits):
"""Base class for the bundle specific MCO models.
This model will also provide, through traits/traitsui magic the View
that will appear in the workflow manager UI.
In your bundle definition, your bundle-specific model must reimplement
this class.
"""
#: A reference to the creating bundle, so that we can
#: retrieve it as the originating factory.
bundle = Instance(IMultiCriteriaOptimizerBundle,
visible=False, transient=True)
visible=False,
transient=True)
def __init__(self, bundle, *args, **kwargs):
self.bundle = bundle
......
......@@ -6,6 +6,15 @@ from ..mco.base_mco_model import BaseMCOModel
class Workflow(HasStrictTraits):
"""Model object that represents the Workflow as a whole"""
#: Contains the bundle-specific MCO Model object.
#: Can be None if no MCO has been specified yet.
multi_criteria_optimizer = Instance(BaseMCOModel, allow_none=True)
#: Contains the bundle-specific DataSource Model objects.
#: The list can be empty
data_sources = List(BaseDataSourceModel)
#: Contains the bundle-specific KPI Calculator Model objects.
#: The list can be empty
kpi_calculators = List(BaseKPICalculatorModel)
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