diff --git a/force_bdss/cli/tests/fixtures/test_csv.json b/force_bdss/cli/tests/fixtures/test_csv.json index b58994dba80eabeecad2fc886de0b5a377de74b4..1c15b0f07f2bdeee497b41ea655e31fb64b19dff 100644 --- a/force_bdss/cli/tests/fixtures/test_csv.json +++ b/force_bdss/cli/tests/fixtures/test_csv.json @@ -1,38 +1,40 @@ { "version": "1", - "multi_criteria_optimizer": { - "id": "force.bdss.bundles.enthought.dakota", - "model_data": { - "value_types": ["DUMMY"] - } - }, - "data_sources": [ - { - "id": "force.bdss.bundles.enthought.csv_extractor", + "workflow": { + "multi_criteria_optimizer": { + "id": "force.bdss.bundles.enthought.dakota", "model_data": { - "filename": "foo.csv", - "row": 3, - "column": 5, - "cuba_type": "PRESSURE" + "value_types": ["DUMMY"] } }, - { - "id": "force.bdss.bundles.enthought.csv_extractor", - "model_data": { - "filename": "foo.csv", - "row": 3, - "column": 5, - "cuba_type": "PRESSURE" + "data_sources": [ + { + "id": "force.bdss.bundles.enthought.csv_extractor", + "model_data": { + "filename": "foo.csv", + "row": 3, + "column": 5, + "cuba_type": "PRESSURE" + } + }, + { + "id": "force.bdss.bundles.enthought.csv_extractor", + "model_data": { + "filename": "foo.csv", + "row": 3, + "column": 5, + "cuba_type": "PRESSURE" + } } - } - ], - "kpi_calculators": [ - { - "id": "force.bdss.bundles.enthought.kpi_adder", - "model_data": { - "cuba_type_in": "PRESSURE", - "cuba_type_out": "TOTAL_PRESSURE" + ], + "kpi_calculators": [ + { + "id": "force.bdss.bundles.enthought.kpi_adder", + "model_data": { + "cuba_type_in": "PRESSURE", + "cuba_type_out": "TOTAL_PRESSURE" + } } - } - ] + ] + } } diff --git a/force_bdss/cli/tests/fixtures/test_csv_v2.json b/force_bdss/cli/tests/fixtures/test_csv_v2.json index a6963bba7644cf77ece55b383ec72204906d6d8b..2479fa8781ee6c6e16739c43dfa2c7737db04a5b 100644 --- a/force_bdss/cli/tests/fixtures/test_csv_v2.json +++ b/force_bdss/cli/tests/fixtures/test_csv_v2.json @@ -1,3 +1,5 @@ { - "version": "2" + "version": "2", + "workflow": { + } } diff --git a/force_bdss/io/tests/test_workflow_reader.py b/force_bdss/io/tests/test_workflow_reader.py index 46ab12413c13c25797ca4103069a358c103dc5f5..53c73f4032d0802883d4cf8b039a311bfbccaeba 100644 --- a/force_bdss/io/tests/test_workflow_reader.py +++ b/force_bdss/io/tests/test_workflow_reader.py @@ -24,7 +24,8 @@ class TestWorkflowReader(unittest.TestCase): def test_invalid_version(self): data = { - "version": "2" + "version": "2", + "workflow": {} } with self.assertRaises(InvalidVersionException): diff --git a/force_bdss/io/workflow_reader.py b/force_bdss/io/workflow_reader.py index db64510aa89deabf08aaaa4f320fa5d1666252e2..5b4dab2e9aafdb8ab7e0d85a045dc7e171a7b09c 100644 --- a/force_bdss/io/workflow_reader.py +++ b/force_bdss/io/workflow_reader.py @@ -47,12 +47,14 @@ class WorkflowReader(HasStrictTraits): wf = Workflow() try: - wf.multi_criteria_optimizer = self._extract_mco(json_data) - wf.data_sources[:] = self._extract_data_sources(json_data) - wf.kpi_calculators[:] = self._extract_kpi_calculators(json_data) + workflow_data = json_data["workflow"] + wf.multi_criteria_optimizer = self._extract_mco(workflow_data) + wf.data_sources[:] = self._extract_data_sources(workflow_data) + wf.kpi_calculators[:] = self._extract_kpi_calculators(workflow_data) except KeyError as e: logging.exception("Could not read file") - raise InvalidFileException("Could not read file. {}".format(e)) + raise InvalidFileException("Could not read file. " + "Unable to find key {}".format(e)) def _extract_mco(self, json_data): registry = self.bundle_registry