| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Phenyx::Utils::LSF::Submission; | ||||||||||||||||||||||||||||
| 4 | require Exporter; | ||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Phenyx::Utils::LSF::Submission | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | For all related to LSF system submission (linux only). Read configuration data from properties (can be deduced from Phenyx::Config::GlobalParam) | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | Conceptually, this module is able to | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =over 4 | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =item deal with a local or remote lsf master (meaning that the lsf system is not force to be ran on your machine) | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =item pass whatever argument to bsub command | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =item pre/pos synchronize sub directories | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =item synchronize file at regular interval during execution between node0 and lsf master (and back to your machine if lsf master is remote) | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =item extract properties from a function pointer (see t/Phenyx/Submit/LSF.t) | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =item deal with more than one lsf submission in the same working directory | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =back | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | #LSF activity | ||||||||||||||||||||||||||||
| 37 | lsf.active=1 | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | #LSF master host from outside | ||||||||||||||||||||||||||||
| 40 | lsf.master.hostname=phenyx@vit-prd.unil.ch | ||||||||||||||||||||||||||||
| 41 | #LSF master host name from within the cluster | ||||||||||||||||||||||||||||
| 42 | lsf.master.localHostname=frt | ||||||||||||||||||||||||||||
| 43 | #lsf.master.shell=/bin/bash | ||||||||||||||||||||||||||||
| 44 | lsf.queue.name=priority | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | lsf.mpich.nbnodes=3,4 | ||||||||||||||||||||||||||||
| 47 | lsf.mpich.wrapper=$LSF_BINDIR/pam -g 1 mpichp4_wrapper | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | lsf.extrasubcommand=-P phenyx | ||||||||||||||||||||||||||||
| 50 | lsf.extrasubcommand+=-R "select[model=XeonEM64T34]" | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | lsf.sync.pre.node0.directories=working,tmp | ||||||||||||||||||||||||||||
| 53 | lsf.sync.post.node0.directories=working | ||||||||||||||||||||||||||||
| 54 | lsf.sync.continuous.node0.files=tmp:my-stderr.txt | ||||||||||||||||||||||||||||
| 55 | lsf.refreshDelay=10 | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =head3 isActive([$val]); | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | Returns if the LSF is to be launched (lsf.active property) | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head3 isAvailable(); | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Returns true if LSF system is possible on the lsf master (bsub binary is available) | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head3 mpichActive(); | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | return if mpich features is activated from (mpich.active property) | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head3 propertyExtractionFunction(\&fct) | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | Set a function to extract properties | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =head3 readProperty($) | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | Read a property (such as lsf.master.hostname) | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =head1 METHODS | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head3 $lsfSub = Phenyx::Utils::LSF::Submission->new([\%h]) | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head3 $lsfSub->id(); | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | Returns the LSF job id from the submitted job (undef means the job has not yet been submitted (or no id has been returned) | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head3 listNodes([model=>str] [,type=str]) | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | Returns a hash of available nodes ([for a given proc type & model ]) within the served lsf system. Data is based on the lsf lshosts command. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head3 getQueues() | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | Returns a list of available queues | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =head3 $lsfSub->directory($cat [, $val]); | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | Returns [or set] a directory (ex $cat=working, tmp...) | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head3 $lsfSub->newScriptTag(); | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | If more than one lsf job is submitted from within a directory, we want to label them (to build exec & pre-exec scripts, stderr and stdout files for examples). | ||||||||||||||||||||||||||||
| 103 | Such a tag is read parsing lsf.*.scripts files in the current working directory. | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =head3 $lsfSub->scriptTag(); | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | Returns the current scriptTag | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | =head3 $lsfSub->syncStart(); | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | Synchronize files (if any) at start time | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =head3 $lsfSub->syncContinuous(); | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | Synchronize files (if any) continuously during execution (frequency based on phenyx.lsf.sync.continuous.delay property) | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =head3 $lsfSub->syncEnd(); | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | Synchronize files (if any) at finish time. | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =head3 $lsfSub->buildExecScript($executionCmd); | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | Builds the script file to feed the LSF bsub command. Returns the script file name | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =head3 $lsfSub->buildPreExecScript(); | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | Builds the script to be executed prior to launch (-E option) if any. Returns the script file name or undef if no command is to be executed. | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =head3 $lsfSub->anyFileContSync(); | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | Returns if any file is to be synchronized | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =head3 $lsfSub->buildSynchroScript(); | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | Builds locally the script which will be executed to synchronize the files (lsf.sync.continuous... property) every refreshDelay this script has to be standalone and to quit whenever the job has finished. | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | Returns without doing nothing if the script already exist or if no file is to be synchronized. | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =head3 $lsfSub->buildSynchroScriptCall(); | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | Build a .sh file to call the file from buildSynchroScript with the correct arguments. | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =head3 submitLSF(); | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | Submit the current setup lsf script to the system | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | =head3 $lsfSub->shellProfile() | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | Returns the .profile file (with aliases and shell functions) from the lib files | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | =head3 $lsfSub->wait4End(); | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | Waits for the job has finished. Returns 0 if OK | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =head3 $lsfSub->masterExec(); | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | If a phenyx.lsf.master.hostname exist, make a command to ssh all conmmands. If not, just execute locally. | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | =head3 $lsfSub->masterExecCmd($cmd); | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | Prepend an ssh string if the lsf master is remote | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | =head1 PROPERTIES | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | #lsf active (no effective lsf submission if not active) | ||||||||||||||||||||||||||||
| 166 | lsf.active=0|1 | ||||||||||||||||||||||||||||
| 167 | #lsf master hostname, to be contacted from outside the cluster | ||||||||||||||||||||||||||||
| 168 | #nothing means lsf master is the localhost | ||||||||||||||||||||||||||||
| 169 | lsf.master.hostname=host | ||||||||||||||||||||||||||||
| 170 | #lsf master hostname, contacted from within the cluster | ||||||||||||||||||||||||||||
| 171 | lsf.master.localHostname=host | ||||||||||||||||||||||||||||
| 172 | #queue to to submited (bsub -q argument) | ||||||||||||||||||||||||||||
| 173 | lsf.queue.name=name | ||||||||||||||||||||||||||||
| 174 | #/bin/bash by default (bsub -L argument) | ||||||||||||||||||||||||||||
| 175 | lsf.master.shell=shell path | ||||||||||||||||||||||||||||
| 176 | #nb nodes for mpich submission (bsub -n arg) | ||||||||||||||||||||||||||||
| 177 | lsf.mpich.nbnodes=n[,m] | ||||||||||||||||||||||||||||
| 178 | #mpich wrapper command | ||||||||||||||||||||||||||||
| 179 | lsf.mpich.wrapper=string | ||||||||||||||||||||||||||||
| 180 | #extra param to be passed to bsub | ||||||||||||||||||||||||||||
| 181 | lsf.extrasubcommand=multiline string | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | #registered directories to be synchronized beteween master and node0 before the job starts | ||||||||||||||||||||||||||||
| 184 | lsf.sync.pre.node0.directories=dir1[,dir2] | ||||||||||||||||||||||||||||
| 185 | #after the job has finsished | ||||||||||||||||||||||||||||
| 186 | lsf.sync.post.node0.directories=dir1[,dir2[...]] | ||||||||||||||||||||||||||||
| 187 | #files to be kept updated back on the master every refreshDelay seconds | ||||||||||||||||||||||||||||
| 188 | lsf.sync.continuous.node0.files=dir1:file1,[dir2:file2[...]] | ||||||||||||||||||||||||||||
| 189 | lsf.sync.refreshDelay=int [10 default] | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =head1 EXAMPLES | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | Phenyx::Submit::JobSubmission, Phenyx::Config::GlobalParam | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | Copyright (C) 2004-2005 Geneva Bioinformatics www.genebio.com | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 204 | modify it under the terms of the GNU Lesser General Public | ||||||||||||||||||||||||||||
| 205 | License as published by the Free Software Foundation; either | ||||||||||||||||||||||||||||
| 206 | version 2.1 of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | This library is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 209 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 210 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||||||||||||||||
| 211 | Lesser General Public License for more details. | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | You should have received a copy of the GNU Lesser General Public | ||||||||||||||||||||||||||||
| 214 | License along with this library; if not, write to the Free Software | ||||||||||||||||||||||||||||
| 215 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | =head1 AUTHORS | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | Alexandre Masselot, www.genebio.com | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | =cut | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 1 | ▶ | use Phenyx::Utils::LSF::JobInfo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 1 | ▶ | use File::Temp qw/ tempfile tempdir /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 227 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 228 | 1 | ▶ | use File::Path; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 229 | 1 | ▶ | use File::Find::Rule; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 230 | 1 | ▶ | use File::chmod; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 231 | 1 | ▶ | use File::Copy; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 1 | ▶ | use POSIX ":sys_wait_h"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 234 | 1 | ▶ | use Errno qw(EAGAIN); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 1 | ▶ | use Time::localtime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 237 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 238 | 1 | ▶ | use Cwd qw(getcwd); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | our (@ISA,@EXPORT,@EXPORT_OK); | ||||||||||||||||||||||||||||
| 241 | @ISA = qw(Exporter); | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | @EXPORT = qw(); | ||||||||||||||||||||||||||||
| 244 | @EXPORT_OK = (); | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | our $rsyncCmdHead="rsync --recursive --verbose --rsh=ssh"; | ||||||||||||||||||||||||||||
| 247 | #a pointer to a function to extract properties | ||||||||||||||||||||||||||||
| 248 | our $propExtractFct; | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 0 | ▶ | sub new{ | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 251 | 0 | my ($pkg, $h)=@_; | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 0 | my $dvar={}; | |||||||||||||||||||||||||||
| 254 | 0 | bless $dvar, $pkg; | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | foreach (keys %$h){ | |||||||||||||||||||||||||||
| 257 | 0 | $dvar->set($_, $h->{$_}); | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 0 | $dvar->{active}=readProperty('lsf.active'); | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | $dvar->{master}{hostname}=readProperty('lsf.master.hostname'); | |||||||||||||||||||||||||||
| 263 | 0 | $dvar->{master}{localHostname}=readProperty('lsf.master.localHostname'); | |||||||||||||||||||||||||||
| 264 | 0 | $dvar->{queue}{name}=readProperty('lsf.queue.name'); | |||||||||||||||||||||||||||
| 265 | 0 | ▶ | $dvar->{master}{shell}=readProperty('lsf.master.shell') || '/bin/bash'; | ||||||||||||||||||||||||||
|
Condition0%0/2
&readProperty('lsf.master.shell') || '/bin/bash'
MC/DC0%0/1
&readProperty('lsf.master.shell') || '/bin/bash'
&readProperty('lsf.master.shell')
Truth table0%0/2
A
A= &readProperty('lsf.master.shell')
| |||||||||||||||||||||||||||||
| 266 | 0 | $dvar->{mpich}{nbnodes}=readProperty('lsf.mpich.nbnodes'); | |||||||||||||||||||||||||||
| 267 | 0 | $dvar->{mpich}{wrapper}=readProperty('lsf.mpich.wrapper'); | |||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | my @tmp=readProperty('lsf.extrasubcommand'); | |||||||||||||||||||||||||||
| 270 | 0 | $dvar->{extrasubcommand}=\@tmp; | |||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 0 | $dvar->{sync}{pre}{node0}{directories}=readProperty('lsf.sync.pre.node0.directories'); | |||||||||||||||||||||||||||
| 273 | 0 | $dvar->{sync}{post}{node0}{directories}=readProperty('lsf.sync.post.node0.directories'); | |||||||||||||||||||||||||||
| 274 | 0 | $dvar->{sync}{continuous}{node0}{files}=readProperty('lsf.sync.continuous.node0.files'); | |||||||||||||||||||||||||||
| 275 | 0 | ▶ | $dvar->{sync}{refreshDelay}=readProperty('lsf.sync.refreshDelay')||10; | ||||||||||||||||||||||||||
|
Condition0%0/2
&readProperty('lsf.sync.refreshDelay') || 10
MC/DC0%0/1
&readProperty('lsf.sync.refreshDelay') || 10
&readProperty('lsf.sync.refreshDelay')
Truth table0%0/2
A
A= &readProperty('lsf.sync.refreshDelay')
| |||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 0 | return $dvar; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | ##### global function | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sub isActive{ | ||||||||||||||||||||||||||
|
Subroutine
isActive: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 284 | 0 | my $this=shift; | |||||||||||||||||||||||||||
| 285 | 0 | my $val=shift; | |||||||||||||||||||||||||||
| 286 | 0 | ▶ | if(defined $val){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | 0 | $this->{active}=$val; | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | 0 | return $this->{active}; | |||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 0 | ▶ | sub propertyExtractionFunction{ | ||||||||||||||||||||||||||
|
Subroutine
propertyExtractionFunction: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 293 | 0 | my $fct=shift; | |||||||||||||||||||||||||||
| 294 | 0 | ▶ | croak __PACKAGE__.": propertyExtractionFunction() has not been defined" if((! defined $fct) && (!defined $propExtractFct)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fct or defined $Phenyx::Utils::LSF::Submission::propExtractFct
MC/DC0%0/2
defined $fct or defined $Phenyx::Utils::LSF::Submission::propExtractFct
defined $fct
defined $Phenyx::Utils::LSF::Submission::propExtractFct
Truth table0%0/3
A or B
A= defined $fctB= defined $Phenyx::Utils::LSF::Submission::propExtractFct
| |||||||||||||||||||||||||||||
| 295 | 0 | ▶ | $propExtractFct=$fct if defined $fct; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | 0 | return $propExtractFct | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 0 | ▶ | sub readProperty($){ | ||||||||||||||||||||||||||
|
Subroutine
readProperty: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 300 | 0 | return propertyExtractionFunction()->(shift); | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | #### master sub | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 0 | ▶ | sub listNodes{ | ||||||||||||||||||||||||||
|
Subroutine
listNodes: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 306 | 0 | my $this=shift; | |||||||||||||||||||||||||||
| 307 | 0 | my %prm=@_; | |||||||||||||||||||||||||||
| 308 | 0 | my %ctr; | |||||||||||||||||||||||||||
| 309 | 0 | $ctr{model}=$prm{model}; | |||||||||||||||||||||||||||
| 310 | 0 | $ctr{type}=$prm{type}; | |||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | my $cmd=$this->masterExecCmd('lshosts'); | |||||||||||||||||||||||||||
| 313 | 0 | my $fd; | |||||||||||||||||||||||||||
| 314 | 0 | ▶ | open ( $fd, "$cmd|") or croak "cannot launch command $cmd: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | 0 | $_=<$fd>; | |||||||||||||||||||||||||||
| 316 | 0 | my @headers=split; | |||||||||||||||||||||||||||
| 317 | 0 | my %list; | |||||||||||||||||||||||||||
| 318 | 0 | ▶ | while (<$fd>){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 0 | chomp; | |||||||||||||||||||||||||||
| 320 | 0 | my @line=split /\s+/, $_, scalar(@headers); | |||||||||||||||||||||||||||
| 321 | 0 | my $host=$line[0]; | |||||||||||||||||||||||||||
| 322 | 0 | foreach (0..$#headers){ | |||||||||||||||||||||||||||
| 323 | 0 | $list{$host}{$headers[$_]}=$line[$_]; | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||
| 326 | 0 | foreach my $ctr (qw/model type/){ | |||||||||||||||||||||||||||
| 327 | 0 | ▶ | next unless $ctr{$ctr}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 328 | 0 | foreach (keys %list){ | |||||||||||||||||||||||||||
| 329 | 0 | ▶ | delete $list{$_} unless $list{$_}->{$ctr} =~ /$ctr{$ctr}/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | 0 | return %list; | |||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 0 | ▶ | sub masterExecCmd{ | ||||||||||||||||||||||||||
|
Subroutine
masterExecCmd: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 336 | 0 | my $this=shift; | |||||||||||||||||||||||||||
| 337 | 0 | my $cmdExec="@_"; | |||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | 0 | my $cmd; | |||||||||||||||||||||||||||
| 340 | 0 | undef $cmd; | |||||||||||||||||||||||||||
| 341 | 0 | ▶ | $cmd="ssh $this->{master}{hostname} " if $this->{master}{hostname}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 342 | 0 | $cmd.=$cmdExec; | |||||||||||||||||||||||||||
| 343 | 0 | return $cmd; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 0 | ▶ | sub masterExec{ | ||||||||||||||||||||||||||
|
Subroutine
masterExec: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 347 | 0 | my $this=shift; | |||||||||||||||||||||||||||
| 348 | 0 | my $cmd=$this->masterExecCmd(@_); | |||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 0 | ▶ | system "$cmd" && croak "error executing line $cmd"; | ||||||||||||||||||||||||||
|
Condition0%0/2
"$cmd" && croak("error executing line $cmd")
MC/DC0%0/1
"$cmd" && croak("error executing line $cmd")
"$cmd"
Truth table0%0/2
A
A= "$cmd"
| |||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | ############### | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 0 | ▶ | sub newScriptTag{ | ||||||||||||||||||||||||||
|
Subroutine
newScriptTag: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 356 | 0 | my $this=shift; | |||||||||||||||||||||||||||
| 357 | 0 | my @files=File::Find::Rule->file()->name('lsf.*.script.sh')->in('.'); | |||||||||||||||||||||||||||
| 358 | 0 | my $max=-1; | |||||||||||||||||||||||||||
| 359 | 0 | foreach (@files){ | |||||||||||||||||||||||||||
| 360 | 0 | ▶ | die "cannot parse [$_] for a tag" unless /lsf\.(.+)\.script.sh/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | 0 | ▶ | $max=$1 if $1>$max; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | 0 | $max++; | |||||||||||||||||||||||||||
| 364 | 0 | $this->{scriptTag}=$max; | |||||||||||||||||||||||||||
| 365 | 0 | my $fd; | |||||||||||||||||||||||||||
| 366 | 0 | open ($fd, ">lsf.$this->{scriptTag}.script.sh"); | |||||||||||||||||||||||||||
| 367 | 0 | close $fd; | |||||||||||||||||||||||||||
| 368 | 0 | return $this->{scriptTag}; | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | 0 | ▶ | sub scriptTag{ | ||||||||||||||||||||||||||
|
Subroutine
scriptTag: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 372 | 0 | my $this=shift; | |||||||||||||||||||||||||||
| 373 | 0 | ▶ | $this->newScriptTag() unless defined $this->{scriptTag}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 374 | 0 | return $this->{scriptTag}; | |||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | ############### Accessors/Setters | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 0 | ▶ | sub directory{ | ||||||||||||||||||||||||||
|
Subroutine
directory: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 381 | 0 | my($this, $cat, $val)=@_; | |||||||||||||||||||||||||||
| 382 | 0 | ▶ | croak "a cat parameter ('working', 'tmp'...) must be defined in lsfSub->directory() method" unless defined $cat; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if(defined $val){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 384 | 0 | $this->{directories}{$cat}=$val; | |||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | 0 | return $this->{directories}{$cat}; | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 0 | ▶ | sub mpichActive{ | ||||||||||||||||||||||||||
|
Subroutine
mpichActive: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 390 | 0 | my($this, $val)=@_; | |||||||||||||||||||||||||||
| 391 | 0 | ▶ | if(defined $val){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 392 | 0 | $this->{mpich}{active}=$val; | |||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | 0 | return $this->{mpich}{active}; | |||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | ############### | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 0 | ▶ | sub buildExecScript{ | ||||||||||||||||||||||||||
|
Subroutine
buildExecScript: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||
| 400 | 0 | my $this=shift; | |||||||||||||||||||||||||||
| 401 | 0 | my $cmd=shift; | |||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 0 | ▶ | croak "could not define script tag" unless defined $this->scriptTag(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 0 | my $fname=getcwd."/lsf.$this->{scriptTag}.script.sh"; | |||||||||||||||||||||||||||
| 406 | 0 | my $fdout; | |||||||||||||||||||||||||||
| 407 | 0 | ▶ | open ($fdout, ">$fname") or croak "cannot open [$fname] for writing: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | 0 | my $fdin; | |||||||||||||||||||||||||||
| 410 | 0 | ▶ | open ($fdin, "<".$this->shellProfile()) or die "cannot open profile def [".$this->shellProfile()."] for reading: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 411 | 0 | print $fdout "#start --- include profile from ".$this->shellProfile()."\n"; | |||||||||||||||||||||||||||
| 412 | 0 | ▶ | while (<$fdin>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 413 | 0 | print $fdout $_; | |||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | 0 | print $fdout "#end --- including profile from ".$this->shellProfile()."\n"; | |||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 0 | my $lsftag=$this->{scriptTag}; | |||||||||||||||||||||||||||
| 418 | 0 | ▶ | $this->{stdout} ||= "$this->{directories}{working}/lsf.$lsftag.stdout"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$this->{"stdout"} ||= qq[$this->{"directories"}{"working"}/lsf.$lsftag.stdout]
MC/DC0%0/1
$this->{"stdout"} ||= qq[$this->{"directories"}{"working"}/lsf.$lsftag.stdout]
$this->{"stdout"}
Truth table0%0/2
A
A= $this->{"stdout"}
| |||||||||||||||||||||||||||||
| 419 | 0 | ▶ | $this->{stderr} ||= "$this->{directories}{working}/lsf.$lsftag.stderr"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$this->{"stderr"} ||= qq[$this->{"directories"}{"working"}/lsf.$lsftag.stderr]
MC/DC0%0/1
$this->{"stderr"} ||= qq[$this->{"directories"}{"working"}/lsf.$lsftag.stderr]
$this->{"stderr"}
Truth table0%0/2
A
A= $this->{"stderr"}
| |||||||||||||||||||||||||||||
| 420 | 0 | print $fdout <<EOT; | |||||||||||||||||||||||||||
| 421 | #!$this->{master}{shell} | ||||||||||||||||||||||||||||
| 422 | #BSUB -L $this->{master}{shell} | ||||||||||||||||||||||||||||
| 423 | #BSUB -q $this->{queue}{name} | ||||||||||||||||||||||||||||
| 424 | #BSUB -o $this->{stdout} | ||||||||||||||||||||||||||||
| 425 | #BSUB -e $this->{stderr} | ||||||||||||||||||||||||||||
| 426 | EOT | ||||||||||||||||||||||||||||
| 427 | 0 | ▶ | if(ref($this->{extrasubcommand}) eq 'ARRAY'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 428 | 0 | foreach (@{$this->{extrasubcommand}}){ | |||||||||||||||||||||||||||
| 429 | 0 | print $fdout "#BSUB $_\n"; | |||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||
| 431 | }else{ | ||||||||||||||||||||||||||||
| 432 | 0 | print $fdout "#BSUB $this->{extrasubcommand}\n"; | |||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | #post synchronize stdout & stderr if those file exist | ||||||||||||||||||||||||||||
| 435 | 0 | foreach (qw /stdout stderr/){ | |||||||||||||||||||||||||||
| 436 | 0 | ▶ | if(-e dirname($this->{$_})){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 437 | 0 | print $fdout "#BSUB -f \"$this->{$_} ><\"\n"; | |||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 0 | my $preExec=$this->buildPreExecScript(); | |||||||||||||||||||||||||||
| 442 | 0 | my $tmpPreExec; | |||||||||||||||||||||||||||
| 443 | 0 | ▶ | if ($preExec){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 444 | 0 | $tmpPreExec=$preExec; | |||||||||||||||||||||||||||
| 445 | 0 | $tmpPreExec=~s/\//_/g; | |||||||||||||||||||||||||||
| 446 | 0 | $tmpPreExec="/tmp/$tmpPreExec"; | |||||||||||||||||||||||||||
| 447 | # copy($preExec, $tmpPreExec) or die "cannot copy($preExec, $tmpPreExec): $!"; | ||||||||||||||||||||||||||||
| 448 | 0 | print $fdout "#BSUB -E \"rsync $this->{master}{localHostname}:$preExec $tmpPreExec; $tmpPreExec\"\n"; | |||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | 0 | ▶ | if($this->mpichActive() && (split ',', $this->{mpich}{nbnodes})[0]>1){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$this->mpichActive and (split(/,/, $this->{"mpich"}{"nbnodes"}, 0))[0] > 1
MC/DC0%0/2
$this->mpichActive and (split(/,/, $this->{"mpich"}{"nbnodes"}, 0))[0] > 1
$this->mpichActive
(split(/,/, $this->{"mpich"}{"nbnodes"}, 0))[0] > 1
Truth table0%0/3
A and B
A= $this->mpichActiveB= (split(/,/, $this->{"mpich"}{"nbnodes"}, 0))[0] > 1
| |||||||||||||||||||||||||||||
| 451 | 0 | print $fdout "#BSUB -n $this->{mpich}{nbnodes}\n"; | |||||||||||||||||||||||||||
| 452 | 0 | $cmd="$this->{mpich}{wrapper} $cmd"; | |||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | 0 | print $fdout "\n$cmd\n\n"; | |||||||||||||||||||||||||||
| 455 | #print $fdout "\nrm $tmpPreExec\n\n"; | ||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | 0 | print $fdout "#post sync commands\n"; | |||||||||||||||||||||||||||
| 459 | 0 | foreach (split /,/, $this->{sync}{post}{node0}{directories}) { | |||||||||||||||||||||||||||
| 460 | 0 | my $dn=dirname($this->directory($_)); | |||||||||||||||||||||||||||
| 461 | 0 | my $cmd="$rsyncCmdHead ".$this->directory($_)." $this->{master}{localHostname}:$dn/"; | |||||||||||||||||||||||||||
| 462 | 0 | print $fdout "$cmd\n"; | |||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 0 | $this->{script}=$fname; | |||||||||||||||||||||||||||
| 466 | 0 | chmod("a+x", $fname); | |||||||||||||||||||||||||||
| 467 | 0 | return $this->{script}; | |||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | 0 | ▶ | sub buildPreExecScript{ | ||||||||||||||||||||||||||
|
Subroutine
buildPreExecScript: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 471 | 0 | my $this=shift; | |||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | 0 | ▶ | croak "could not define script tag" unless defined $this->scriptTag(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 0 | my $fname=getcwd."/lsf.$this->{scriptTag}.pre-script.sh"; | |||||||||||||||||||||||||||
| 476 | 0 | my $fdout; | |||||||||||||||||||||||||||
| 477 | 0 | ▶ | open ($fdout, ">$fname") or croak "cannot open [$fname] for writing: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | 0 | my $usePreExec; | |||||||||||||||||||||||||||
| 480 | my $fdin; | ||||||||||||||||||||||||||||
| 481 | # open ($fdin, "<".$this->shellProfile()) or die "cannot open profile def [".$this->shellProfile()."] for reading: $!"; | ||||||||||||||||||||||||||||
| 482 | # print $fdout "#start --- include profile from ".$this->shellProfile()."\n"; | ||||||||||||||||||||||||||||
| 483 | # while (<$fdin>){ | ||||||||||||||||||||||||||||
| 484 | # print $fdout $_; | ||||||||||||||||||||||||||||
| 485 | # } | ||||||||||||||||||||||||||||
| 486 | # print $fdout "#end --- including profile from ".$this->shellProfile()."\n"; | ||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | 0 | foreach (split /,/, $this->{sync}{pre}{node0}{directories}){ | |||||||||||||||||||||||||||
| 489 | 0 | my $cmd="mkdir -p ".dirname($this->directory($_))."; $rsyncCmdHead $this->{master}{localHostname}:".$this->directory($_)." ".dirname($this->directory($_))."/"; | |||||||||||||||||||||||||||
| 490 | 0 | print $fdout "$cmd\n"; | |||||||||||||||||||||||||||
| 491 | 0 | $usePreExec=1; | |||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | 0 | close $fdout; | |||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | 0 | ▶ | if($usePreExec){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 496 | 0 | $this->{preExecScript}=$fname; | |||||||||||||||||||||||||||
| 497 | 0 | chmod("a+x", $fname); | |||||||||||||||||||||||||||
| 498 | 0 | return $this->{preExecScript}; | |||||||||||||||||||||||||||
| 499 | }else{ | ||||||||||||||||||||||||||||
| 500 | 0 | unlink $fname; | |||||||||||||||||||||||||||
| 501 | 0 | return undef; | |||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | 0 | ▶ | sub buildSynchroScript{ | ||||||||||||||||||||||||||
|
Subroutine
buildSynchroScript: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||
| 506 | 0 | my $this=shift; | |||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 0 | ▶ | return unless $this->{sync}{continuous}{node0}{files}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 509 | 0 | ▶ | return $this->{contSynchroScript} if -f $this->{contSynchroScript}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | 0 | my $JobInfoPMFile=dirname(__FILE__)."/JobInfo.pm"; | |||||||||||||||||||||||||||
| 512 | 0 | my $fd; | |||||||||||||||||||||||||||
| 513 | 0 | ▶ | open ($fd, "<$JobInfoPMFile") or die "cannot open for read $JobInfoPMFile: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 514 | 0 | local $/; | |||||||||||||||||||||||||||
| 515 | 0 | my $pmContents=<$fd>; | |||||||||||||||||||||||||||
| 516 | 0 | close $fd; | |||||||||||||||||||||||||||
| 517 | 0 | eval{ | |||||||||||||||||||||||||||
| 518 | 0 | eval Pod::Strip; | |||||||||||||||||||||||||||
| 519 | 0 | my $p=Pod::Strip->new; | |||||||||||||||||||||||||||
| 520 | 0 | my $tmp=$pmContents; | |||||||||||||||||||||||||||
| 521 | 0 | undef $pmContents; | |||||||||||||||||||||||||||
| 522 | 0 | $p->output_string(\$pmContents); | |||||||||||||||||||||||||||
| 523 | 0 | $p->parse_string_document($tmp); | |||||||||||||||||||||||||||
| 524 | }; | ||||||||||||||||||||||||||||
| 525 | 0 | ▶ | if($@){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 526 | 0 | warn "[warning] could not strip Pod from $JobInfoPMFile. $!"; | |||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | 0 | $ENV{PATH}.=":".dirname(__FILE__)."/../../../../scripts/"; | |||||||||||||||||||||||||||
| 531 | 0 | ▶ | my $synchroScript=`which lsf-synchroFilesUntilFinished.pl` or die "cannot find executable script lsf-synchroFilesUntilFinished.pl in $ENV{PATH}"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 532 | 0 | ▶ | open ($fd, "<$synchroScript") or die "cannot open for read $synchroScript: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 533 | 0 | my $scriptContent=<$fd>; | |||||||||||||||||||||||||||
| 534 | 0 | close $fd; | |||||||||||||||||||||||||||
| 535 | 0 | ▶ | $scriptContent=~s/use\s+Phenyx::Utils::LSF::JobInfo;/$pmContents\n/ or die "could not patch line use\\s+Phenyx::Utils::LSF::JobInfo; in script $synchroScript"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | 0 | my $script=getcwd."/lsf.contsynchro-script.pl"; | |||||||||||||||||||||||||||
| 538 | 0 | ▶ | open ($fd, ">$script") or die "cannot open for writing $script: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 539 | 0 | print $fd $scriptContent; | |||||||||||||||||||||||||||
| 540 | 0 | close $fd; | |||||||||||||||||||||||||||
| 541 | 0 | $this->{contSynchroScript}=$script; | |||||||||||||||||||||||||||
| 542 | 0 | chmod "+x", $script; | |||||||||||||||||||||||||||
| 543 | 0 | return $this->{contSynchroScript}; | |||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | sub buildSynchroScriptCall{ | ||||||||||||||||||||||||||||
| 547 | my $this=shift; | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | my $script=getcwd."/lsf.$this->{scriptTag}.contsynchro-call-script.sh"; | ||||||||||||||||||||||||||||
| 550 | return $script if -f $script; | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | unless(Phenyx::Utils::LSF::JobInfo::isJobRunning($this->{lsfid})){ | ||||||||||||||||||||||||||||
| 553 | die "cannot buildSynchroScriptCall for LSF job [$this->{lsfid}] as it is not yet running"; | ||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | my $synchroFiles; | ||||||||||||||||||||||||||||
| 557 | foreach(split /,/, $this->{sync}{continuous}{node0}{files}){ | ||||||||||||||||||||||||||||
| 558 | my ($d, $f)=split /:/, $_; | ||||||||||||||||||||||||||||
| 559 | $synchroFiles.=" $this->{directories}{$d}/$f" | ||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||
| 561 | unless($synchroFiles){ | ||||||||||||||||||||||||||||
| 562 | undef $this->{contSynchroScriptCall}; | ||||||||||||||||||||||||||||
| 563 | return undef; | ||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | my $fd; | ||||||||||||||||||||||||||||
| 567 | open ($fd, ">$script") or die "cannot open for writing $script: $!"; | ||||||||||||||||||||||||||||
| 568 | if ($this->{master}{hostname}){ | ||||||||||||||||||||||||||||
| 569 | my $rsync="$rsyncCmdHead $this->{contSynchroScript} $this->{master}{hostname}:$this->{contSynchroScript} "; | ||||||||||||||||||||||||||||
| 570 | #copy script call to remote | ||||||||||||||||||||||||||||
| 571 | print $fd "$rsync\n"; | ||||||||||||||||||||||||||||
| 572 | # make a remote call to execute the files between node0 and lsf master | ||||||||||||||||||||||||||||
| 573 | my $cmd="ssh -n $this->{master}{hostname} '$this->{contSynchroScript} --rsyncopt=\"--rsh=ssh\" --lsfid=$this->{lsfid} --remotenode=0 $synchroFiles' &"; | ||||||||||||||||||||||||||||
| 574 | print $fd "$cmd\n"; | ||||||||||||||||||||||||||||
| 575 | sleep 2; | ||||||||||||||||||||||||||||
| 576 | #make a call to synchronize between lsf master and local | ||||||||||||||||||||||||||||
| 577 | $cmd="$this->{contSynchroScript} --rsyncopt=\"--rsh=ssh\" --lsfhost=$this->{master}{hostname} --lsfid=$this->{lsfid} --remotehost=$this->{master}{hostname} $synchroFiles"; | ||||||||||||||||||||||||||||
| 578 | print $fd "$cmd\n"; | ||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | foreach (split /,/, $this->{sync}{post}{node0}{directories}) { | ||||||||||||||||||||||||||||
| 581 | my $dn=dirname($this->directory($_)); | ||||||||||||||||||||||||||||
| 582 | my $cmd="$rsyncCmdHead $this->{master}{hostname}:".$this->directory($_)." $dn/"; | ||||||||||||||||||||||||||||
| 583 | print $fd "$cmd\n"; | ||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||
| 585 | }else{ | ||||||||||||||||||||||||||||
| 586 | print $fd "$this->{contSynchroScript} --rsyncopt='--rsh=ssh' --lsfid=$this->{lsfid} --remotenode=0 $synchroFiles\n"; | ||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||
| 588 | close $fd; | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | $this->{contSynchroScriptCall}=$script; | ||||||||||||||||||||||||||||
| 591 | chmod "+x", $script; | ||||||||||||||||||||||||||||
| 592 | return $this->{contSynchroScriptCall}; | ||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | sub submitLSF{ | ||||||||||||||||||||||||||||
| 596 | my $this=shift; | ||||||||||||||||||||||||||||
| 597 | die "cannot submitLSF if buildExecScript has not been created [$this->{script}]" unless -f $this->{script}; | ||||||||||||||||||||||||||||
| 598 | die "cannot submit if {basedir} attribute was not set to lsfSubbmission opbject" unless $this->{basedir}; | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | if ($this->{master}{hostname}) { | ||||||||||||||||||||||||||||
| 601 | my $cmd="scp -r $this->{basedir} $this->{master}{hostname}:".(dirname $this->{basedir})."/"; | ||||||||||||||||||||||||||||
| 602 | system($cmd) && die "could not execute [$cmd]: $!"; | ||||||||||||||||||||||||||||
| 603 | $Phenyx::Utils::LSF::JobInfo::SHELLCOMMANDPREFIX="ssh $this->{master}{hostname}"; | ||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||
| 607 | my $cmd=$this->masterExecCmd("bsub <$this->{script}"); | ||||||||||||||||||||||||||||
| 608 | my $fd; | ||||||||||||||||||||||||||||
| 609 | open ($fd, "$cmd|") or die "cannot open pipe from [$cmd]"; | ||||||||||||||||||||||||||||
| 610 | my $line=<$fd>; | ||||||||||||||||||||||||||||
| 611 | chomp $line; | ||||||||||||||||||||||||||||
| 612 | die "cannot extract LSF job id from line [$line]" unless $line=~/Job <(\d+)> is submitted/; | ||||||||||||||||||||||||||||
| 613 | $this->{lsfid}=$1; | ||||||||||||||||||||||||||||
| 614 | close $fd; | ||||||||||||||||||||||||||||
| 615 | my $whiled; | ||||||||||||||||||||||||||||
| 616 | while(!(Phenyx::Utils::LSF::JobInfo::isJobRunning($this->{lsfid}) or Phenyx::Utils::LSF::JobInfo::isJobFinished($this->{lsfid}))){ | ||||||||||||||||||||||||||||
| 617 | print STDERR "."; | ||||||||||||||||||||||||||||
| 618 | $whiled=1; | ||||||||||||||||||||||||||||
| 619 | sleep 1; | ||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||
| 621 | print STDERR "\n" if $whiled; | ||||||||||||||||||||||||||||
| 622 | if(my $f=$this->buildSynchroScriptCall()){ | ||||||||||||||||||||||||||||
| 623 | system($f) && die "canot execute [$f]: $!"; | ||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | sub shellProfile{ | ||||||||||||||||||||||||||||
| 629 | my $this=shift; | ||||||||||||||||||||||||||||
| 630 | my $prf=dirname(__FILE__)."/lsf.".basename($this->{master}{shell}).".profile"; | ||||||||||||||||||||||||||||
| 631 | return $prf | ||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | 1; | ||||||||||||||||||||||||||||