Salome HOME
Add the preprocess feature to SALOME_Launcher.
[modules/kernel.git] / idl / SALOME_Launcher.idl
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef _SALOME_LAUNCHER_IDL_
24 #define _SALOME_LAUNCHER_IDL_
25
26 #include "SALOME_Exception.idl"
27 #include "SALOME_ResourcesManager.idl"
28
29 /*! \file SALOME_Launcher.idl \brief Interfaces for %SALOME Launcher service
30 */
31
32 module Engines
33 {
34
35 //! files list
36 typedef sequence<string> FilesList;
37
38 //! A generic parameter
39 struct Parameter
40 {
41   string name;
42   string value;
43 };
44 //! Generic parameter list
45 typedef sequence<Engines::Parameter> ParameterList;
46
47 struct JobParameters
48 {
49   //! Name of the job.
50   string job_name;
51
52   //! Type of the job.
53   /*! There are three supported types:
54         - "command" : execute #job_file script without %SALOME environment
55         - "python_salome" : execute #job_file python script by %SALOME
56         - "yacs_file" : execute #job_file by YACS module as a xml YACS schema
57   */
58   string job_type;
59
60   // Common values
61   //! Local path to the file to be executed by the job.
62   /*! The type of the file depends on #job_type.
63       If #job_type is "command", the #job_file must be a single filename
64       specifying a self-consistent script to be executed without any argument,
65       on the remote host.
66   */
67   string job_file;
68
69   //! Pre processing command.
70   /*! This command is called on the remote resource, from #work_directory, after
71       the copy of #in_files and before submiting the job.
72   */
73   string pre_command;
74
75   //! Local path to a script to be sourced in the environment of the job.
76   /*! It may contain modifications of environment variables.
77   */
78   string env_file; 
79
80   //! List of local data files to be copied to #work_directory.
81   /*! #job_file and #env_file are automaticaly copied, without adding them
82       to this list. If basenames are specified, then the files are supposed
83       to be located in #local_directory.
84   */
85   FilesList in_files;
86
87   //! List of results to get back at the end of the job.
88   /*! These results can be names of files or directories, produced by the job
89       in #work_directory. Directories will be copied recursively.
90       It is also possible to use an absolute path instead of the simple name,
91       (string beginning with '/') and this absolute path will be used instead
92       of #result_directory when SalomeLauncher::getJobResults is called.
93       \see SalomeLauncher::getJobResults
94   */
95   FilesList out_files;
96
97   //! Remote directory where the job will be executed.
98   /*! It must be used to specify the remote directory where to put all
99       the stuff to run the job. Note that the job will be executed from within
100       this directory. A change directory toward this working directory is done
101       by the batch system before running the job.
102       If not specified (empty string), the launcher will use the working
103       directory of the chosen ressource and if this is also an empty string
104       the value used will be $HOME/Batch/workdir_"date" where $HOME is the
105       value of the environment variable on the remote ressource and "date" is
106       the current date.
107   */
108   string work_directory;
109
110   //! Prefix to be applied to #in_files.
111   /*! It can be used to specify where to find the local input files.
112       It's optionnal if you specify the absolute path name of input files.
113   */
114   string local_directory;
115
116   //! Local directory where to get result files.
117   /*! It must be used to specify where to download the output files on the
118       local file system.
119       If not specified (empty string), the value of $HOME environment variable
120       will be used.
121       \see SalomeLauncher::getJobResults
122   */
123   string result_directory;
124
125   //! Maximum time for the batch execution (expected format : "hh:mm").
126   /*! Could be empty, in this case, default value of the selected resource
127       will be used.
128   */
129   string maximum_duration; 
130
131   //! Specifies the rules to choose the ressource where to execute the job.
132   /*! The additionnal two following parameters MUST be specified explicitly,
133       because they are not provided by the resource definition:
134       - mem_mb -> Memory expressed in megabytes.
135       - nb_proc -> Number of Processors.
136   */
137   ResourceParameters resource_required;
138
139   //!  Name of the batch queue chosen - optional
140   string queue;
141   
142   //! Specifies if the job must run in exclusive mode (without sharing nodes with other jobs)
143   boolean exclusive;
144
145   //! Specifies the memory limit per cpu (exclusive with resource_required.mem_mb)
146   unsigned long mem_per_cpu;
147
148   //! Workload Characterization Key - mandatory on some clusters
149   string wckey;
150
151   //! String that is added to the job submission file - optional
152   string extra_params;
153
154   //! Specific parameters for each type of job - optional
155   /*! This is a list of parameters (key - value pairs of strings) useful in
156       some specific situations.
157       Known parameters:
158       - EnableDumpYACS : value of the "dump" option of the "driver" command
159         when the job type is "yacs_file". It gives the number of seconds
160         between two updates of the state dump file. There will be no dump file
161         if this parameter is missing or if its value is less than 1.
162       - YACSDriverOptions : options of the driver command when the job type is
163         "yacs_file".
164       - LoalLevelerJobType : LL_JOBTYPE.
165   */
166   Engines::ParameterList specific_parameters;
167
168   //! %Parameter for COORM
169   string launcher_file;
170   //! %Parameter for COORM
171   string launcher_args;
172 };
173
174 struct JobDescription
175 {
176   long job_id;
177   Engines::JobParameters job_parameters;
178 };
179 typedef sequence<Engines::JobDescription> JobsList;
180
181 interface SalomeLauncherObserver
182 {
183   void notify(in string event_name, in string event_data);
184 };
185
186 //! Interface of the %salome launcher.
187 /*! This interface is used for interaction with the unique instance
188     of SalomeLauncher.
189     The utilisation of this interface is explained in the YACS documentation,
190     article "Starting a SALOME application in a batch manager".
191     Other examples of use can be found in the modules JOBMANAGER, PARAMETRIC
192     and SMESH (PADDER tool).
193 */
194 interface SalomeLauncher
195 {
196   // Main methods
197   //! Create a job and set its parameters, without launching it.
198   /*! Its state becomes "CREATED".
199       \return job id
200   */
201   long   createJob    (in Engines::JobParameters job_parameters) raises (SALOME::SALOME_Exception);
202
203   //! Launch an already created job (job's state should be "CREATED").
204   /*! Launching the job consists of:
205       - create the working directory on the remote file system
206       - copy the input files into the working directory
207       - launch the pre processing command if one is defined
208       - submit the job to the batch manager
209   */
210   void   launchJob    (in long job_id)                           raises (SALOME::SALOME_Exception);
211
212   //! Get the execution state of the job.
213   /*! \return "CREATED", "IN_PROCESS", "QUEUED", "RUNNING", "PAUSED",
214              "FINISHED" or "FAILED"
215       \see LIBBATCH/src/core/Constants.hxx
216   */
217   string getJobState  (in long job_id)                           raises (SALOME::SALOME_Exception);
218
219   //! Get names or ids of hosts assigned to the job
220   string getAssignedHostnames  (in long job_id)                  raises (SALOME::SALOME_Exception);
221
222   //! Copy the result files from the work directory of the job
223   //! to a local directory.
224   /*! The list of result files is given by the JobParameters::out_files parameter.
225      If a result "file" is a directory, the copy is recursive.
226      The "logs" directory contains the standard and the error outputs of the job.
227      \param job_id    Job id returned by createJob().
228      \param directory Local directory where to copy the results.
229                       If this value is an empty string (""), files will be
230                       copied to the directory given by
231                       JobParameters::result_directory.
232      \see JobParameters
233      \see createJob
234   */
235   void   getJobResults(in long job_id, in string directory)      raises (SALOME::SALOME_Exception);
236
237   //! Try to copy the files named "dumpState*.xml" from the working directory.
238   /*! The file "dumpState_name.xml" can be produced by the execution of a YACS
239       schema and it contains the execution state of the schema.
240       You can activate the creation of this file by adding the parameter
241       "EnableDumpYACS" in JobParameters::specific_parameters when the job
242       is created.
243      \param job_id    Job id returned by createJob().
244      \param directory Local directory where to copy the file.
245                       If this value is an empty string (""), the file will be
246                       copied to the directory given by
247                       JobParameters::result_directory.
248      \return 1 if the copy succeeds.
249      \see JobParameters::specific_parameters
250   */
251   boolean getJobDumpState(in long job_id, in string directory)   raises (SALOME::SALOME_Exception);
252
253   //! Remove the working directory on the remote file system.
254   /*!
255      \param job_id    Job id returned by createJob().
256   */
257   void clearJobWorkingDir(in long job_id) raises (SALOME::SALOME_Exception);
258
259   //! Retrieve one sigle file from the working directory.
260   /*! Use this method if you don't want to copy all the results of the job,
261       for instance if you want to obtain a file which contains the computing
262       progress while the job is running.
263      \param job_id    Job id returned by createJob().
264      \param work_file Path to the file to be copied, relative to the
265                       working directory of the job. If it is a directory,
266                       it will be copied recursively.
267      \param directory Local directory where to copy the file.
268                       If this value is an empty string (""), the file will be
269                       copied to the directory given by
270                       JobParameters::result_directory.
271      \return 1 if the copy succeeds.
272   */
273   boolean getJobWorkFile(in long job_id, in string work_file, in string directory)   raises (SALOME::SALOME_Exception);
274
275   //! Kill the job and set its state to "FAILED"
276   void   stopJob      (in long job_id)                           raises (SALOME::SALOME_Exception);
277   //! Kill the job and remove it from the jobs list
278   void   removeJob    (in long job_id)                           raises (SALOME::SALOME_Exception);
279
280   // Useful methods
281   long    createJobWithFile(in string xmlJobFile, in string clusterName) raises (SALOME::SALOME_Exception);
282   boolean testBatch        (in ResourceParameters params)                raises (SALOME::SALOME_Exception);
283
284   // SALOME kernel service methods
285   //! Shutdow SalomeLauncher server.
286   void Shutdown();
287   //! Get the PID of the current process
288   long getPID();
289
290   // Observer and introspection methods
291   //! Add an observer to be notified of the jobs list modifications
292   void addObserver(in Engines::SalomeLauncherObserver observer);
293   void removeObserver(in Engines::SalomeLauncherObserver observer);
294   Engines::JobsList getJobsList();
295   Engines::JobParameters getJobParameters(in long job_id) raises (SALOME::SALOME_Exception);
296
297   // Save and load methods
298   //! Add to the current jobs list the jobs previously saved in an xml file.
299   void loadJobs(in string jobs_file) raises (SALOME::SALOME_Exception);
300   //! Save the current list of jobs in an xml file.
301   void saveJobs(in string jobs_file) raises (SALOME::SALOME_Exception);
302
303 };
304
305 };
306   
307 #endif