Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Apr 30, 2024
1 parent 052e108 commit 4146e2b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
22 changes: 0 additions & 22 deletions scripts/create_environments.sh

This file was deleted.

30 changes: 30 additions & 0 deletions scripts/update_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

if [ $# -lt 1 ]; then
echo "please specify the environments (i.e., 'wp3', 'wp4', and/or 'wp5')"
exit 1
fi

create_environment ()(
URL1="https://raw.githubusercontent.com/bopen/c3s-eqc-toolbox-template/main/environment.yml"
URL2="https://raw.githubusercontent.com/bopen/c3s-eqc-toolbox-template/main/environments/environment_$1.yml"
DATE=$(date --iso-8601=seconds)
TMP1=$(mktemp --suffix=.yml)
TMP2=$(mktemp --suffix=.yml)
TMP_MERGED=$(mktemp --suffix=.yml)
wget -O "$TMP1" "$URL1"
wget -O "$TMP2" "$URL2"
conda run conda-merge "$TMP1" "$TMP2" > "$TMP_MERGED"
mamba env create -n "$1" -f "$TMP_MERGED" --yes || exit
# mamba env update -n "$1" -f "$TMP_MERGED" --prune || exit
mkdir -p yml_files
conda env export -n "$1" --file yml_files/environment_"$1"_"$DATE".yml --no-build
rm -f "$TMP1" "$TMP2" "$TMP_MERGED"
)

mamba update -n base conda mamba --yes
mamba install -c conda-forge conda-merge --yes
for WP in "$@"; do
create_environment "$WP" || exit
done
conda clean --all --yes

0 comments on commit 4146e2b

Please sign in to comment.