]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Allowing string input for AlgorithmParameters dictionary
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Mon, 15 Jul 2013 09:56:56 +0000 (11:56 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Mon, 15 Jul 2013 09:56:56 +0000 (11:56 +0200)
doc/en/reference.rst
resources/ADAOSchemaCatalog.xml
src/daEficas/generator_adao.py
src/daSalome/daYacsSchemaCreator/infos_daComposant.py
src/daSalome/daYacsSchemaCreator/methods.py

index ca97218861d06827a586d673d43d72d54ce09b51..483139b340e318c5a2b18733be4d758100b07e46 100644 (file)
@@ -38,7 +38,7 @@ different pseudo-types are:
 
 **Dict**
     This indicates a variable that has to be filled by a dictionary, usually
-    given as a script.
+    given either as a string or as a script.
 
 **Function**
     This indicates a variable that has to be filled by a function, usually given
index b8e8ebd70fe20f229dd15c991101627e44a4aafe..350e34f8f0e7ca0fdcdc18c6e543346b1303debc 100644 (file)
@@ -507,6 +507,15 @@ result = None
     <outport name="result" type="SALOME_TYPES/ParametricOutput"/>
   </inline>
 
+  <inline name="CreateDictFromString">
+    <script><code><![CDATA[
+import logging, sys, os
+logging.debug("CREATE Entering in CreateDictFromString")
+dico = eval(dict_in_string)
+]]></code></script>
+    <inport name="dict_in_string" type="string"/>
+  </inline>
+
   <inline name="CreateDictFromScript">
     <script><code><![CDATA[
 import logging, sys, os
index 3ce44bd155b74176ca550954a0a5189a4e80ff80..98dbb990aae706f475968a56bddd3d4cf0d3fe08 100644 (file)
@@ -234,14 +234,23 @@ class AdaoGenerator(PythonGenerator):
 
     data_name = "AlgorithmParameters"
     data_type = "Dict"
-    from_type = "Script"
-    data = self.dictMCVal["__"+self.type_of_study+"__AlgorithmParameters__Dict__data__SCRIPT_DATA__SCRIPT_FILE"]
-
-    self.text_da += data_name + "_config = {} \n"
-    self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n"
-    self.text_da += data_name + "_config['From'] = '" + from_type + "'\n"
-    self.text_da += data_name + "_config['Data'] = '" + data + "'\n"
-    self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
+    from_type = self.dictMCVal["__"+self.type_of_study+"__AlgorithmParameters__Dict__data__FROM"]
+    
+    if from_type == "Script":
+      data = self.dictMCVal["__"+self.type_of_study+"__AlgorithmParameters__Dict__data__SCRIPT_DATA__SCRIPT_FILE"]
+      self.text_da += data_name + "_config = {} \n"
+      self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n"
+      self.text_da += data_name + "_config['From'] = '" + from_type + "'\n"
+      self.text_da += data_name + "_config['Data'] = '" + data + "'\n"
+      self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
+    
+    if from_type == "String":
+      data = self.dictMCVal["__"+self.type_of_study+"__AlgorithmParameters__Dict__data__STRING_DATA__STRING"]
+      self.text_da += data_name + "_config = {} \n"
+      self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n"
+      self.text_da += data_name + "_config['From'] = '" + from_type + "'\n"
+      self.text_da += data_name + "_config['Data'] = '" + data + "'\n"
+      self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
 
   def add_init(self):
 
index 2b901f8c73a6275fc3fd1b444bf762c526a4e69a..e6391de5610027028c98c28c29d5aa34ca3644b3 100644 (file)
@@ -54,7 +54,7 @@ FromNumpyList["Matrix"]               = ["String", "Script"]
 FromNumpyList["ScalarSparseMatrix"]   = ["String", "Script"]
 FromNumpyList["DiagonalSparseMatrix"] = ["String", "Script"]
 FromNumpyList["Function"]             = ["ScriptWithOneFunction", "ScriptWithFunctions", "ScriptWithSwitch", "FunctionDict"]
-FromNumpyList["Dict"]                 = ["Script"]
+FromNumpyList["Dict"]                 = ["String", "Script"]
 
 # -- Infos from daAlgorithms --
 AssimAlgos = [
@@ -173,7 +173,7 @@ DataTypeDict["Matrix"]               = ["String", "Script"]
 DataTypeDict["ScalarSparseMatrix"]   = ["String", "Script"]
 DataTypeDict["DiagonalSparseMatrix"] = ["String", "Script"]
 DataTypeDict["Function"]             = ["ScriptWithOneFunction", "ScriptWithFunctions", "ScriptWithSwitch", "FunctionDict"]
-DataTypeDict["Dict"]                 = ["Script"]
+DataTypeDict["Dict"]                 = ["String", "Script"]
 
 DataTypeDefaultDict = {}
 DataTypeDefaultDict["Vector"]               = "Script"
index 66c30db351501c81a86b3313e9e9ed41ee852333..3dee00e3baab1d6bec3f45eb8cdfe6b738213b9f 100644 (file)
@@ -161,6 +161,28 @@ def create_yacs_proc(study_config):
           back_node.edAddInputPort("init_data", t_pyobj)
           ADAO_Case.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
 
+      if data_config["Type"] == "Dict" and data_config["From"] == "String":
+        # Create node
+        factory_back_node = catalogAd.getNodeFromNodeMap("CreateDictFromString")
+        back_node = factory_back_node.cloneNode("Get" + key)
+        back_node.getInputPort("dict_in_string").edInitPy(data_config["Data"])
+        back_node.edAddOutputPort(key, t_pyobj)
+        back_node_script = back_node.getScript()
+        back_node_script += key + " = dict(dico)\n"
+        back_node_script += "logging.debug(\"Dict is %ss\"%s%s)"%("%","%",key)
+        back_node.setScript(back_node_script)
+        ADAO_Case.edAddChild(back_node)
+        # Connect node with CreateAssimilationStudy
+        CAS_node.edAddInputPort(key, t_pyobj)
+        ADAO_Case.edAddDFLink(back_node.getOutputPort(key), CAS_node.getInputPort(key))
+        # Connect node with InitUserData
+        if key in init_config["Target"]:
+          back_node_script = back_node.getScript()
+          back_node_script = "__builtins__[\"init_data\"] = init_data\n" + back_node_script
+          back_node.setScript(back_node_script)
+          back_node.edAddInputPort("init_data", t_pyobj)
+          ADAO_Case.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
+
       if data_config["Type"] == "Vector" and data_config["From"] == "String":
         # Create node
         factory_back_node = catalogAd.getNodeFromNodeMap("CreateNumpyVectorFromString")