blib/lib/HPCI.pm

filter: Statementstmt 90.4% 19 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 92.8% 26 / 28 CC 1 SCAR 0.4
CC
1
Cov
90%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/HPCI/File.pm ↑ Summary blib/lib/HPCI/Subgroup.pm »
1 package HPCI;
2 ### HPCI.pm ###################################################################
3  
4 ### INCLUDES ##################################################################
5  
6 # safe Perl
7 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 22 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 22 ▶use Module::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 22 ▶use Module::Load::Conditional qw(can_load);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 22 ▶use List::MoreUtils qw(uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 22 ▶use HPCI::Subgroup;
Subroutine BEGIN: called CC=1 SCAR=2.6
14  
15 our @extra_roles;
16  
17 sub add_extra_role {
18 # next line is documentation
19 # my ($cluster, $level, $role) = @_;
20 shift; # get rid of HPCI class name
21 push @extra_roles, [ @_ ];
22 }
23  
24 sub get_extra_roles {
25 my ($target_cluster, $target_level) = @_;
26 my @roles;
27 for my $role_bunch (@extra_roles) {
28 my ($cluster, $level, $roles) = @$role_bunch;
29 next unless $cluster eq 'ALL' || $cluster eq $target_cluster;
30 next unless $level eq $target_level;
31 push @roles, ref $roles ? @$roles : $roles;
32 }
33 return @roles;
34 }
35  
36 my $default_attrs = {};
37  
38 sub add_default_attrs {
39 shift; # get rid of HPCI class name
40 my $newhash = ref($_[0]) eq 'HASH' ? shift : { @_ };
41 _merge_hash( $default_attrs, $newhash );
42 }
43  
44 sub _merge_hash {
45 my( $target, $new, $path ) = @_;
46 $path ||= [];
47 croak "not a hash when merging attribute hash{".join('}{',@$path)."}"
48 unless ref($target) eq 'HASH' && ref($new) eq 'HASH';
49 while (my($k,$v) = each %$new) {
50 if (ref($v) eq 'HASH' || (exists $target->{$k} && ref($target->{$k}) eq 'HASH')) {
51 $target->{$k} //= {};
52 _merge_hash( $target->{$k}, $v, [ @$path, $k ] );
53 }
54 else {
55 $target->{$k} = $v;
56 }
57 }
58 }
59  
60 sub explist {
61 return (
62 map {
63 ref($_) eq 'ARRAY' ? @$_
64 : defined($_) ? ( $_ )
65 : ( )
66 } @_
67 );
68 }
69  
70 # get the env_keys, in original order, but use *LAST* instance
71 # that retains the order specified in either default or args
72 # but lets the relative order in args take precedence for keys
73 # that are in both
74 #
75 # So, the order is:
76 # [ keys that are only in default in the order they were specified in default ]
77 # [ then keys that are in args in the order they were specified in args ]
78 # No complaint is made if the same key is specified twice in either default
79 # or args, the earlier one(s) are simply ignored.
80 sub keylist {
81 my @keys;
82 for my $arg (@_) {
83 my $keys = (delete $arg->{env_keys}) // [];
84 push @keys, @$keys;
85 }
86 return (reverse uniq reverse @keys);
87 }
88  
89 sub group {
90 my $pkg = shift;
91 my $args =
92 scalar(@_) == 1 && ref($_[0]) eq 'HASH' ? shift
93 : scalar(@_) % 2 == 0 ? { @_ }
94 : croak("HPCI->group() requires a hashref or a hash in list form");
95 # copy the default attributes as a start
96 my $use_args = {};
97 _merge_hash( $use_args, $default_attrs );
98  
99 # pull out the env_keys (if any)
100 my @keys = keylist( $use_args, $args );
101 my @key_specific = map { $_->{env_key_specific} // () } $use_args, $args;
102  
103 # merge any specified env_key list that has a value available
104 for my $key (@keys) {
105 for my $key_spec (@key_specific) {
106 if (my $spec_args = $key_spec->{$key}) {
107 _merge_hash( $use_args, $spec_args );
108 }
109 }
110 }
111  
112 my $cluster = $args->{cluster} // $use_args->{cluster}
113 // croak("HPCI->group() requires a cluster key in the argument hash");
114  
115 for my $arg_set ($use_args, $args) {
116 if (my $spec_args = delete $arg_set->{cluster_specific}) {
117 _merge_hash( $use_args, $spec_args->{$cluster} // {} );
118 }
119 }
120 _merge_hash( $use_args, $args );
121 my $clgmod = "HPCD::${cluster}::Group";
122 load $clgmod;
123  
124 return $clgmod->new($use_args);
125 }
126  
127  
128 sub _trigger_mkdir {
129 my $self = shift; # an object with a log
130 my $dir = shift; # a Path::Class::Dir object
131 $self->info( "Created directory: $_" ) for $dir->mkpath;
132 }
133  
134 =head1 NAME
135  
136 HPCI
137  
138 =head1 VERSION
139  
140 Version 0.73
141  
142 =cut
143  
144 our $VERSION = '0.73';
145  
146 our $LocalConfigFound;
147  
148 $LocalConfigFound = can_load( modules => { 'HPCI::LocalConfig' => undef });
149  
150 if (!$LocalConfigFound) {
151 my $err = $Module::Load::Conditional::ERROR;
152 if (defined $err && $err !~ /^Could not find or check module /) {
153 print STDERR "Conditional load of HPCI::LocalConfig failed. Error is:\n";
154 print STDERR "$err\n";
155 }
156 }
157  
158 =head1 SYNOPSIS
159  
160 use HPCI;
161  
162 my $group = HPCI->group(
163 cluster => ($ENV{HPCI_CLUSTER} // 'uni'),
164 ...
165 );
166 $group->stage(
167 name => 'analysis_A',
168 command => '...'
169 );
170 $group->stage(
171 name => 'analysis_B',
172 command => '...'
173 );
174 $group->stage(
175 name => 'analysis_C',
176 command => '...'
177 );
178 $group->stage(
179 name => 'report',
180 command => '...'
181 );
182 $group->add_deps(
183 pre_reqs => [ qw(analysis_A analysis_B analysis_C) ],
184 dep => 'report'
185 );
186  
187 my $status_info = $group->execute;
188  
189 my $exit_status = 0;
190 for my $stage ( qw(analysis_A analysis_B analysis_C report) ) {
191 if (my $stat = $status_info->{$stage}[-1]{exit_status}) {
192 $exit_status ||= $stat;
193 print stderr "Stage $stage failed, status $stat!\n";
194 }
195 }
196  
197 exit(0); # all stages completed without error
198  
199 =head1 OVERVIEW
200  
201 HPCI (High Performance Computing Interface) provides an interface to
202 a range of types of computer aggregations (clusters, clouds, ...).
203 (The rest of this document will use I<cluster> henceforth to refer
204 to any type of aggregation that is supported by HPCI.)
205  
206 A cluster is defined as a software interface that allows running
207 multiple programs on separate compute elements (nodes).
208  
209 HPCI uses an HPCD (High Performance Computing Driver) module
210 to translate its standard interface into the appropriate access
211 mechanisms for the type of cluster that is selected. (If you have
212 used the DBI/DBD modules for accessing databases, this will seem
213 very familiar.)
214  
215 The goal of this HPCI/HPCD split is to allow users to write
216 programs that make use of cluster facilities in a portable manner.
217 If there is a reason to run the same program using a different
218 type of cluster, it should only require change the cluster
219 definition attributes provided to one parent object creation; the
220 rest of code need not know or care about the changed cluster type.
221 Programs which are likely to be run on different cluster types will
222 usually be written to get the cluster attribute information from
223 a configuration file, or command line arguments - so the program
224 itself need not change at all.
225  
226 Running a program on different types of clusters can happen for a
227 number of reasons. An organization might have access to multiple
228 types of cluster, such as an in-house cluster plus an external cloud.
229 Scholarly research often shares programs both to allow similar
230 research, or to validate existing research results.
231  
232 HPCD modules can provide cluster-specific extensions. That can
233 either be a different kind of functionality, or it can be as simple
234 as allowing the teminology familiar to users of that cluster type
235 to be used in place of the generic terminology provided by HPCI.
236 However, using such extensions makes it harder to move to a
237 different cluster type. So, actually making use of such extensions
238 must be considered carefully.
239  
240 =head1 The life cycle of a B<group>
241  
242 A B<group> is the main mechanism for using HPCI. It is an object that
243 manages a group of computation steps (called B<stage>s), distributing them
244 across the cluster and keeping track of various housekeeping details like
245 when each stage can be run, checking for the result of each completed stage
246 run, deciding whether a failure should cause a stage to be retried to to
247 prevent other stages from being executed, and collecting the status for each
248 stage.
249  
250 The life cycle of running a group of commands on a cluster is:
251  
252 =over 4
253  
254 =item create group
255  
256 A B<group> object is created using the HPCI "class method" B<group>.
257 HPCI isn't really a class, it just appears to be one. Its B<group>
258 "class method" actually delegates creation of a group object to
259 the HPCD module that is indicated by the I<cluster> attribute
260 and it returns an cluster-specific group object that supports the
261 HPCI interface.
262  
263 =item create stages
264  
265 A B<stage> is created for each command that is to be executed on a
266 separate node of the cluster. This is created using the B<group>
267 object's method B<stage>.
268  
269 =item define dependency ordering between the stages
270  
271 An important reason for running a group of jobs on a cluster is the
272 ability to use multiple computers to run portions of the computation
273 at the same time, rather than having them compete for the rsources
274 of a single computer. However, often some stages will depend
275 upon the output of other stages. Such a dependent stage cannot
276 start executing until all pre-requisite stages have completed.
277 Specifying such dependency requirements is done with the B<group>
278 method B<add_deps>.
279  
280 =item execution
281  
282 Finally, the B<group> method B<execute> will run the entire set
283 of stages. It does not return until all stages have completed (or
284 have been skipped). Each stage will normally be run once, however
285 it is possible for some stages to be retried under some
286 failure conditions.
287 A failure of one stage (after retry possibilities have been exhausted)
288 can be a trigger for
289 completely skipping the execution of other stages. Each separate
290 execution of a stage (original or retry) is managed with an internal object
291 called a job - but a user program won't see job objects directly.
292  
293 As many stages as possible are run simultaneously. This is limited by
294 the specified dependencies, by cluster-specific driver limits, and by
295 user-specified limits on concurrent execution.
296  
297 =back
298  
299 The objects that calling code deals with directly are a group object to
300 manage a group of stages, and a stage object for each separately run job.
301 Internally, there are also job objects for each retry of a stage, and a
302 log object for logging the execution process (alternately, the user can
303 provide their own Log4Perl compatible log object for HPCI to use - this may be
304 of use if you wish to merge logging of multiple groups and/or of other
305 processing within your program together in a single log).
306  
307 There are also some facilities to provide local customization of the standard
308 usage of HPCI (see "Local Customization" below).
309  
310 =head1 Output Tree Layout
311  
312 There are a number of output files and directories created during a group execution.
313  
314 The default layout of these is:
315  
316 <base_dir> "."
317 <group_dir> <base_dir>/<name>-<YYYYMMDD-hhmmss>
318 <log> <group_dir>/<name>.log
319 <stage_dir> <group_dir>/<stage_name>
320 <script_file> <stage_dir>/script.sh
321 <job_dir> <stage_dir>/<retry_number>
322 stdout
323 stderr
324 final_retry symlink to final <job_dir>
325  
326 Many of these files/directories can be re-assigned to different
327 location using group or stage attributes - shown above is the
328 default layout. Commonly, you will specifically use the I<base_dir>
329 attribute to choose a location other than the current directory for
330 placing the tree; or else use the I<group_dir> attribute if you want
331 to choose a location that does not create a sub-directory for you.
332 (If this is an already existing directory that is being re-used you
333 may end up with a mixture of old and new contents that are hard to
334 figure out.)
335  
336 =over 4
337  
338 =item base_dir
339  
340 The top level of all the generated output. It defaults to ".",
341 but can be specified explicitly when the group is created with
342 the attribute B<base_dir>.
343  
344 =item group_dir
345  
346 By default, a new directory is created under B<base_dir>. Its name
347 is I<name>-I<YYYYMMDD>-I<hhmmss> - the name of the group along with
348 a timestamp of when the execution started. This can be over-ridden
349 when the group is created by providing the group attribute B<group_dir>.
350  
351 =item log
352  
353 The automatically provided log is written to the file I<"group.log">
354 directly under I<group_dir>. This logs information about the
355 execution of the entire group of stages. See B<Logging Attributes
356 of group object> below for ways of changing the default setting.
357  
358 =item stage_dir
359  
360 Each stage creates a sub-directory beneath I<group_dir> with the
361 same name as the stage. An alternate name can be used by providing
362 the B<dir> attribute when the stage object is created.
363  
364 =item script_file
365  
366 The script created to be executed on the cluster node. This wraps
367 the specified command with additional logic to pass on environment
368 and config info, and to set output redirection. It is called
369 "script.sh" and placed in I<stage_dir>.
370  
371 =item job_dir
372  
373 A sub-directory is created under I<stage_dir> for each attempt to
374 run the command. Usually, there will only be a single attempt.
375 However, if the cluster driver provides mechanisms for detecting
376 recoverable issues and then retries a command there can be more
377 than one attempt; or alternately, if a pre-requisite stage
378 fails there might be no attempt made (in that case, though,
379 the entire I<stage_dir> directory would not even get created).
380 These directories are simply named with the retry number ("0",
381 "1", ...).
382  
383 =item stdout/stderr
384  
385 Within each I<job_dir>, the files "stdout" and "stderr" collect
386 the standard output and standard error output from that (re)try
387 attempt to run the command.
388  
389 =item final_retry
390  
391 A symlink named "final_retry" is created within I<stage_dir> that
392 points to the I<job_dir> of the final (re)try. Since you often
393 don't care as much about the initial run tries as you do about the
394 last one, this symlink provides a consistant access path to that
395 final retry.
396  
397 =back
398  
399 =head1 HPCI "Class" Methods
400  
401 You can pretend that B<HPCI> is a class with one primary class
402 method named B<group>.
403  
404 There a few other class methods used for localization purposes, they
405 are decribed below in "Local Customization".
406  
407 =head2 B<group> method
408  
409 The B<group> method creates and returns a group object, which
410 you can treat like a B<HPCI::Group> object. (In fact, it really
411 returns an object of class B<HPCD::I<cluster>::Group>, but if you
412 ignore that fact then you can trivially have your program run on
413 some other cluster type.)
414  
415 =head2 B<group> object
416  
417 The description of attributes and methods for the B<group> object given here describe
418 the generic attributes and how they are treated for all cluster types.
419 Individual cluster drivers can modify this behaviour and can provide
420 additional attributes and methods for cluster-specific purposes.
421  
422 =head3 Cluster-Related Attributes of B<group> object
423  
424 The one necessary attribute is B<cluster>. For some specific
425 cluster types there may be additional attributes required for
426 connecting to the cluster software (authentification, usage
427 class info, etc.).
428  
429 =over 4
430  
431 =item cluster
432  
433 The B<cluster> attribute specifies which type of cluster is to be used.
434 This is the only required attribute. (Some cluster types may have
435 additional attributes that are required for specifying connection
436 and authentification info.)
437  
438 =item cluster_specific
439  
440 The attribute B<cluster_specific> is optional. If provided, it should
441 contain a hashref of hashrefs. If the value specified for the I<cluster>
442 attribute is present as a key in the B<cluster_specific>
443 hash, the corresponding value will be used as a set of attribute values
444 when the group is created. Its elements will replace or augment any values
445 for the same attribute name provided to the group method. This will normally be
446 used if the program can be dynamically configured for different cluster
447 types, and there are different arg settings required for the different
448 types of cluster.
449  
450 =back
451  
452 =head3 Basic Attributes of B<group> object
453  
454 =over 4
455  
456 =item name
457  
458 The B<name> you give to a group is used for creating the directory
459 where output is stored, and also in log messages. A default name
460 "default_group_name" is provided if you do not specific an explicit
461 name. Using the default name is adequate in simple programs which
462 only create one group, but for more complicated programs giving
463 separate names to each group is necessary to easily identify the
464 output of each group. The value of B<name> may also be used by
465 the cluster-specific driver to provide an identifier name (or the
466 basis of one) to the underlying cluster, if it needs one.
467  
468 =item stage_defaults
469  
470 The attribute B<stage_defaults> is optional. If provided, it should
471 contain a hashref. This hash will be used as default values for
472 every stage created by this group.
473  
474 =back
475  
476 =head3 Directory Layout Attributes of B<group> object
477  
478 =over 4
479  
480 =item base_dir
481  
482 If none of the other directory layout attributes are used to
483 over-ride this, this attribute specifies the directory in which
484 all output directories and files will be created. This is
485 usually an existing directory; it defaults to the current
486 directory ".".
487  
488 =item group_dir
489  
490 This directory is usually created to contain the outputs of the
491 group execution. By default, it is directly under B<base_dir> with
492 a name that consists of the group name attribute and a timestamp
493 (e.g. "T_Definition-20150521-153256").
494  
495 If you provide an explicit value for this parameter, then it
496 should not be an existing directory containing previous results.
497 (If it is, the log file will be appended to the previous one, but
498 the stage directories will over-write equivalently named directories
499 and files that are created in this run, while leaving unchanged any
500 that did not recur, so you'll have a mix of old and new contents.)
501 The names of files and directories created under B<group_dir> are
502 chosen to be consistent and easy to find automatically.
503  
504 =back
505  
506 =head3 Logging Attributes of B<group> object
507  
508 An HPCI group logs its activities using a Log::Log4perl logger.
509 The logger can either be provided by the caller, or else HPCI will
510 create its own.
511  
512 =over 4
513  
514 =item log
515  
516 This a Log::Log4perl::Logger object. If it is provided as an
517 attribute to the B<group> creation call, it will be used as it is,
518 and the other logging attributes will be ignored.
519  
520 If it is not provided by the user, a new Log::Log4perl::Logger
521 object will be created using the attributes below to define where
522 it is logged to. This created logger will send all log entries to
523 a file, as well as sending all info and higher log entries to stderr.
524  
525 =item log_path
526  
527 If this attribute is provided (and the B<log> attribute is not
528 provided) it will be used as the full pathname of a file where the
529 log will be written. If it is not provided, it will use the path
530 B<log_dir>/B<log_file> by default.
531  
532 =item log_dir
533  
534 If neither B<log> or B<log_path> is provided, this attribute can
535 be used to specify the directory where the log file is to be written.
536 By default, it uses B<group_dir>.
537  
538 =item log_file
539  
540 If neither B<log> or B<log_path> is provided, this attribute can
541 be used to specify the file name to be written in the log directory.
542 By default, it uses the constant name "group.log".
543  
544 =item log_level
545  
546 You can provide this attribute to change the default log level setting from "info" to any of I<debug info warn error fatal>.
547  
548 =item log_no_stderr, log_no_file
549  
550 Normally, the default log is written to both stderr and to the log file.
551 Either of those can be suppressed by setting the corresponding attribute to a true value.
552 These attributes have no effect if the user proviedes their own logger instead of using the default one.
553  
554 =back
555  
556 =head3 Operational Attributes of B<group> object
557  
558 =over 4
559  
560 =item max_concurrent
561  
562 This attribute specifies the maximum number of stages that will
563 be executing at one time. The default setting of 0 allows as
564 many stages as possible (all those that are not waiting for a
565 pre-requisite stage to complete) to run at the same time.
566  
567 =item status
568  
569 This attribute is set internally while stages are executed.
570 It contains the final result status from each stage run that
571 has completed. The B<execute> method returns this value when
572 execution completes, so you will usually not need to access it
573 explicitly yourself.
574  
575 This value is a hashref (indexed by stage name). The values are
576 arrayrefs (indexed by run number 0..n). For each run, there is
577 a hash. The key B<exit_status> contains the exit status of the run.
578 If the stage was never run, B<exit_status> instead contains a text
579 message listing the reason that it was skipped.
580  
581 =back
582  
583 =head3 Environment Passing Attributes of B<group> object
584  
585 You can set up a set of enviroment variables that will be provided to
586 all stages. (You can also set variables that are only for individual
587 stages - if so, they will modify any set you provide in the group.)
588  
589 See B<HPCI::Env> for a description of these.
590  
591 =head3 Method B<stage> of B<group> object
592  
593 The method B<stage> is used to create a new stage object.
594 Its characteristics are described below.
595  
596 The B<group> object keeps track of all B<stage> objects created
597 within that group so that they can all be managed properly when the
598 B<execute> method is invoked.
599  
600 =head3 Method B<add_deps> of B<group> object
601  
602 The method B<add_deps> is used to specify pre-requisite/dependent
603 relationships. It takes either a hashref or a list containing
604 pairs. One of the keys must be either B<pre_req> or B<pre_reqs>,
605 another must be either B<dep> or B<deps>.
606  
607 The value for each of these keys can be either a scalar, or an arrayref
608 of scalar values. A scalar value can be either a B<stage> object (a reference),
609 the exact name of a stage object (a string), or a pattern that matches
610 the name of zero or more stages (a regexp).
611  
612 HPCI will ensure that the stage or all of the stages specified for pre_req
613 or pre_reqs have completed execution before any of the dep (or deps) stages
614 is allowed to start executing.
615  
616 The plural forms are provided for convenience - often the output
617 file from one preparation stage is required by many others, or the
618 output from many processing stages is needed by a stage that merges
619 results into a summary report. Rather than having to loop over the
620 pre_reqs and deps and calling B<add_deps> individually for every
621 individual dependency, a single call will handle the entire combination.
622  
623 Allowing a regexp to match no stages at all makes it possible to write
624 an add_deps call for stages that are optional - no dependency will be
625 added if the optional stage was not created this run.
626  
627 While it is recommended for code readability that you use the singular
628 form (B<dep> or B<pre_req>) is you are providing a single stage, and the
629 plural form (B<deps> or B<pre_reqs>) if you are providing a list of
630 stages, either can be used.
631  
632 The B<add_deps> method can be called multiple times. HPCI will
633 accumlate the dependencies appropriately.
634  
635 It is an error to provide a sequence of dependencies that form
636 a cycle in which a stage directly or indirectly has itself as a
637 pre-requisite. (Such a stage could never run. HPCI will detect
638 when all remaining stages are blocked by pre-requisites and abort,
639 but that might be after numerous stages have already been executed.)
640  
641 =head3 METHOD execute of B<group> object
642  
643 The B<execute> method is the final goal of building the group.
644 It schedules the execution of individual stages. It waits for
645 pre-requisites before running a stage. It provides for re-running
646 a stage if a soft failure has occurred that allows a retry. If a
647 failure that cannot be retried occurs, it can skip scheduling dependent
648 stages, or even stop scheduling all new stages.
649  
650 =head2 Stage Object
651  
652 =head3 Attributes
653  
654 =over 4
655  
656 =item name
657  
658 A unique B<name> attribute must be provided for stages. It is a string.
659 There is no default value provided.
660  
661 =item command
662  
663 The B<command> attribute must be provided before the group is
664 executed. It can either be provided as a string attribute when the
665 stage is created, or by using the one of
666 the command-setting methods provided by the stage class.
667  
668 See B<HPCI::Stage> for more details about the command setting
669 methods.
670  
671 =item dir
672  
673 The B<dir> attribute is optional. It specifies the direcory
674 in which files related to the stage are placed. By default,
675 it is I<group_dir>/I<stage_name>. You will usually not need to
676 change this.
677  
678 =item cluster
679  
680 The B<cluster> attribute is automatically passed on fro mthe B<group>
681 to each B<stage>. You are not likely to need this.
682  
683 =item group
684  
685 The B<group> that created a stage is automatically passed on (as a weak
686 reference) to the stage. You are not likely to need to use this attribute
687 in user code.
688  
689 =item resources_required
690  
691 =item retry_resources_required
692  
693 The B<resources_required> and B<retry_resources_required> are used to
694 define resources that will be required by the stage when it executes.
695 These attributes are somewhat cluster specific - each cluster has
696 its own set of requirements for how a job submission must specify
697 the sort of resources that it will require.
698  
699 The B<resources_required> attribute is a hash, specifying the
700 value for each resource that is to be considered.
701  
702 The B<retry_resources_required> attribute is also a hash. For
703 each resource, you can specify an array of values. If the cluster
704 driver is able to detect that a run failed because the resource
705 was inadequate, it will retry the run with the next larger value
706 from this list.
707  
708 See B<HPCI::Stage> for more details about resources.
709  
710 =item force_retries
711  
712 This attribute specifies an integer number of time to retry the
713 stage before comcluding that it has actually failed. You might use
714 this if your cluster has some nodes that work differently from
715 others and a stage might fail on one type of node but succeed on
716 another.
717  
718 These retries are done after any cluster-specific retry mechanisms
719 have been used.
720  
721 The default value for this attribute is 0 (zero), giving no forced
722 retries unless you specifically ask for them.
723  
724 =item failure_action ('abort_group', 'abort_deps'*, or 'ignore')
725  
726 Specifies the action to take if this stage fails (terminates with
727 a non-zero status).
728  
729 There are three string values that it can have:
730  
731 =over 4
732  
733 =item - abort_deps (default)
734  
735 If the stage fails, then any stages which depend upon it
736 (recursively) are not run. The group continues executing until
737 all stages which are not dependent upon this stage (including those
738 that have not yet been initiated) complete execution.
739  
740 =item - abort_group
741  
742 If the stage fails, then no other stages are started. The group
743 simply waits until stages that have already been started complete
744 and then returns.
745  
746 =item - ignore
747  
748 Execution continues unchanged, any dependent stages will be run when they are
749 no longer blocked.
750  
751 =back
752  
753 =item abort_group_on_failure abort_deps_on_failure ignore_failure
754  
755 As an alternative to providing a value to the failute_action attribute
756 when you create a stage, you can instead provide one of the pseudo-attributes
757 'abort_group_on_failure', 'abort_deps_on_failure', or 'ignore_failure' with
758 a true value to specify 'abort_group', 'abort_deps', or 'ignore' respectively.
759  
760 =item state
761  
762 The B<state> is mostly an internal attribute but after the group has
763 finished execution you can use this to check whether the stage was
764 run successfully. After execution, B<state> will either be 'pass" or
765 'fail'.
766  
767 =item Environment passing attributes
768  
769 You can set up a set of environment variables that will be provided to
770 this stage. It will use set defined for the group as a basis (if such a set was
771 defined for the group), but that set can be changed for individual stages
772 or you can have no group default and only provide a set to specific stages
773 as needed. See B<HPCI::Env> for further details.
774  
775 =back
776  
777 =head3 Methods
778  
779 =head4 command creation
780  
781 There are a number of helper methods to assist in building different
782 types of commands to be provided for the B<command> attribute.
783 See B<HPCI::Stage> for details.
784  
785 =head1 Local Configuration
786  
787 TODO: write this section
788 - describe the HPCI::LocalConfig module
789 - describe the mechanism for adding extra roles to group, stage, etc.
790  
791 =head1 Additional
792  
793 This is an early public release of HPCI, and at present, there are
794 only two drivers available.
795  
796 Only one cluster type is directly included within the HPCI package.
797 The cluster type B<HPCD::uni> runs on a "cluster" of only one
798 machine. It simply uses fork to submit individual stages and has
799 facility for retries and timeouts. This is the default cluster
800 type used for testing, as it will work natively on all types of
801 Unix systems. It is also possible to use this driver as a fallback,
802 in cases where the only available "real" cluster is not accessable
803 for some reason.
804  
805 Additionally, there is the B<HPCD::SGE> driver available on CPAN.
806 It has seen heavy use within Boutros Lab.
807  
808 Now that these packages have been released, it is likely new
809 cluster drivers will be written. People interested in developing
810 drivers for additional cluster types should contact the authors
811 of this package to co-ordinate releases, features needed, etc. at
812 B<mailto:BoutrosLabSoftware@oicr.on.ca>.
813  
814 Additionally, you may wish to subscribe to the email list mentioned
815 at B<https:://lists.oicr.on.ca/mailman/listinfo/hpci-discuss>.
816 This is expected to be a low volume discussion group, although the
817 future will tell what the actual volume will be.
818  
819 As additional capabilities of new cluster types are addressed, and as
820 different control needs used at other organizations are identified;
821 this interface will surely change. As far as possible, such changes
822 will be done in an upwardly compatible manner, but until a few more
823 drivers have been integrated there is the possibility of changes
824 that are not fully backward compatible. Watch the release notes
825 for warnings of such issues. At some point there will be a 1.0.0
826 release, at which point this expectation of (limited) incompatible
827 future change will be dropped. After that point, incompatible
828 changes will only be made for critical reasons.
829  
830 The reason for separate distribution of cluster-specific HPCD
831 packages are fairly obvious:
832  
833 =over 4
834  
835 =item -
836  
837 The maintainers of the HPCI package do not have access to every
838 possible cluster type, and it unlikely that anyone will have access
839 to all supported cluster types from one location, so the driver
840 modules will need to be tested separately anyhow.
841  
842 =item -
843  
844 A user of HPCI is equally not going to have need to access every
845 type of cluster that exists, so they will probably prefer to only
846 download the driver modules that they actually need.
847  
848 =back
849  
850 =head1 SEE ALSO
851  
852 =over 4
853  
854 =item HPCI::Group
855  
856 Describes the interface common to all B<HPCI Group>
857 objects, regardless of the particular type of cluster that
858 is actually being used to run the stages. In the future, the
859 common interface may change somewhat as supprt for additional
860 cluster types is added and a better understanding of the common
861 features is achieved.
862  
863 =item HPCI::Stage
864  
865 Describes the interface common to stage object returned
866 by all B<HPCI Stage> objects, regardless of the
867 particular type of cluster that is actually being used to
868 run the stages. The common interface may change somewhat
869 as supprt for additional cluster types is added and a better
870 understanding of the common features is achieved.
871  
872 =item HPCI::Logger
873  
874 Describes the logger parameters in more detail.
875  
876 =item HPCI::Env
877  
878 Describes the environment passing parameters in more detail.
879  
880 =item HPCD::I<$cluster>::Group
881  
882 Describes the group interface unique to a specific type of cluster,
883 including any limitations or extensions to the generic interface.
884  
885 =item HPCD::I<$cluster>::Stage
886  
887 Describes the stage interface unique to a specific type of cluster,
888 including any limitations or extensions to the generic interface.
889  
890 =back
891  
892 =head1 AUTHOR
893  
894 Christopher Lalansingh - Boutros Lab
895  
896 John Macdonald - Boutros Lab
897  
898 =head1 ACKNOWLEDGEMENTS
899  
900 Paul Boutros, Phd, PI - Boutros Lab
901  
902 The Ontario Institute for Cancer Research
903  
904 =cut
905  
906 1;
907  
« blib/lib/HPCI/File.pm ↑ Summary blib/lib/HPCI/Subgroup.pm »