-
Notifications
You must be signed in to change notification settings - Fork 61
[WIP] Scripts for generating easystacks based on an existing stack #1035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
bedroge
wants to merge
9
commits into
EESSI:2023.06-software.eessi.io
from
bedroge:dump_stack_to_easystacks
Closed
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
adde35f
initial version/draft of scripts for generating easystacks based on a…
bedroge ef7f671
remove head -n 3 command
bedroge c5b1aa0
Added parallel version of stack_to_json, and added script to also sup…
84817f0
I don't believe this bootstrap is needed, we should be able to instal…
cebdf18
Updated EB bootstrap version and reactivate using the bootstrap
7cc477f
Make sure the easystack duration gets prepended to the easystack file…
56ae512
Print the durations to stdout at teh end of the script
a3c0cdf
don't use easyconfig from `reprod`
bedroge c08a472
don't use easyconfig from `reprod`
bedroge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
scripts/generate_easystacks_for_existing_stack/json_to_easystacks.sh
This file contains hidden or 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,28 @@ | ||
#!/bin/bash | ||
|
||
input_file=$1 | ||
|
||
prev_eb_version="0.0.0" | ||
#prev_toolchain="none" | ||
easystack_num=0 | ||
|
||
while read app | ||
do | ||
eval $(echo $app | jq -r '. | to_entries | .[] | .key + "=" + (.value | @sh)') | ||
|
||
#if [[ ${prev_toolchain} != ${toolchain} ]] || [[ ${prev_eb_version} != ${easybuild} ]]; then | ||
if [[ ${prev_eb_version} != ${easybuild} ]]; then | ||
easystack_num=$(( easystack_num + 1)) | ||
#prev_toolchain=${toolchain} | ||
prev_eb_version=${easybuild} | ||
fi | ||
|
||
#easystack="$(printf '%03d\n' ${easystack_num})-eb-${easybuild}-${toolchain}.yml" | ||
easystack="$(printf '%03d\n' ${easystack_num})-eb-${easybuild}.yml" | ||
if [ ! -f "${easystack}" ]; then | ||
echo "easyconfigs:" > ${easystack} | ||
fi | ||
echo " - ${easyconfig}:" >> ${easystack} | ||
echo " options:" >> ${easystack} | ||
echo " include-easyblocks: ${easyblocks}" >> ${easystack} | ||
done < <(jq -c '.[]' ${input_file}) |
84 changes: 84 additions & 0 deletions
84
scripts/generate_easystacks_for_existing_stack/stack_to_json.sh
This file contains hidden or 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,84 @@ | ||
#!/bin/bash | ||
|
||
DEBUG=0 | ||
BASE_STACK=/cvmfs/software.eessi.io/versions/2023.06/software/linux/x86_64/intel/haswell/software | ||
EB_BOOTSTRAP=4.9.4 | ||
|
||
declare -A gcc_to_foss=( ["12.2.0"]="2022b" ["12.3.0"]="2023a" ["13.2.0"]="2023b" ) | ||
|
||
if [[ ! -d ${BASE_STACK} ]]; then | ||
echo "The given base stack (${BASE_STACK}) is not a directory." | ||
exit 1 | ||
fi | ||
|
||
apps=$(find ${BASE_STACK} -mindepth 2 -maxdepth 2 -type d) | ||
|
||
json_output="[" | ||
for app_dir in $apps; do | ||
app_version=$(basename ${app_dir}) | ||
app_name=$(basename $(dirname ${app_dir})) | ||
|
||
if [[ ${app_name} == "EESSI-extend" ]]; then | ||
# Skip EESSI-extend, as it will be installed automatically. | ||
continue | ||
fi | ||
|
||
easyblocks=${app_dir}/easybuild/reprod/easyblocks/*.py | ||
easyconfig=${app_dir}/easybuild/reprod/${app_name}-${app_version}.eb | ||
if [[ ! -f ${easyconfig} ]]; then | ||
echo "ERROR: cannot find easyconfig for ${app_name}/${app_version}" | ||
fi | ||
# If rebuilds would not remove the original log file, we should take the build time from the first log. | ||
# As we cannot guarantee that at the moment, we are cautious and use the last one. | ||
log_file=$(ls -1 ${app_dir}/easybuild/easybuild-${app_name}*.log* | tail -n 1) | ||
build_time_start=$(bzcat ${log_file} | head -n 1 | awk '{print $2 "T" $3}' | cut -d, -f1) | ||
build_time_end=$(bzcat ${log_file} | tail -n 1 | awk '{print $2 "T" $3}' | cut -d, -f1) | ||
#build_time_unix=$( date +%s -d ${build_time}) | ||
build_duration=$(( ($(date +%s -d ${build_time_end}) - $(date +%s -d ${build_time_start}))/60 )) | ||
|
||
eb_version=$(bzgrep -oP "This is EasyBuild \K([0-9].[0-9].[0-9])" ${log_file} | head -n 1) | ||
# Some EB versions have been installed with a temporary EB installation of the same version. | ||
# If that's the case, use the version specified with ${EB_BOOTSTRAP} instead. | ||
# This needs to correspond to the version that gets installed initially by EESSI-install-software.sh, | ||
# which should be the latest EB version available when that script is being run. | ||
if [[ ${app_name} == "EasyBuild" ]] && [[ ${app_version} == ${eb_version} ]]; then | ||
eb_version=${EB_BOOTSTRAP} | ||
fi | ||
|
||
if [[ ${app_version} != *-* ]]; then | ||
toolchain=SYSTEM | ||
else | ||
if [[ ${app_version} == *-GCC* ]]; then | ||
gcc_ver=$(echo ${app_version} | grep -oP "(GCC|GCCcore)-\K.*?(?=-|$)") | ||
toolchain=${gcc_to_foss[$gcc_ver]} | ||
else | ||
toolchain=$(echo ${app_version} | grep -oP "(foss|gfbf|gompi)-\K.*?(?=-|$)") | ||
fi | ||
fi | ||
|
||
json=$( | ||
jq --null-input \ | ||
--arg build_time "${build_time_start}" \ | ||
--arg build_duration_minutes "${build_duration}" \ | ||
--arg name "${app_name}" \ | ||
--arg version "${app_version}" \ | ||
--arg easybuild "${eb_version}" \ | ||
--arg toolchain "${toolchain}" \ | ||
--arg easyconfig "${easyconfig}" \ | ||
--arg easyblocks "${easyblocks}" \ | ||
'$ARGS.named' # requires jq 1.7 or newer | ||
#'{build_time: $build_time, build_duration_minutes: $build_duration, name: $name, version: $version, easybuild: $easybuild, | ||
# toolchain: $toolchain, easyconfig: $easyconfig, easyblocks: $easyblocks}' | ||
) | ||
|
||
if [[ ${json_output} == "[" ]]; then | ||
json_output="${json_output}${json}" | ||
else | ||
json_output="${json_output},${json}" | ||
fi | ||
[[ ${DEBUG} -ne 0 ]] && echo ${build_time_unix} ${app_name} ${app_version} ${eb_version} ${toolchain} ${easyconfig} ${easyblocks} | ||
done #| sort -nu | ||
json_output="${json_output}]" | ||
|
||
[[ ${DEBUG} -ne 0 ]] && echo ${json_output} | ||
echo ${json_output} | jq 'sort_by(.build_time)' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.