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

Added possibility to create model objects without json data

parent 6ac89a1b
No related branches found
No related tags found
1 merge request!17Add empty initialisation for models
...@@ -11,8 +11,11 @@ from .csv_extractor_data_source import CSVExtractorDataSource ...@@ -11,8 +11,11 @@ from .csv_extractor_data_source import CSVExtractorDataSource
class CSVExtractorBundle(HasStrictTraits): class CSVExtractorBundle(HasStrictTraits):
name = String("csv_extractor") name = String("csv_extractor")
def create_model(self, model_data): def create_model(self, model_data=None):
return CSVExtractorModel.from_json(model_data) if model_data is None:
return CSVExtractorModel()
else:
return CSVExtractorModel.from_json(model_data)
def create_data_source(self, application, model): def create_data_source(self, application, model):
return CSVExtractorDataSource(self, application, model) return CSVExtractorDataSource(self, application, model)
...@@ -11,8 +11,11 @@ from .kpi_adder_calculator import KPIAdderCalculator ...@@ -11,8 +11,11 @@ from .kpi_adder_calculator import KPIAdderCalculator
class KPIAdderBundle(HasStrictTraits): class KPIAdderBundle(HasStrictTraits):
name = String("kpi_adder") name = String("kpi_adder")
def create_model(self, model_data): def create_model(self, model_data=None):
return KPIAdderModel.from_json(model_data) if model_data is None:
return KPIAdderModel()
else:
return KPIAdderModel.from_json(model_data)
def create_data_source(self, application, model): def create_data_source(self, application, model):
return KPIAdderCalculator(self, application, model) return KPIAdderCalculator(self, application, model)
...@@ -14,8 +14,11 @@ from .dakota_optimizer import DakotaOptimizer ...@@ -14,8 +14,11 @@ from .dakota_optimizer import DakotaOptimizer
class DakotaBundle(HasStrictTraits): class DakotaBundle(HasStrictTraits):
name = String("dakota") name = String("dakota")
def create_model(self, model_data): def create_model(self, model_data=None):
return DakotaModel.from_json(model_data) if model_data is None:
return DakotaModel()
else:
return DakotaModel.from_json(model_data)
def create_optimizer(self, application, model): def create_optimizer(self, application, model):
return DakotaOptimizer(self, application, model) return DakotaOptimizer(self, application, model)
......
...@@ -7,5 +7,5 @@ class IDataSourceBundle(Interface): ...@@ -7,5 +7,5 @@ class IDataSourceBundle(Interface):
def create_data_source(self, application, model): def create_data_source(self, application, model):
pass pass
def create_model(self, model_data): def create_model(self, model_data=None):
pass pass
...@@ -7,5 +7,5 @@ class IKPICalculatorBundle(Interface): ...@@ -7,5 +7,5 @@ class IKPICalculatorBundle(Interface):
def create_kpi_calculator(self, application, model): def create_kpi_calculator(self, application, model):
pass pass
def create_model(self, model_data): def create_model(self, model_data=None):
pass pass
...@@ -7,7 +7,7 @@ class IMultiCriteriaOptimizerBundle(Interface): ...@@ -7,7 +7,7 @@ class IMultiCriteriaOptimizerBundle(Interface):
def create_optimizer(self, application, model): def create_optimizer(self, application, model):
pass pass
def create_model(self, model_data): def create_model(self, model_data=None):
pass pass
def create_communicator(self, model_data): def create_communicator(self, model_data):
......
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