From 3063c7934da91266c64d05a5f9e805db8dcdaa9a Mon Sep 17 00:00:00 2001
From: kasravi1 <kasravi1@jpblt-s01-02.jupiter.internal>
Date: Thu, 5 Dec 2024 14:52:42 +0100
Subject: [PATCH] add group name into args

---
 README.md                         | 11 ++++++-----
 scripts/build_customized_image.sh | 14 ++++++++------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 52b3663..ca52aa4 100644
--- a/README.md
+++ b/README.md
@@ -16,10 +16,10 @@ Building your base singularity image is a crucial step in preparing your environ
 Once you have reviewed the repository details and determined the appropriate Python version, you can proceed to build the base Python image using the following command:
 
 ```bash
-bash scripts/build_base_image.sh -A {account} -G {Group_name} -p {partition} -V {python_version} -N {base_image_name}
+bash scripts/build_base_image.sh -A {account} -G {group_name} -p {partition} -V {python_version} -N {base_image_name}
 ```
 - `account`: The account name for using supercomputers (you can find the name of the budget on JuDoor).
-- `Group_name`: The group name for using supercomputers (you can find the name of the Group on JuDoor). Sometimes account and group name are the same.
+- `group_name`: The group name for using supercomputers (you can find the name of the Group on JuDoor). Sometimes account and group name are the same.
 - `partition`: The partition name on the supercomputer. Please use a partition that has internet access (e.g., `devel`, `develgpus`, `develbooster`, `all (JEDI)`, etc.).
 - `python_version`: The Python version (e.g., `3.10`).
 - `base_image_name`: The name of the base image with a `.sif` extension (e.g., `base.sif`).
@@ -44,9 +44,10 @@ The above command will create an singularity image in the following path:
 After creating the base image, you can use it to install the pip packages listed in `requirements.txt` in order to create your final image.
 
 ```bash
-bash scripts/build_customized_image.sh -A {account} -P {partition} -S {absolute_path_base_image} -R {absolute_path_requirements.txt}  -F {final_image_name}
+bash scripts/build_customized_image.sh -A {account} -G {group_name} -P {partition} -S {absolute_path_base_image} -R {absolute_path_requirements.txt}  -F {final_image_name}
 ```
 - `account`: The account name for using supercomputers.
+- `group_name`: The group name for using supercomputers (you can find the name of the Group on JuDoor). Sometimes account and group name are the same.
 - `partition`: The partition name on the supercomputer. Please use a partition that has internet access (e.g., `devel`, `develgpus`, `develbooster`, etc.).
 - `absolute_path_base_image`: The absolute path of the base image that was created before.
 - `absolute_path_requirements.txt`: The absolute path of the requirements.txt that all containes all pip dependencies.
@@ -57,7 +58,7 @@ Here is the example how to build the final image:
 
 
 ```bash
-bash scripts/build_customized_image.sh -A atmlaml -P devel -S /p/project1/atmlaml/{$USER}/apptainer/test.sif -R {path_to_requirements}/requirements.txt -F final.sif
+bash scripts/build_customized_image.sh -A atmlaml -G atmlaml -P devel -S /p/project1/atmlaml/{$USER}/apptainer/test.sif -R {path_to_requirements}/requirements.txt -F final.sif
 ```
 
 Check slurm report in `slurm_report` to make sure the singularity image has been created sucessfully. 
@@ -65,7 +66,7 @@ Athe end of this report, if you see `Hello world. This is my Python version` can
 
 You can find the final singularity image in the following path:
 
-`/p/project1/{account}/{$USER}/apptainer/final.sif`
+`/p/project1/{account}/$USER/apptainer/final.sif`
 
 
 In General, If the containers from the NVIDIA container registry [link](https://catalog.ngc.nvidia.com/) are used as a base image you can be quite sure that you are as fast as it gets.
diff --git a/scripts/build_customized_image.sh b/scripts/build_customized_image.sh
index b541c1e..3775307 100644
--- a/scripts/build_customized_image.sh
+++ b/scripts/build_customized_image.sh
@@ -6,26 +6,28 @@ PARTITION_NAME=""
 SINGULARITY_BASE_IMG_PATH=""
 SINGULARITY_FINAL_IMG_NAME=""
 REQUIREMENT_PATH=""
+GROUP_NAME=""
 
 # Parse options
-while getopts "A:P:S:R:F:" opt; do
+while getopts "A:G:P:S:R:F:" opt; do
     echo "Processing option: $opt with argument: $OPTARG" # Add this for debugging
     case $opt in
         A) ACCOUNT_NAME=$OPTARG ;;
+        G) GROUP_NAME=$OPTARG ;;
         P) PARTITION_NAME=$OPTARG ;;
         S) SINGULARITY_BASE_IMG_PATH=$OPTARG ;;
         R) REQUIREMENT_PATH=$OPTARG ;;
         F) SINGULARITY_FINAL_IMG_NAME=$OPTARG ;;
         *)
-            echo "Usage: $0 -A <account_name> -P <partition_name> -S <singularity_base_image_path> -R <requirement.txt_path> F <singularity_image_name>"
+            echo "Usage: $0 -A <account_name> -G <group_name> -P <partition_name> -S <singularity_base_image_path> -R <requirement.txt_path> F <singularity_image_name>"
             exit 1
             ;;
     esac
 done
 
 # Check if required arguments are provided
-if [ -z "$ACCOUNT_NAME" ] || [ -z "$PARTITION_NAME" ] || [ -z "$SINGULARITY_BASE_IMG_PATH" ] || [ -z "$REQUIREMENT_PATH" ] || [ -z "$SINGULARITY_FINAL_IMG_NAME" ]; then
-    echo "Usage: $0 -A <account_name> -P <partition_name> -S <singularity_base_image_path> -R <requirement.txt_path> F <singularity_image_name>"
+if [ -z "$ACCOUNT_NAME" ] || [ -z "$GROUP_NAME" ] || [ -z "$PARTITION_NAME" ] || [ -z "$SINGULARITY_BASE_IMG_PATH" ] || [ -z "$REQUIREMENT_PATH" ] || [ -z "$SINGULARITY_FINAL_IMG_NAME" ]; then
+    echo "Usage: $0 -A <account_name> -G <group_name> -P <partition_name> -S <singularity_base_image_path> -R <requirement.txt_path> F <singularity_image_name>"
     exit 1
 fi
 
@@ -62,7 +64,7 @@ module load Stages
 module try-load GCC Apptainer-Tools
 
 # Define the directory path
-DIR="/p/project1/${ACCOUNT_NAME}/${USER}/apptainer"
+DIR="/p/project1/${GROUP_NAME}/${USER}/apptainer"
 
 # Ensure directory exists
 if [ ! -d "\$DIR" ]; then
@@ -74,7 +76,7 @@ else
 fi
 
 # Create temporary directory for Apptainer build
-TMP=\$(mktemp -p /p/scratch/${ACCOUNT_NAME}/apptainer -d) || { echo "Failed to create temporary directory"; exit 1; }
+TMP=\$(mktemp -p /p/scratch/${GROUP_NAME}/apptainer -d) || { echo "Failed to create temporary directory"; exit 1; }
 export APPTAINER_TMPDIR=\$TMP
 
 # Create the Singularity definition file in TMP
-- 
GitLab