forked from SiVeGCS/dask_template
41 lines
1.2 KiB
Bash
41 lines
1.2 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
# Check if a destination and environment name are provided
|
||
|
if [ "$#" -ne 2 ]; then
|
||
|
echo "Usage: $0 <environment_name> <destination_directory>"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# Name of the Conda environment
|
||
|
CONDA_ENV_NAME="$1"
|
||
|
TAR_FILE="$CONDA_ENV_NAME.tar.gz"
|
||
|
|
||
|
# Check if the tar.gz file already exists
|
||
|
if [ -e "$TAR_FILE" ]; then
|
||
|
echo "Using existing $TAR_FILE"
|
||
|
else
|
||
|
# Pack the Conda environment if the file doesn't exist
|
||
|
conda pack -n "$CONDA_ENV_NAME" -o "$TAR_FILE"
|
||
|
fi
|
||
|
|
||
|
# Parse the destination host and directory
|
||
|
DESTINATION=$2
|
||
|
IFS=':' read -ra DEST <<< "$DESTINATION"
|
||
|
DEST_HOST="${DEST[0]}"
|
||
|
DEST_DIR="${DEST[1]}"
|
||
|
|
||
|
# Copy the environment tarball to the remote server
|
||
|
scp "$TAR_FILE" "$DEST_HOST":"$DEST_DIR"
|
||
|
scp deploy-dask.sh "$DEST_HOST":"$DEST_DIR"
|
||
|
scp dask-worker.sh "$DEST_HOST":"$DEST_DIR"
|
||
|
|
||
|
echo "Conda environment '$CONDA_ENV_NAME' packed and deployed to '$DEST_HOST:$DEST_DIR' as '$TAR_FILE'."
|
||
|
|
||
|
# Ask the user if they want to delete the tar.gz file
|
||
|
read -p "Do you want to delete the local tar.gz file? (y/n): " answer
|
||
|
if [ "$answer" == "y" ]; then
|
||
|
rm "$TAR_FILE"
|
||
|
echo "Local tar.gz file deleted."
|
||
|
else
|
||
|
echo "Local tar.gz file not deleted."
|
||
|
fi
|