How to run multiple analyses automatically?

Hello,

Here is an example describing how to use the Python API of Persalys in order to automatically launch analyses.

One may have several analyses to launch and each analysis is time consuming so it could be nice to launch everything overnight. The problem is that Persalys does not have the possibility to define a list of analysis to be executed one after the other.

However it is possible to use the Python API of Persalys to get the current available analyses of a study and then run the desired analysis.

In the following minimal example, several analyses are defined but not evaluated:

The following code can be copied in the Persalys console to launch automatically all selected analyses (by names):

import persalys
# get the first study opened in Persalys (to be modified if several studies exist in Persalys)
study = persalys.Study.GetInstances()[0]
# Name of the analyses (must match the names in Persalys)
analysis_name_list = ['optimisation_0', 'screening_0', 'sensitivity_0', 'optimisation_1']
# launch the analyses in a for loop
for analysis_name in analysis_name_list:
    analysis = study.getAnalysisByName(analysis_name)
    analysis.run()

I hope this could be useful in your study !

Regards,
Antoine

Great Antoine!
And if one of these analysis is already done, what happens when command “analysis.run()” is executed ?

If the analysis is already done, it will be relaunched but it is possible to check if the analysis has been already launched using this command:

analysis.hasValidResult()

It will return True if results are already available, False otherwise. So it is simple to add a condition before running the analysis.