From fa5ddddd37ebb713f2de9a1e750b4e94582b8227 Mon Sep 17 00:00:00 2001 From: Andreas Makus <makus.andreas@gmail.com> Date: Wed, 6 Jul 2016 14:09:13 +0200 Subject: [PATCH] started on the graphing function --- pyKADMOS/MDOproblem.py | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/pyKADMOS/MDOproblem.py b/pyKADMOS/MDOproblem.py index 584577ae9..822c1e904 100644 --- a/pyKADMOS/MDOproblem.py +++ b/pyKADMOS/MDOproblem.py @@ -47,13 +47,14 @@ class MDOproblem: # Get input and output files, save in instance self._get_In_Out_Files(KB_files) - # Get Read-Write File, save in instance - self._get_base_file(KB_files) + if self.knowledge_base == "KB_CPACS": + # Get Read-Write File, save in instance + self._get_base_file(KB_files) - ignoreNodes = ['toolspecific'] - self._check_base_against_schema(ignoreNodes) + ignoreNodes = ['toolspecific'] + self._check_base_against_schema(ignoreNodes) - self._validate_InOutXmls() + self._validate_InOutXmls() self._get_function_data() @@ -537,6 +538,28 @@ class MDOproblem: idx += 1 return common_nodes + def _get_function_graph(self, functionName): + """ + This function builds a graph for the indicated function. + :param: functionName + :return: functionGraph + """ + assert isinstance(functionName, basestring), 'Provided function name must be a string!' + # TODO: ensure that function name exists in KB + + DG = nx.DiGraph() + for i in len(self.functionData): + # get function name + # loop through input child nodes + # build tuple of tool and child node, add attributes + # repreat for output + + + + pass + + return + def get_function_graph(self, function_name): """ Function to automatically create the digraph of the function element. @@ -551,9 +574,7 @@ class MDOproblem: function_input_analysis = self.analyze_function_xml(xml_file_input) function_output_analysis = self.analyze_function_xml(xml_file_output) - input_edges = [(function_input_analysis['valued_nodes'][i]['xpath'], - function_input_analysis['properties'][0]['attributes']['tool_name']) - for i in range(len(function_input_analysis['valued_nodes']))] + input_edges = [(function_input_analysis['valued_nodes'][i]['xpath'], function_input_analysis['properties'][0]['attributes']['tool_name']) for i in range(len(function_input_analysis['valued_nodes']))] output_edges = [(function_output_analysis['properties'][0]['attributes']['tool_name'], function_output_analysis['valued_nodes'][i]['xpath']) for i in range(len(function_output_analysis['valued_nodes']))] -- GitLab