pydefx 9.14.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mpmcn.py +154 -0
- pydefx/__init__.py +32 -0
- pydefx/allpurposebuilder.py +56 -0
- pydefx/configuration.py +120 -0
- pydefx/defaultschemabuilder.py +55 -0
- pydefx/localbuilder.py +37 -0
- pydefx/localstudy.py +78 -0
- pydefx/multijobbuilder.py +33 -0
- pydefx/multijobstudy.py +84 -0
- pydefx/parameters.py +169 -0
- pydefx/plugins/jobexecutor.py +130 -0
- pydefx/plugins/lightexecutor.py +40 -0
- pydefx/plugins/localexecutor.py +81 -0
- pydefx/plugins/mainjob.py +56 -0
- pydefx/plugins/pointeval.py +39 -0
- pydefx/plugins/srunexecutor.py +87 -0
- pydefx/pyscript.py +110 -0
- pydefx/pystudy.py +327 -0
- pydefx/salome_proxy.py +88 -0
- pydefx/sample.py +263 -0
- pydefx/samplecsviterator.py +191 -0
- pydefx/samplecsvmanager.py +136 -0
- pydefx/schemas/idefix_pyschema.xml +106 -0
- pydefx/schemas/plugin.py +81 -0
- pydefx/slurmbuilder.py +33 -0
- pydefx/slurmstudy.py +77 -0
- pydefx/studyexception.py +41 -0
- pydefx/studyresult.py +54 -0
- pydefx-9.14.0.dist-info/METADATA +22 -0
- pydefx-9.14.0.dist-info/RECORD +45 -0
- pydefx-9.14.0.dist-info/WHEEL +4 -0
- salome/bin/salome/test/CTestTestfile.cmake +28 -0
- salome/bin/salome/test/cpp/CTestTestfile.cmake +36 -0
- salome/bin/salome/test/cpp/SampleTest +0 -0
- salome/bin/salome/test/cpp/StudyGeneralTest +0 -0
- salome/bin/salome/test/cpp/StudyRestartTest +0 -0
- salome/bin/salome/test/pyexample/CTestTestfile.cmake +25 -0
- salome/bin/salome/test/pyexample/insitu/insituiterator.py +48 -0
- salome/bin/salome/test/pyexample/insitu/insitumanager.py +46 -0
- salome/bin/salome/test/pyexample/runUnitTest.sh +26 -0
- salome/bin/salome/test/pyexample/test_default.py +79 -0
- salome/bin/salome/test/pyexample/test_insitu.py +60 -0
- salome/bin/salome/test/pyexample/test_mpmcn.py +40 -0
- salome/bin/salome/test/pyexample/test_prescript.py +52 -0
- salome/bin/salome/test/pyexample/test_ydefx_base.py +79 -0
pydefx/schemas/plugin.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
from salome.yacs import SALOMERuntime
|
|
2
|
+
import pickle
|
|
3
|
+
import json
|
|
4
|
+
import importlib
|
|
5
|
+
|
|
6
|
+
class myalgosync(SALOMERuntime.OptimizerAlgSync):
|
|
7
|
+
def __init__(self):
|
|
8
|
+
SALOMERuntime.OptimizerAlgSync.__init__(self, None)
|
|
9
|
+
self.started = False
|
|
10
|
+
|
|
11
|
+
def setPool(self,pool):
|
|
12
|
+
"""Must be implemented to set the pool"""
|
|
13
|
+
self.pool=pool
|
|
14
|
+
|
|
15
|
+
def getTCForIn(self):
|
|
16
|
+
"""return typecode of type expected as Input of the internal node """
|
|
17
|
+
return SALOMERuntime.getSALOMERuntime().getTypeCode("string")
|
|
18
|
+
|
|
19
|
+
def getTCForOut(self):
|
|
20
|
+
"""return typecode of type expected as Output of the internal node"""
|
|
21
|
+
return SALOMERuntime.getSALOMERuntime().getTypeCode("string")
|
|
22
|
+
|
|
23
|
+
def getTCForAlgoInit(self):
|
|
24
|
+
"""return typecode of type expected as input for initialize """
|
|
25
|
+
return SALOMERuntime.getSALOMERuntime().getTypeCode("string")
|
|
26
|
+
|
|
27
|
+
def getTCForAlgoResult(self):
|
|
28
|
+
"""return typecode of type expected as output of the algorithm """
|
|
29
|
+
return SALOMERuntime.getSALOMERuntime().getTypeCode("int")
|
|
30
|
+
|
|
31
|
+
def initialize(self,input):
|
|
32
|
+
"""Optional method called on initialization.
|
|
33
|
+
The type of "input" is returned by "getTCForAlgoInit"
|
|
34
|
+
"""
|
|
35
|
+
with open("idefixconfig.json", "r") as f:
|
|
36
|
+
self.config = json.load(f)
|
|
37
|
+
|
|
38
|
+
def start(self):
|
|
39
|
+
"""Start to fill the pool with samples to evaluate."""
|
|
40
|
+
itModuleName = self.config["sampleIterator"]
|
|
41
|
+
itModule = importlib.import_module(itModuleName)
|
|
42
|
+
self.started = True
|
|
43
|
+
self.manager = itModule.SampleIterator()
|
|
44
|
+
self.manager.writeHeaders()
|
|
45
|
+
values=None
|
|
46
|
+
for i in range(0, self.getNbOfBranches()):
|
|
47
|
+
try:
|
|
48
|
+
newid, values = next(self.manager)
|
|
49
|
+
self.pool.pushInSample(newid, pickle.dumps(values, protocol=0).decode())
|
|
50
|
+
except StopIteration:
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
def takeDecision(self):
|
|
54
|
+
""" This method is called each time a sample has been evaluated. It can
|
|
55
|
+
either add new samples to evaluate in the pool, do nothing (wait for
|
|
56
|
+
more samples), or empty the pool to finish the evaluation.
|
|
57
|
+
"""
|
|
58
|
+
currentId=self.pool.getCurrentId()
|
|
59
|
+
samplebyte=self.pool.getCurrentInSample().getStringValue().encode()
|
|
60
|
+
sample = pickle.loads(samplebyte)
|
|
61
|
+
resultbyte=self.pool.getCurrentOutSample().getStringValue().encode()
|
|
62
|
+
error,result = pickle.loads(resultbyte)
|
|
63
|
+
self.manager.addResult(currentId, sample, result, error)
|
|
64
|
+
try:
|
|
65
|
+
newid, values = next(self.manager)
|
|
66
|
+
self.pool.pushInSample(newid, pickle.dumps(values, protocol=0).decode())
|
|
67
|
+
except StopIteration:
|
|
68
|
+
pass
|
|
69
|
+
|
|
70
|
+
def finish(self):
|
|
71
|
+
"""Optional method called when the algorithm has finished, successfully
|
|
72
|
+
or not, to perform any necessary clean up."""
|
|
73
|
+
if self.started :
|
|
74
|
+
self.manager.terminate()
|
|
75
|
+
self.pool.destroyAll()
|
|
76
|
+
|
|
77
|
+
def getAlgoResult(self):
|
|
78
|
+
"""return the result of the algorithm.
|
|
79
|
+
The object returned is of type indicated by getTCForAlgoResult.
|
|
80
|
+
"""
|
|
81
|
+
return 0
|
pydefx/slurmbuilder.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (C) 2019-2024 EDF
|
|
3
|
+
#
|
|
4
|
+
# This library is free software; you can redistribute it and/or
|
|
5
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
6
|
+
# License as published by the Free Software Foundation; either
|
|
7
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
8
|
+
#
|
|
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.
|
|
13
|
+
#
|
|
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
|
|
17
|
+
#
|
|
18
|
+
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
19
|
+
#
|
|
20
|
+
import inspect
|
|
21
|
+
import pathlib
|
|
22
|
+
import os
|
|
23
|
+
from .allpurposebuilder import AllPurposeBuilder
|
|
24
|
+
|
|
25
|
+
class SlurmBuilder(AllPurposeBuilder):
|
|
26
|
+
def __init__(self, executor = None, pointEval = None, mainJob = None):
|
|
27
|
+
filename = inspect.getframeinfo(inspect.currentframe()).filename
|
|
28
|
+
install_root_directory = pathlib.Path(filename).resolve().parent
|
|
29
|
+
install_files_directory = os.path.join(install_root_directory, "plugins")
|
|
30
|
+
|
|
31
|
+
if executor is None:
|
|
32
|
+
executor = os.path.join(install_files_directory, "srunexecutor.py")
|
|
33
|
+
super().__init__(executor, pointEval, mainJob)
|
pydefx/slurmstudy.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (C) 2019-2024 EDF
|
|
3
|
+
#
|
|
4
|
+
# This library is free software; you can redistribute it and/or
|
|
5
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
6
|
+
# License as published by the Free Software Foundation; either
|
|
7
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
8
|
+
#
|
|
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.
|
|
13
|
+
#
|
|
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
|
|
17
|
+
#
|
|
18
|
+
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
19
|
+
#
|
|
20
|
+
import copy
|
|
21
|
+
import os
|
|
22
|
+
import json
|
|
23
|
+
from . import pystudy
|
|
24
|
+
from . import slurmbuilder
|
|
25
|
+
from . import salome_proxy
|
|
26
|
+
from . import configuration
|
|
27
|
+
|
|
28
|
+
class SlurmStudy(pystudy.PyStudy):
|
|
29
|
+
def __init__(self, sampleManager=None, schemaBuilder=None):
|
|
30
|
+
if schemaBuilder is None:
|
|
31
|
+
schemaBuilder = slurmbuilder.SlurmBuilder()
|
|
32
|
+
super().__init__(sampleManager, schemaBuilder)
|
|
33
|
+
|
|
34
|
+
def createNewJob(self, script, sample, params):
|
|
35
|
+
# TODO: modifier le copier/coller
|
|
36
|
+
self._check(script,sample)
|
|
37
|
+
self.sample = sample
|
|
38
|
+
self.params = copy.deepcopy(params)
|
|
39
|
+
main_job_work_dir = self.params.salome_parameters.result_directory
|
|
40
|
+
if not os.path.exists(main_job_work_dir):
|
|
41
|
+
os.makedirs(main_job_work_dir)
|
|
42
|
+
# set the parameters of the local job
|
|
43
|
+
self.params.salome_parameters.job_type = self.jobType()
|
|
44
|
+
|
|
45
|
+
result_directory = self.params.salome_parameters.result_directory
|
|
46
|
+
# export sample to result_directory
|
|
47
|
+
inputFiles = self.sampleManager.prepareRun(self.sample, result_directory)
|
|
48
|
+
inputFiles.extend([self.schemaBuilder.getExecutor(),
|
|
49
|
+
self.schemaBuilder.getPointEval()])
|
|
50
|
+
self.params.salome_parameters.job_file = self.schemaBuilder.getMainJob()
|
|
51
|
+
|
|
52
|
+
# export config
|
|
53
|
+
dicconfig = {}
|
|
54
|
+
dicconfig["nbbranches"] = self.params.nb_branches
|
|
55
|
+
dicconfig["studymodule"] = "idefixstudy"
|
|
56
|
+
dicconfig["sampleIterator"] = self.sampleManager.getModuleName()
|
|
57
|
+
dicconfig["plugin"] = self.schemaBuilder.getPluginName()
|
|
58
|
+
nbproc = self.params.salome_parameters.resource_required.nb_proc
|
|
59
|
+
dicconfig["tasksPerEval"] = nbproc // self.params.nb_branches
|
|
60
|
+
configpath = configuration.exportConfig(dicconfig, result_directory)
|
|
61
|
+
studypath = os.path.join(result_directory, "idefixstudy.py")
|
|
62
|
+
with open(studypath, "w") as f:
|
|
63
|
+
f.write(script.script)
|
|
64
|
+
|
|
65
|
+
inputFiles.extend([configpath, studypath])
|
|
66
|
+
|
|
67
|
+
# this list manipulation is needed because in_files is not a python list
|
|
68
|
+
# if we don't use a salome session. In that case swig uses a python tuple
|
|
69
|
+
# in order to map a std::list as a parameter of a structure.
|
|
70
|
+
in_files_as_list = list(self.params.salome_parameters.in_files)
|
|
71
|
+
self.params.salome_parameters.in_files = in_files_as_list + inputFiles
|
|
72
|
+
launcher = salome_proxy.getLauncher()
|
|
73
|
+
self.job_id = launcher.createJob(self.params.salome_parameters)
|
|
74
|
+
return self.job_id
|
|
75
|
+
|
|
76
|
+
def jobType(self):
|
|
77
|
+
return "command_salome"
|
pydefx/studyexception.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (C) 2019-2024 EDF
|
|
3
|
+
#
|
|
4
|
+
# This library is free software; you can redistribute it and/or
|
|
5
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
6
|
+
# License as published by the Free Software Foundation; either
|
|
7
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
8
|
+
#
|
|
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.
|
|
13
|
+
#
|
|
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
|
|
17
|
+
#
|
|
18
|
+
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
class StudyException(Exception):
|
|
22
|
+
"""
|
|
23
|
+
Root of exceptions raised by a study.
|
|
24
|
+
"""
|
|
25
|
+
def __init__(self, message):
|
|
26
|
+
super().__init__(message)
|
|
27
|
+
|
|
28
|
+
class StudyUseException(StudyException):
|
|
29
|
+
"""
|
|
30
|
+
Exception used when there is a bad utilisation of the study - functions called
|
|
31
|
+
in a wrong order.
|
|
32
|
+
"""
|
|
33
|
+
def __init__(self, message):
|
|
34
|
+
super().__init__(message)
|
|
35
|
+
|
|
36
|
+
class StudyRunException(StudyException):
|
|
37
|
+
"""
|
|
38
|
+
Exception used when there is a problem when running the study.
|
|
39
|
+
"""
|
|
40
|
+
def __init__(self, message):
|
|
41
|
+
super().__init__(message)
|
pydefx/studyresult.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (C) 2019-2024 EDF
|
|
3
|
+
#
|
|
4
|
+
# This library is free software; you can redistribute it and/or
|
|
5
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
6
|
+
# License as published by the Free Software Foundation; either
|
|
7
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
8
|
+
#
|
|
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.
|
|
13
|
+
#
|
|
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
|
|
17
|
+
#
|
|
18
|
+
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
class StudyResult:
|
|
22
|
+
"""
|
|
23
|
+
This class gathers global information about the execution of the study (global
|
|
24
|
+
errors, global result).
|
|
25
|
+
"""
|
|
26
|
+
def __init__(self):
|
|
27
|
+
self.result = None
|
|
28
|
+
self.exit_code = None
|
|
29
|
+
self.error_message = None
|
|
30
|
+
|
|
31
|
+
def isExitCodeAvailable(self):
|
|
32
|
+
return not self.exit_code is None
|
|
33
|
+
|
|
34
|
+
def getExitCode(self):
|
|
35
|
+
return self.exit_code
|
|
36
|
+
|
|
37
|
+
def isResultAvailable(self):
|
|
38
|
+
return not self.exit_code is None
|
|
39
|
+
|
|
40
|
+
def getResult(self):
|
|
41
|
+
return self.result
|
|
42
|
+
|
|
43
|
+
def hasErrors(self):
|
|
44
|
+
return not self.error_message is None and len(self.error_message) > 0
|
|
45
|
+
|
|
46
|
+
def getErrors(self):
|
|
47
|
+
return self.error_message
|
|
48
|
+
|
|
49
|
+
def __str__(self):
|
|
50
|
+
result = """Exit code : {}
|
|
51
|
+
Error message : {}
|
|
52
|
+
Result:
|
|
53
|
+
{}""".format(self.exit_code, self.error_message, self.result)
|
|
54
|
+
return result
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 1.2
|
|
2
|
+
Name: pydefx
|
|
3
|
+
Version: 9.14.0
|
|
4
|
+
Summary: tool for parametric computations of SALOME platform
|
|
5
|
+
Home-page: https://github.com/SalomePlatform/ydefx
|
|
6
|
+
Author: EDF R&D
|
|
7
|
+
Author-email: eric.fayolle@edf.fr
|
|
8
|
+
License: LGPL
|
|
9
|
+
Keywords: salome
|
|
10
|
+
Platform: any
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
|
|
13
|
+
Classifier: Programming Language :: C++
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Requires-Dist: salome.yacs
|
|
18
|
+
|
|
19
|
+
pydefx
|
|
20
|
+
======
|
|
21
|
+
|
|
22
|
+
Ydefx library is a tool to make parametric computations on distributed resources.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
./mpmcn.py,sha256=gv8Tl8oSBsUhH2EuqPGDlaegxtk_rUyizvysmAt3sQ8=,6649
|
|
2
|
+
./salome/bin/salome/test/CTestTestfile.cmake,sha256=Kg2sTm7DL9mWjhYDrPz3UXjBG1Jcn9bjQGqAkD47PiA=,1022
|
|
3
|
+
./salome/bin/salome/test/cpp/StudyGeneralTest,sha256=ZlXHlIVRMqVNFgGEFI9M_qEJp-Jbf0fzwQU2QqZRgfY=,216048
|
|
4
|
+
./salome/bin/salome/test/cpp/SampleTest,sha256=I8fCA8klhOmWNStSvv2djHd0NImpr-LB_NQSA1GVo8g=,280496
|
|
5
|
+
./salome/bin/salome/test/cpp/CTestTestfile.cmake,sha256=JjSkD4flyDAd4ENPkzPXvsgaVU1X9bfxgnWCdbGqFV4=,1492
|
|
6
|
+
./salome/bin/salome/test/cpp/StudyRestartTest,sha256=rrvAMCz3rLtUbvhG8dxKcee1PJSxUHePYdySG0oZK8Y=,112976
|
|
7
|
+
./salome/bin/salome/test/pyexample/test_ydefx_base.py,sha256=BXl-Zsu6YoMfZBZUYSY2xDPJq3SnAapDyKLWWQO3CuY=,3548
|
|
8
|
+
./salome/bin/salome/test/pyexample/test_default.py,sha256=CpDNuLT2BEL8pzjXDUnVb6zJzehu7FIp8WCGxSs56lg=,2114
|
|
9
|
+
./salome/bin/salome/test/pyexample/CTestTestfile.cmake,sha256=hsdRpK-RznugDLCDWYm3ga_j7Z6w26PLTU5cd-Rze_0=,1078
|
|
10
|
+
./salome/bin/salome/test/pyexample/runUnitTest.sh,sha256=0szCXwZm5zXMhzvZ6ac-Sfv9qH0BEjyiTsApXPPZRPw=,1010
|
|
11
|
+
./salome/bin/salome/test/pyexample/test_prescript.py,sha256=d95SazPsqfCsygFQhE2hjDcPfiY_0amVgOpC31p29Lc=,1527
|
|
12
|
+
./salome/bin/salome/test/pyexample/test_mpmcn.py,sha256=yMzcSfB2cec92MPI0vF_s1x7N_Ujwh1X3QOeOvltn0s=,1168
|
|
13
|
+
./salome/bin/salome/test/pyexample/test_insitu.py,sha256=FI7xe_cCHotAwbHRWyorV-piW7qPG8KH60AqkWkaZqw=,1581
|
|
14
|
+
./salome/bin/salome/test/pyexample/insitu/insituiterator.py,sha256=Ya7O4NAdP1TNMlCV3_VFbhXI4guKdhiJJj9-I3Df4y8=,1890
|
|
15
|
+
./salome/bin/salome/test/pyexample/insitu/insitumanager.py,sha256=iLjGJxUOekyc-6cmYWVhMGqNHO4mdpQVrNBH8Fmn9Z0=,1844
|
|
16
|
+
./pydefx/studyexception.py,sha256=sBnASgZxLNKG0PlAtycRqgGPYw6YSwN2FDwCh7l3SDw=,1407
|
|
17
|
+
./pydefx/pyscript.py,sha256=B9W699pfHSVrBvwXNV3Hg5ulBcaE_F1cEaAlB6fT60o=,3895
|
|
18
|
+
./pydefx/localbuilder.py,sha256=YpRU6G8_xreNWClJo1CPdTt2k-ptFgV9uI1DopUILqk=,1728
|
|
19
|
+
./pydefx/multijobbuilder.py,sha256=xN5cBTlTJelXqD-5NGUtPNo6gPT6r70hVsKN6zrxKBE=,1435
|
|
20
|
+
./pydefx/sample.py,sha256=sdRnnSjNFNaG2c9lF89EXOVIpygtn7rNRZx5N_u-kMA=,8201
|
|
21
|
+
./pydefx/samplecsviterator.py,sha256=OSrpK9pmFAYh_nN10KfNfSmlmw_LR1ZymKcJKE-w8hg=,7323
|
|
22
|
+
./pydefx/defaultschemabuilder.py,sha256=fXApmYOAxiI0Esb1CpQ67kfv48YtSWa4MrZADnZlWjM=,2204
|
|
23
|
+
./pydefx/multijobstudy.py,sha256=BbZC-Wj-YR-86L3AZTHeVcDaAtji26XmlQ8vCTZEikk=,3583
|
|
24
|
+
./pydefx/allpurposebuilder.py,sha256=yKHHeukvZj35iV3tVLesfBEwumc-r4-1jNM4DqHlIL4=,2030
|
|
25
|
+
./pydefx/slurmstudy.py,sha256=i8qg89__V7g3YCr2gMg4ccQjeEl6bNbpsCMRtzS2wZU=,3257
|
|
26
|
+
./pydefx/salome_proxy.py,sha256=F3IPIzr39wTig-_A6eaFoFN-BNEETpX368GzoGeRweg=,2484
|
|
27
|
+
./pydefx/parameters.py,sha256=OxJMnO5TodrWv_RYHp_kK6ATmUc3bwX0XqlK4JG0deQ=,10542
|
|
28
|
+
./pydefx/slurmbuilder.py,sha256=KNVAU6KRYt58qBM4drXwTbH0TreFcsBWPD87XRTnYoE=,1433
|
|
29
|
+
./pydefx/configuration.py,sha256=yxo18DwSbj3xD_jhgmw1OrVARfdPIkUbTabw_I0Amuc=,4489
|
|
30
|
+
./pydefx/localstudy.py,sha256=31h1SSFl7tUS6TjAy58RQggiKaaTSE4cg0nJbGpQ0BE=,3260
|
|
31
|
+
./pydefx/pystudy.py,sha256=hk6d5ONBn1hStYIOba7zmrc9xYvszNLJZITt3dj5D2c=,12680
|
|
32
|
+
./pydefx/studyresult.py,sha256=Zry29oVglnhNX_zYM4hDnIbXPiGcnWPw-8WbNY8JSCo=,1657
|
|
33
|
+
./pydefx/samplecsvmanager.py,sha256=RItHOCQc72O6fv-siSNF1f9iPi5eU3oqyzHGplRQroE=,5531
|
|
34
|
+
./pydefx/__init__.py,sha256=b6X6ep9xIcL55miqh5VSPaiA3MCfjsD7ZfcJ_yEucFU=,1367
|
|
35
|
+
./pydefx/plugins/mainjob.py,sha256=qAKBgLACvFefvwkP8C_ntiNBbvlj9-T1sSVqr2cQxao=,1584
|
|
36
|
+
./pydefx/plugins/pointeval.py,sha256=irnGedatMCIVZTFlhYG3rvwqrPrJo5uZVPpvC48vEmI=,937
|
|
37
|
+
./pydefx/plugins/localexecutor.py,sha256=UwSPKHGHbLJIbvUyTYp0XLwxoFuq9-lkrbSCtLRuf5w=,2338
|
|
38
|
+
./pydefx/plugins/lightexecutor.py,sha256=75Hmd_QVL1ndBkcxEOQWpb68MmuNS0TZvvAU0hEmxuk=,953
|
|
39
|
+
./pydefx/plugins/jobexecutor.py,sha256=BQGk-xV3ruuCj5T8cKb1AOAvfsPRMMee2RFAcTVdwn0=,4610
|
|
40
|
+
./pydefx/plugins/srunexecutor.py,sha256=FjOyRauhQeK30Yfa59D9F5OgoQdjVz-a4-1WXRzupMY=,2603
|
|
41
|
+
./pydefx/schemas/plugin.py,sha256=S5TI2EvYtOhEPIAJp3KN1L5ySD6rBvPHJaxmLW_bBAE=,2882
|
|
42
|
+
./pydefx/schemas/idefix_pyschema.xml,sha256=0jE6Ml6ieEyB-4Gm1FWkujohgrdUvY2kBdyqRiPflUs=,4393
|
|
43
|
+
./pydefx-9.14.0.dist-info/METADATA,sha256=w2cJaLYCNx-ofb7ml50cGY8NvsSOAuAdDdwOGPnlBGU=,727
|
|
44
|
+
./pydefx-9.14.0.dist-info/WHEEL,sha256=toYQVYYf5C9LeESCm2UcHbMMqDwSAVkkAchMdEqcWys=,78
|
|
45
|
+
./pydefx-9.14.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright (C) 2019-2024 EDF
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16
|
+
#
|
|
17
|
+
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
SET(SALOME_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/salome_test_driver.py")
|
|
21
|
+
|
|
22
|
+
SET(COMPONENT_NAME YDEFX)
|
|
23
|
+
SET(TIMEOUT 500)
|
|
24
|
+
|
|
25
|
+
SUBDIRS(
|
|
26
|
+
cpp
|
|
27
|
+
pyexample
|
|
28
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (C) 2019-2024 EDF
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16
|
+
#
|
|
17
|
+
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
SET(TEST_NAME ${COMPONENT_NAME}_SampleTest)
|
|
21
|
+
ADD_TEST(${TEST_NAME} ./SampleTest)
|
|
22
|
+
SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
|
|
23
|
+
LABELS "${COMPONENT_NAME}"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
SET(TEST_NAME ${COMPONENT_NAME}_StudyGeneralTest)
|
|
27
|
+
ADD_TEST(${TEST_NAME} ./StudyGeneralTest)
|
|
28
|
+
SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
|
|
29
|
+
LABELS "${COMPONENT_NAME}"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
SET(TEST_NAME ${COMPONENT_NAME}_StudyRestartTest)
|
|
33
|
+
ADD_TEST(${TEST_NAME} ./StudyRestartTest)
|
|
34
|
+
SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
|
|
35
|
+
LABELS "${COMPONENT_NAME}"
|
|
36
|
+
)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright (C) 2019-2024 EDF
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16
|
+
#
|
|
17
|
+
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
SET(TEST_NAME ${COMPONENT_NAME}_PyExampleTest)
|
|
21
|
+
ADD_TEST(${TEST_NAME} ./runUnitTest.sh)
|
|
22
|
+
SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
|
|
23
|
+
LABELS "${COMPONENT_NAME}"
|
|
24
|
+
)
|
|
25
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Copyright (C) 2019-2024 EDF
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16
|
+
#
|
|
17
|
+
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
# The following import is made in the execution environment and in the working
|
|
21
|
+
# directory of the job.
|
|
22
|
+
import samplecsviterator
|
|
23
|
+
import os
|
|
24
|
+
|
|
25
|
+
class SampleIterator(samplecsviterator.SampleIterator):
|
|
26
|
+
"""
|
|
27
|
+
Example of an iterator which uses insitu computation.
|
|
28
|
+
"""
|
|
29
|
+
def __init__(self, directory=None):
|
|
30
|
+
super().__init__(directory)
|
|
31
|
+
self.insitu_result = 0
|
|
32
|
+
|
|
33
|
+
def addResult(self, currentId, currentInput, currentOutput, currentError):
|
|
34
|
+
"""
|
|
35
|
+
currentId : integer. Index of the curent point.
|
|
36
|
+
currentInput : dictionary of curent input values (name, value)
|
|
37
|
+
currentOutput: tuple with the output values
|
|
38
|
+
currentError : string. Empty if no error.
|
|
39
|
+
"""
|
|
40
|
+
super().addResult(currentId, currentInput, currentOutput, currentError)
|
|
41
|
+
value_of_interest = currentOutput
|
|
42
|
+
self.insitu_result = self.insitu_result + value_of_interest
|
|
43
|
+
|
|
44
|
+
def terminate(self):
|
|
45
|
+
super().terminate()
|
|
46
|
+
result_file = os.path.join(self.result_directory, "insitu_result.txt")
|
|
47
|
+
with open(result_file, "w") as f:
|
|
48
|
+
f.write(repr(self.insitu_result))
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright (C) 2019-2024 EDF
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16
|
+
#
|
|
17
|
+
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
import pydefx.samplecsvmanager
|
|
21
|
+
import inspect
|
|
22
|
+
import os
|
|
23
|
+
import pathlib
|
|
24
|
+
|
|
25
|
+
class InsituManager(pydefx.samplecsvmanager.SampleManager):
|
|
26
|
+
def prepareRun(self, sample, directory):
|
|
27
|
+
files_list = super().prepareRun(sample, directory)
|
|
28
|
+
# add the insituiterator file to the list
|
|
29
|
+
filename = inspect.getframeinfo(inspect.currentframe()).filename
|
|
30
|
+
install_directory = pathlib.Path(filename).resolve().parent
|
|
31
|
+
iteratorFile = os.path.join(install_directory, "insituiterator.py")
|
|
32
|
+
files_list.append(iteratorFile)
|
|
33
|
+
return files_list
|
|
34
|
+
|
|
35
|
+
def loadResult(self, sample, directory):
|
|
36
|
+
super().loadResult(sample, directory)
|
|
37
|
+
# load the insitu result and return it
|
|
38
|
+
insitu_result_file = os.path.join(directory,
|
|
39
|
+
self.getResultFileName(),
|
|
40
|
+
"insitu_result.txt")
|
|
41
|
+
with open(insitu_result_file, "r") as f:
|
|
42
|
+
result_string = f.read()
|
|
43
|
+
return eval(result_string)
|
|
44
|
+
|
|
45
|
+
def getModuleName(self):
|
|
46
|
+
return "insituiterator"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Copyright (C) 2019-2024 EDF
|
|
3
|
+
#
|
|
4
|
+
# This library is free software; you can redistribute it and/or
|
|
5
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
6
|
+
# License as published by the Free Software Foundation; either
|
|
7
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
8
|
+
#
|
|
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.
|
|
13
|
+
#
|
|
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
|
|
17
|
+
#
|
|
18
|
+
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
python3 -m unittest test_insitu.py test_prescript.py test_default.py test_ydefx_base.py
|
|
22
|
+
ret0=$?
|
|
23
|
+
python3 test_mpmcn.py
|
|
24
|
+
ret1=$?
|
|
25
|
+
let ret=$ret0+$ret1
|
|
26
|
+
exit $ret
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
import os
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
class TestYdefx(unittest.TestCase):
|
|
6
|
+
def test_errors(self):
|
|
7
|
+
"""
|
|
8
|
+
Test errors in study script.
|
|
9
|
+
"""
|
|
10
|
+
import pydefx
|
|
11
|
+
|
|
12
|
+
myScript = pydefx.PyScript()
|
|
13
|
+
myScript.loadString("a=5")
|
|
14
|
+
self.assertIn("not accepted statement", myScript.getErrors())
|
|
15
|
+
|
|
16
|
+
myScript.loadString("n'importe quoi!")
|
|
17
|
+
self.assertIn("SyntaxError", myScript.getErrors())
|
|
18
|
+
|
|
19
|
+
myScript.loadString("")
|
|
20
|
+
self.assertIn("Function _exec not found", myScript.getErrors())
|
|
21
|
+
|
|
22
|
+
with self.assertRaises(pydefx.pyscript.PyScriptException):
|
|
23
|
+
mySample = myScript.CreateEmptySample()
|
|
24
|
+
|
|
25
|
+
def test_availableResources(self):
|
|
26
|
+
import pydefx
|
|
27
|
+
lr = pydefx.configuration.availableResources()
|
|
28
|
+
self.assertIn('localhost', lr)
|
|
29
|
+
|
|
30
|
+
def test_invalid_study(self):
|
|
31
|
+
import pydefx
|
|
32
|
+
myParams = pydefx.Parameters()
|
|
33
|
+
myParams.configureResource("localhost")
|
|
34
|
+
myScript = pydefx.PyScript()
|
|
35
|
+
myStudy = pydefx.PyStudy()
|
|
36
|
+
|
|
37
|
+
myScript.loadString("wrong 'script")
|
|
38
|
+
mySample = pydefx.Sample([],[])
|
|
39
|
+
try:
|
|
40
|
+
myStudy.createNewJob(myScript, mySample, myParams)
|
|
41
|
+
self.fail("Excpected pydefx.pyscript.PyScriptException!")
|
|
42
|
+
except pydefx.pyscript.PyScriptException:
|
|
43
|
+
pass
|
|
44
|
+
except pydefx.studyexception.StudyException:
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
script="""
|
|
48
|
+
def _exec():
|
|
49
|
+
x=5
|
|
50
|
+
return x
|
|
51
|
+
"""
|
|
52
|
+
myScript.loadString(script)
|
|
53
|
+
try:
|
|
54
|
+
myStudy.createNewJob(myScript, mySample, myParams)
|
|
55
|
+
self.fail("Excpected pydefx.studyexception.StudyUseException!")
|
|
56
|
+
except pydefx.studyexception.StudyException:
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
script="""
|
|
60
|
+
def _exec(a):
|
|
61
|
+
x=5
|
|
62
|
+
return x
|
|
63
|
+
"""
|
|
64
|
+
myScript.loadString(script)
|
|
65
|
+
try:
|
|
66
|
+
myStudy.createNewJob(myScript, mySample, myParams)
|
|
67
|
+
self.fail("Excpected pydefx.studyexception.StudyUseException!")
|
|
68
|
+
except pydefx.studyexception.StudyException:
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
mySample = pydefx.Sample(["b"],[])
|
|
72
|
+
try:
|
|
73
|
+
myStudy.createNewJob(myScript, mySample, myParams)
|
|
74
|
+
self.fail("Excpected pydefx.studyexception.StudyUseException!")
|
|
75
|
+
except pydefx.studyexception.StudyException:
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
if __name__ == '__main__':
|
|
79
|
+
unittest.main()
|