0293401c526b33087d696a16a2d34909a36e1e11
hiram
  Thu Mar 28 10:51:35 2024 -0700
adding ram and cpu arguments .pm no redmine

diff --git src/hg/utils/automation/HgAutomate.pm src/hg/utils/automation/HgAutomate.pm
index 461722b..b00d7e1 100755
--- src/hg/utils/automation/HgAutomate.pm
+++ src/hg/utils/automation/HgAutomate.pm
@@ -407,92 +407,108 @@
     }
   }
   push @filesystems, '/hive/data/genomes' if (scalar(@filesystems)<1);
   return @filesystems;
 }
 
 
 #########################################################################
 # Support for command line options expected to be common to many
 # automation scripts:
 
 use vars qw( @commonOptionVars @commonOptionSpec );
 
 # Common option defaults:
 my $defaultVerbose = 1;
+my $defaultRamG = "8g";
+my $defaultCpu = 1;
 
 @commonOptionVars = qw(
     $opt_workhorse
     $opt_fileServer
     $opt_dbHost
     $opt_bigClusterHub
     $opt_smallClusterHub
+    $opt_ram
+    $opt_cpu
     $opt_priority
     $opt_debug
     $opt_verbose
     $opt_help
     );
 
 @commonOptionSpec = ("workhorse=s",
 		     "fileServer=s",
 		     "dbHost=s",
 		     "bigClusterHub=s",
 		     "smallClusterHub=s",
+		     "ram=s",
+		     "cpu=n",
 		     "priority=n",
 		     "verbose=n",
 		     "debug",
 		     "help",
 		    );
 
 my %optionHelpText = ( 'workhorse' =>
 '    -workhorse machine    Use machine (default: %s) for compute or
                           memory-intensive steps.
 ',
 		       'fileServer' =>
 '    -fileServer mach      Use mach (default: fileServer of the build directory)
                           for I/O-intensive steps.
 ',
 		       'dbHost' =>
 '    -dbHost mach          Use mach (default: %s) as database server.
 ',
 		       'bigClusterHub' =>
 '    -bigClusterHub mach   Use mach (default: %s) as parasol hub
                           for cluster runs with very large job counts.
 ',
 		       'smallClusterHub' =>
 '    -smallClusterHub mach Use mach (default: %s) as parasol hub
                           for cluster runs with smallish job counts.
 ',
+		       'ram' =>
+'    -ram Ng               Use -ram=Ng for cluster jobs (default: %s)
+                           e.g. -ram=6g.
+',
+		       'cpu' =>
+'    -cpu N                Use -cpu=N for cluster jobs (default: %s)
+                           e.g. -cpu=4.
+',
 		       'priority' =>
 '    -priority num        Use this priority for parasol jobs.
 ',
 		       'debug' =>
 '    -debug                Don\'t actually run commands, just display them.
 ',
 		       'verbose' =>
 '    -verbose num          Set verbose level to num (default %d).
 ',
 		       'help' =>
 '    -help                 Show detailed help and exit.
 ',
 		     );
 
 my %optionDefaultDefaults = ( 'workhorse' => 'least loaded',
 			      'dbHost' => $defaultDbHost,
 			      'priority' => '10',
 			      'bigClusterHub' => 'most available',
 			      'smallClusterHub' => 'most available',
+			      'ram' => $defaultRamG,
+			      'cpu' => $defaultCpu,
 			      'verbose' => $defaultVerbose,
 			    );
 
 
 sub getCommonOptionHelp {
   # Return description of common options, given defaults, for usage message.
   # Input is a hash of applicable options and default values (which can be
   # empty, in which case %optionDefaultDefaults will be used).
   # debug, verbose and help will be added if not specified.
   my %optionSpec = @_;
   my $help = "";
   foreach my $opName (sort keys %optionSpec) {
     if (exists $optionHelpText{$opName}) {
       $help .= sprintf $optionHelpText{$opName},
 	($optionSpec{$opName} || $optionDefaultDefaults{$opName});
@@ -584,39 +600,51 @@
     if (! -e $f) {
       warn "$step: output of previous step $prevStep, $f , is required " .
 	"but does not appear to exist.\n" .
 	"If it actually does exist, then this error is probably due to " .
 	"network/filesystem delays -- wait a minute and restart with " .
 	"-continue $step.\n" .
 	"If it really doesn't exist, either fix things manually or " .
 	"try -continue $prevStep\n";
       $problem = 1;
     }
   }
   exit 1 if ($problem);
 }
 
 sub paraRun {
+ my $ramG = "-ram=$defaultRamG";
+ my $cpu = "-cpu=$defaultCpu";
+ if (@_) {
+   my ($r, $c) = @_;
+   $ramG = "-ram=$r";
+   $cpu = "-cpu=$c";
+ } else {
+   $ramG = $main::opt_ram ? "-ram=$main::opt_ram" : $ramG;
+   $cpu = $main::opt_cpu ? "-cpu=$main::opt_cpu" : $cpu;
+ }
  my $para = '/parasol/bin/para';
  if ( ! -e "$para" ) {
     # allow PATH to find the para command
     $para = "para";
  }
  my $pargs = "";
  if (defined $main::opt_priority) {
      $pargs .= "-priority=$main::opt_priority";
  }
+ $pargs .= " $ramG $cpu";
+ $pargs =~ s/^ +//;
  return ("$para make $pargs jobList\n" .
 "$para check\n" .
 "$para time > run.time\n" .
 'cat run.time');
 }
 
 sub gensub2 {
  my $answer = '/parasol/bin/gensub2';
  if ( ! -s "$answer" ) {
     # allow PATH to find the gensub2 command
     $answer = "gensub2";
   }
  return $answer;
 }