Skip to content

Commit

Permalink
Merge pull request #85 from FredHutch/47-module-usage
Browse files Browse the repository at this point in the history
Adding module check to HelloModuleHostname
  • Loading branch information
sitapriyamoorthi authored Feb 6, 2025
2 parents 1a2b4dd + 493f3de commit 96066d1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
39 changes: 36 additions & 3 deletions helloModuleHostname/helloModuleHostname.wdl
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"
}
}
3 changes: 3 additions & 0 deletions helloModuleHostname/inputs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"HelloModuleHostname.module2load": "Python/3.12.3-GCCcore-13.3.0"
}

0 comments on commit 96066d1

Please sign in to comment.