Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions environments/payu-dev/build_inner.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
### Custom install inner

# Fix shebang headers in payu entry points (issue with pip installed packages: https://github.com/ACCESS-NRI/MED-condaenv/issues/78)
for file in ${CONDA_INSTALLATION_PATH}/envs/${FULLENV}/bin/payu-*; do
for file in ${CONDA_INSTALLATION_PATH}/envs/${FULLENV}/bin/payu*; do
# Using payu-* to modify payu-run, payu-collate, payu-sync files
echo "Adding python header to $file"
# Substitute the first line of file (e.g. 1s), if it starts with #! (regex ^#!/.*$),
# with the python executable in the conda environment
sed -i "1s|^#!/.*$|#!${CONDA_INSTALLATION_PATH}/envs/${FULLENV}/bin/python|" "$file"
done

# Patch payu shebang header with outer python executable that launches a container when run.
# This means when payu submits qsub commands (e.g. payu run), it uses this python executable and launches a container on PBS job
sed -i "1s|^#!/.*$|#!${CONDA_SCRIPT_PATH}/${FULLENV}.d/bin/python|" "${CONDA_INSTALLATION_PATH}/envs/${FULLENV}/bin/payu"
done
12 changes: 11 additions & 1 deletion environments/payu-dev/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ declare -a rpms_to_remove=()
declare -a replace_from_apps=()
declare -a outside_commands_to_include=( "pbs_tmrsh" )
declare -a outside_files_to_copy=()
declare -a replace_with_external=()
declare -a replace_with_external=()
declare -a launcher_commands=(
"payu-run"
"payu-collate"
"payu-sync"
"payu"
"payu-branch"
"payu-checkout"
"payu-clone"
"payu-profile"
)
16 changes: 0 additions & 16 deletions environments/payu/build_inner.sh
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
### Custom install inner to build jupyter lab extensions

# set +u
# eval "$( ${MAMBA} shell hook --shell bash)"
# micromamba activate "${CONDA_INSTALLATION_PATH}/envs/${FULLENV}"
# set -u

# jupyter lab build

# Patch payu shebang header with outer python executable that launches a container when run.
# This means when payu submits qsub commands (e.g. payu run), it uses this python executable and launches a container on PBS job
sed -i "1s|^#!/.*$|#!${CONDA_SCRIPT_PATH}/${FULLENV}.d/bin/python|" "${CONDA_INSTALLATION_PATH}/envs/${FULLENV}/bin/payu"
# Above command follows pattern of "sed -i '1s|pattern|replacement|' filename"
# which modifies the environment's payu executable in place (-i),
# and replaces the first line (1s), if it starts with #! (regex ^#!/.*$),
# with the payu launcher script
10 changes: 10 additions & 0 deletions environments/payu/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ declare -a replace_from_apps=()
declare -a outside_commands_to_include=( "pbs_tmrsh" )
declare -a outside_files_to_copy=()
declare -a replace_with_external=()
declare -a launcher_commands=(
"payu-run"
"payu-collate"
"payu-sync"
"payu"
"payu-branch"
"payu-checkout"
"payu-clone"
"payu-profile"
)
30 changes: 30 additions & 0 deletions modules/common_cmd_v1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#%Module1.0

set prefix __CONDA_BASE__/__APPS_SUBDIR__
set package __CONDA_INSTALL_BASENAME__

# Prevent running this module with a running payu module
conflict payu

# Name of this module's environment
lassign [split [module-info name] {/}] module_name module_version
set condaenv "${module_version}"
set basedir "$prefix/$package/envs/$condaenv"
if {![ file exists $basedir ]} {
# For modulenames which are $ENVIRONMENT/$VERSION, rather than conda/$ENIRONMENT-$VERSION
set condaenv "${module_name}-${module_version}"
set basedir "$prefix/$package/envs/$condaenv"
}

set myscripts [ file normalize __CONDA_BASE__/__SCRIPT_SUBDIR__/$condaenv.d/bin ]
set overlay_path [ string map {/conda/ /envs/} $basedir ].sqsh

module load singularity

prepend-path CONTAINER_OVERLAY_PATH $overlay_path

# Add launcher script directory to PATH
prepend-path PATH $myscripts

