-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from FredHutch/47-module-usage
Adding module check to HelloModuleHostname
- Loading branch information
Showing
2 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,73 @@ | ||
version 1.0 | ||
## This is a test workflow that returns the hostname of the node | ||
## the job is submitted to as a test for module functionality on Gizmo. | ||
## Added verification of module loading. | ||
#### WORKFLOW DEFINITION | ||
workflow HelloModuleHostname { | ||
input { | ||
String module2load = "Python/3.12.3-GCCcore-13.3.0" # Default value can be overwritten | ||
} | ||
|
||
call Hostname { | ||
input: | ||
module_env = module2load | ||
} | ||
|
||
output { | ||
File stdout = Hostname.out | ||
Boolean module_loaded = Hostname.module_verified | ||
} | ||
|
||
parameter_meta { | ||
stdout: "hostname of the node the job was submitted to" | ||
module_loaded: "boolean indicating if the specified module was successfully loaded" | ||
} | ||
} | ||
|
||
#### TASK DEFINITIONS | ||
task Hostname { | ||
input { | ||
String module_env | ||
} | ||
|
||
command <<< | ||
echo $(hostname) | ||
set -e # Exit on any error | ||
|
||
# Get hostname | ||
hostname | ||
|
||
# List loaded modules and verify our module is loaded | ||
source /app/lmod/lmod/init/profile | ||
module list 2>&1 | tee module_list.txt | ||
|
||
# Check if the module or its base name is in the loaded modules | ||
if grep -q "~{module_env}" module_list.txt; then | ||
echo "true" > module_verified.txt | ||
echo "Successfully verified module ~{module_env} is loaded" | ||
else | ||
echo "ERROR: Module ~{module_env} was not found in loaded modules:" | ||
cat module_list.txt | ||
exit 1 | ||
fi | ||
>>> | ||
|
||
output { | ||
File out = stdout() | ||
Boolean module_verified = read_boolean("module_verified.txt") | ||
} | ||
|
||
runtime { | ||
cpu: 1 | ||
memory: "1 GB" | ||
modules: "Python/3.7.4-foss-2019b-fh1" | ||
modules: "~{module_env}" | ||
} | ||
|
||
parameter_meta { | ||
out: "hostname of the node the job was submitted to" | ||
module_env: "name of modules to be loaded" | ||
out: "output file containing hostname and module information" | ||
module_verified: "boolean indicating if the requested module was successfully loaded" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"HelloModuleHostname.module2load": "Python/3.12.3-GCCcore-13.3.0" | ||
} |