Changeset 5989
- Timestamp:
- Aug 19, 2020, 8:19:18 AM (3 years ago)
- Location:
- extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid/config/JobConfig.java
r5987 r5989 92 92 93 93 private Map<String, String> qsubOptions; 94 private Map<String, String> sbatchOptions; 94 95 95 96 /** … … 103 104 this.nice = null; 104 105 this.qsubOptions = new LinkedHashMap<>(); 106 this.sbatchOptions = new LinkedHashMap<>(); 105 107 } 106 108 … … 254 256 } 255 257 256 /** 257 The priority must be between -1023 and +1024. Other generic qsub 258 259 /** 260 Set an option for the 'sbatch' command (Slurm). See 261 https://slurm.schedmd.com/sbatch.html for 262 a lot more information. The options will go into the 263 script file using the #SBATCH prefix. It is not recommended 264 to override options that are automatically set when submitting 265 the job. This is currently: TODO (-terse, -S, -N, -wd, -o, -e 266 and -p). 267 268 @param option The name of the option (with or without the hyphen) 269 @param value The value of the option (null will remove it) 270 @since 1.4 271 */ 272 public void setSbatchOption(String option, String value) 273 { 274 checkLocked("setSbatchOption(" + option + ")"); 275 if (option == null) return; 276 if (option.startsWith("-")) option = option.substring(1); // Remove '-' 277 if (option.startsWith("-")) option = option.substring(1); // Remove '--' 278 if (value == null) 279 { 280 sbatchOptions.remove(option); 281 } 282 else 283 { 284 sbatchOptions.put(option, value); 285 } 286 } 287 288 /** 289 Get the value of a sbatch option. 290 @param option The name of the option (with or without the hyphen) 291 @since 1.4 292 */ 293 public String getSbatchOption(String option) 294 { 295 if (option == null) return null; 296 if (option.startsWith("-")) option = option.substring(1); // Remove '-' 297 if (option.startsWith("-")) option = option.substring(1); // Remove '--' 298 return sbatchOptions.get(option); 299 } 300 301 /** 302 Get all options that has been specified for sbatch so far. 303 @return A read-only map with the sbatch options 304 @since 1.4 305 */ 306 public Map<String, String> getSbatchOptions() 307 { 308 return Collections.unmodifiableMap(sbatchOptions); 309 } 310 311 /** 312 Add all sbatch options in this configuration to the script. 313 Each option will create a line: 314 #SBATCH --<option>=<value> 315 or: 316 #SBATCH -<option>=<value> 317 */ 318 public void appendSbatchOptionsToScript(StringBuilder script, Set<String> ignore) 319 { 320 for (Map.Entry<String, String> entry : sbatchOptions.entrySet()) 321 { 322 String option = entry.getKey(); 323 if (ignore == null || !ignore.contains(option)) 324 { 325 String prefix = option.length() == 1 ? "-" : "--"; 326 script.append("#SBATCH " + prefix + option + "=" + entry.getValue() + "\n"); 327 } 328 } 329 } 330 331 /** 332 The priority must be between -1023 and +1024 and 'nice' must be 333 between -2147483645 and +2147483645. Other generic qsub or sbatch 258 334 options are not checked. 259 335 */ -
extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid/engine/SlurmEngine.java
r5987 r5989 36 36 LoggerFactory.getLogger(SlurmEngine.class); 37 37 38 private static final Set<String> ignoredSbatchOptions = 39 new HashSet<>(); // TODO 40 38 41 public SlurmEngine() 39 42 {} … … 75 78 script.append("#SBATCH --nodes=1\n"); // 1 task on 1 node 76 79 script.append("#SBATCH --ntasks=1\n"); 77 script.append("#SBATCH --cpus-per-task=2\n");80 // script.append("#SBATCH --cpus-per-task=2\n"); 78 81 79 82 if (config.getSlurmNice() != null) … … 81 84 script.append("#SBATCH --nice=" + config.getSlurmNice() + "\n"); 82 85 } 83 // config.appendQsubOptionsToScript(script, ignoredQsubOptions);86 config.appendSbatchOptionsToScript(script, ignoredSbatchOptions); 84 87 85 88 script.append("# --- end sbatch options ---\n");
Note: See TracChangeset
for help on using the changeset viewer.