### Extra env to get other things working
setenv OMPI_MCA_orte_launch_agent $myscripts/orted
20 changes: 14 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,24 @@ function inner() {
copy_if_changed "${override}" "${CONDA_SCRIPT_PATH}"/overrides/"${override##*/}"
done
mkdir -p "${CONDA_MODULE_PATH}"
copy_and_replace "${SCRIPT_DIR}"/../modules/common_v3 "${CONDA_MODULE_PATH}"/.common_v3 CONDA_BASE APPS_SUBDIR CONDA_INSTALL_BASENAME SCRIPT_SUBDIR
copy_and_replace "${SCRIPT_DIR}"/launcher_conf.sh "${CONDA_SCRIPT_PATH}"/launcher_conf.sh CONDA_BASE APPS_SUBDIR CONDA_INSTALL_BASENAME
copy_and_replace "${SCRIPT_DIR}"/../modules/"${COMMON_MODULEFILE}" "${CONDA_MODULE_PATH}"/."${COMMON_MODULEFILE}" CONDA_BASE APPS_SUBDIR CONDA_INSTALL_BASENAME SCRIPT_SUBDIR
copy_and_replace "${SCRIPT_DIR}"/launcher_conf.sh "${CONDA_SCRIPT_PATH}"/launcher_conf.sh CONDA_BASE APPS_SUBDIR CONDA_INSTALL_BASENAME CONDA_SCRIPT_PATH FULLENV

### Create symlink tree
mkdir -p "${CONDA_SCRIPT_PATH}"/"${FULLENV}".d/{bin,overrides}
cp "${CONDA_SCRIPT_PATH}"/{launcher.sh,launcher_conf.sh} "${CONDA_SCRIPT_PATH}"/"${FULLENV}".d/bin
pushd "${CONDA_SCRIPT_PATH}"/"${FULLENV}".d/bin
for i in $( ls "${ENV_INSTALLATION_PATH}"/bin ); do
ln -s launcher.sh $i
done
if [ "${#launcher_commands[@]}" -gt 0 ]; then
# Only create launcher symlinks for the specified commands
for cmd in "${launcher_commands[@]}"; do
ln -s launcher.sh $cmd
done
else
# Create a launcher symlinks for each executable in the bin directory
for i in $( ls "${ENV_INSTALLATION_PATH}"/bin ); do
ln -s launcher.sh $i
done
fi

### Add in the outside commands
for i in "${outside_commands_to_include[@]}"; do
Expand Down Expand Up @@ -225,7 +233,7 @@ fi


if [[ "${DO_UPDATE}" == "--install" ]]; then
ln -s .common_v3 "${CONDA_OUTER_BASE}"/"${MODULE_SUBDIR}"/"${MODULE_NAME}"/"${MODULE_VERSION}"
ln -s ."${COMMON_MODULEFILE}" "${CONDA_OUTER_BASE}"/"${MODULE_SUBDIR}"/"${MODULE_NAME}"/"${MODULE_VERSION}"
fi

pushd "${CONDA_TEMP_PATH}"
Expand Down
3 changes: 3 additions & 0 deletions scripts/install_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export CONDA_INSTALL_BASENAME="base_conda" #TODO: Eventually replace with conda
# so payu modules are named payu/$MODULE_VERSION (e.g. payu/1.1.5)
export MODULE_NAME="conda"

# Common modulefile to use for conda environments
export COMMON_MODULEFILE="common_cmd_v1"

### Derived locations - extra '.' for arcane rsync magic
export CONDA_SCRIPT_PATH="${CONDA_BASE}"/./"${SCRIPT_SUBDIR}"
export CONDA_MODULE_PATH="${CONDA_BASE}"/./"${MODULE_SUBDIR}"/"${MODULE_NAME}"
Expand Down
11 changes: 6 additions & 5 deletions scripts/launcher_conf.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
### Subject to change
export SINGULARITY_BINARY_PATH="/opt/singularity/bin/singularity"
export CONTAINER_PATH="__CONDA_BASE__/__APPS_SUBDIR__/__CONDA_INSTALL_BASENAME__/etc/base.sif"
if [[ "${CONDA_EXE}" ]]; then
export CONDA_BASE_ENV_PATH="${CONDA_EXE//\/bin\/micromamba/}"
else
export CONDA_BASE_ENV_PATH="__CONDA_BASE__/__APPS_SUBDIR__/__CONDA_INSTALL_BASENAME__"
fi

export CONDA_BASE_ENV_PATH="__CONDA_BASE__/__APPS_SUBDIR__/__CONDA_INSTALL_BASENAME__"

declare -a bind_dirs=( "/etc" "/half-root" "/local" "/ram" "/run" "/system" "/usr" "/var/lib/sss" "/var/run/munge" "/sys/fs/cgroup" "/iointensive" )

# Set up the environment launcher script path - useful for scripts, such as payu,
# to know how launch the container directly
export ENV_LAUNCHER_SCRIPT_PATH="__CONDA_SCRIPT_PATH__/__FULLENV__.d/bin/launcher.sh"
Loading