diff --git a/force_bdss/basic_multi_criteria_optimizer.py b/force_bdss/basic_multi_criteria_optimizer.py index 6cac40d1e6584b56c9562e4703b656c12202bc39..5d9088bc0404d6dcc59d4c05f2666b0ef125b601 100644 --- a/force_bdss/basic_multi_criteria_optimizer.py +++ b/force_bdss/basic_multi_criteria_optimizer.py @@ -1,3 +1,5 @@ +import subprocess +import sys from traits.api import provides, HasStrictTraits from force_bdss.i_multi_criteria_optimizers import IMultiCriteriaOptimizer @@ -5,5 +7,9 @@ from force_bdss.i_multi_criteria_optimizers import IMultiCriteriaOptimizer @provides(IMultiCriteriaOptimizer) class BasicMultiCriteriaOptimizer(HasStrictTraits): - def run(self, workflow): - print("Basic multicriteria optimizer in action, {}".format(workflow)) + def run(self, application): + print("Basic multicriteria optimizer in action") + subprocess.check_call([sys.argv[0], "--evaluate", + application.workflow_filepath]) + + diff --git a/force_bdss/bdss_application.py b/force_bdss/bdss_application.py index 62fd89c1bb4264642ebf9d0f179de45570c80f1a..e6abb68250d434c03d1f88ff68fae5b9b6c91141 100644 --- a/force_bdss/bdss_application.py +++ b/force_bdss/bdss_application.py @@ -1,19 +1,25 @@ import json from envisage.api import Application -from traits.api import Unicode -from traits.trait_types import List, Bool, Instance +from traits.api import Unicode, Bool, Instance from force_bdss.workspecs.workflow import Workflow class BDSSApplication(Application): + """Main application for the BDSS. + """ id = "force_bdss.bdss_application" + #: The path of the workflow file to open workflow_filepath = Unicode() + #: Deserialized content of the workflow file. workflow = Instance(Workflow) + #: This flags signals to the application not to execute and orchestrate + #: the MCO, but instead to perform a single evaluation under the + #: coordination of the MCO itself. See design notes for more details. evaluate = Bool() def _workflow_default(self): diff --git a/force_bdss/core_mco_driver.py b/force_bdss/core_mco_driver.py index 8e82a17c5aff59079293f7798f71ad905938fdac..ef1f392966abf8d1dc652040a2785de7804d7571 100644 --- a/force_bdss/core_mco_driver.py +++ b/force_bdss/core_mco_driver.py @@ -8,10 +8,23 @@ from force_bdss.i_multi_criteria_optimizers import IMultiCriteriaOptimizer class CoreMCODriver(Plugin): + """Main plugin that handles the execution of the MCO + or the evaluation. + """ + + # Note: we are forced to declare these extensions points here instead + # of the application object, and this is why we have to use this plugin. + # It is a workaround to an envisage bug that does not find the extension + # points if declared on the application. + + #: A List of the available Multi Criteria Optimizers. + #: This will be populated by MCO plugins. multi_criteria_optimizers = ExtensionPoint( List(IMultiCriteriaOptimizer), id='force_bdss.multi_criteria_optimizers') + #: A list of the available Key Performance Indicator calculators. + #: It will be populated by plugins. key_performance_calculators = ExtensionPoint( List(IKeyPerformanceCalculator), id='force_bdss.key_performance_calculators') @@ -20,7 +33,7 @@ class CoreMCODriver(Plugin): def application_started(self): if self.application.evaluate: for kpi in self.key_performance_calculators: - kpi.run(self.application.workflow) + kpi.run(self.application) else: for mco in self.multi_criteria_optimizers: - mco.run(self.application.workflow) + mco.run(self.application)