2 # Copyright (C) 2010 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # Author : André RIBES (EDF R&D)
26 from daYacsSchemaCreator.infos_daComposant import *
30 logging.debug("Arguments are :" + str(args))
32 logging.fatal("Bad number of arguments: you have to provide two arguments (%d given)" % (len(args)))
35 def check_study(study_config):
37 logging.debug("[check_env] study_config : " + str(study_config))
40 if not isinstance(study_config, dict):
41 logging.fatal("Study configuration is not a dictionnary")
45 if "Name" not in study_config:
46 logging.fatal("Cannot found Name in the study configuration")
50 if "Algorithm" not in study_config:
51 logging.fatal("Cannot found Algorithm in the study configuration")
54 if study_config["Algorithm"] not in AssimAlgos:
55 logging.fatal("Algorithm provided is unknow : " + str(study_config["Algorithm"]) +
56 "\n You can choose between : " + str(AssimAlgos))
60 if "Debug" not in study_config:
61 study_config["Debug"] = "0"
63 # Check if all the data is provided
64 for key in AlgoDataRequirements[study_config["Algorithm"]]:
65 if key not in study_config.keys():
66 logging.fatal("Cannot found " + key + " in your study configuration !" +
67 "\n This key is mandatory into a study with " + study_config["Algorithm"] + " algorithm." +
68 "\n " + study_config["Algorithm"] + " requirements are " + str(AlgoDataRequirements[study_config["Algorithm"]]))
72 for key in study_config.keys():
74 check_data(key, study_config[key])
77 if "UserPostAnalysis" in study_config.keys():
78 analysis_config = study_config["UserPostAnalysis"]
79 if "From" not in analysis_config:
80 logging.fatal("UserPostAnalysis found but From is not defined in the analysis configuration !")
83 if analysis_config["From"] not in AnalysisFromList:
84 logging.fatal("Analysis From defined in the study configuration does not have a correct type : " + str(analysis_config["From"])
85 + "\n You can have : " + str(AnalysisFromList))
87 if "Data" not in analysis_config:
88 logging.fatal("Analysis found but Data is not defined in the analysis configuration !")
92 def check_data(data_name, data_config):
94 logging.debug("[check_data] " + data_name)
95 data_name_data = "Data"
96 data_name_type = "Type"
97 data_name_from = "From"
99 if data_name_data not in data_config:
100 logging.fatal(data_name +" found but " + data_name_data +" is not defined in the study configuration !")
103 if data_name_type not in data_config:
104 logging.fatal(data_name +" found but " + data_name_type +" is not defined in the study configuration !")
107 if data_config[data_name_type] not in AssimType[data_name]:
108 logging.fatal(data_name_type + " defined in the study configuration does not have a correct type : " + str(data_config[data_name_type])
109 + "\n You can have : " + str(AssimType[data_name]))
111 if data_name_from not in data_config:
112 logging.fatal(data_name + " found but " + data_name_from + " is not defined in the study configuration !")
115 if data_config[data_name_from] not in FromNumpyList[data_config[data_name_type]]:
116 logging.fatal(data_name_from + " defined in the study configuration does not have a correct value : " + str(data_config[data_name_from])
117 + "\n You can have : " + str(FromNumpyList[data_config[data_name_type]]))