research-rainfallradar/rainfallwrangler/slurm-process.job

85 lines
2.7 KiB
Plaintext
Raw Normal View History

2022-11-01 18:56:27 +00:00
#!/usr/bin/env bash
2022-11-04 17:11:10 +00:00
#SBATCH -J RWrangle
2022-11-01 18:56:27 +00:00
#SBATCH -N 1
#SBATCH -n 1
2022-11-04 17:11:10 +00:00
#SBATCH -o %j.%N.%a.rainwrangle.out.log
#SBATCH -e %j.%N.%a.rainwrangle.err.log
2022-11-01 18:56:27 +00:00
#SBATCH -p compute
#SBATCH --time=3-00:00:00
#SBATCH --mem=8096
# * 8GB RAM
2022-11-01 19:57:15 +00:00
set -e;
2022-11-01 18:56:27 +00:00
module load utilities/multi
module load readline/7.0
module load gcc/10.2.0
# module load cuda/11.5.0
module load python/anaconda/4.6/miniconda/3.7
RAINFALL="${RAINFALL:-$HOME/data/nimrod_ceda.jsonl.gz}";
WATER="${WATER:-$HOME/data/WaterDepths-new.stream.asc.gz}";
OUTPUT="${OUTPUT}";
2022-11-01 19:57:15 +00:00
COUNT_FILE="${COUNT_FILE:-4096}";
2022-11-01 18:56:27 +00:00
if [[ -z "${WATER}" ]]; then
echo "Error: No input water depth file specified in the WATER environment variable.";
exit 1;
fi
if [[ -z "${RAINFALL}" ]]; then
echo "Error: No input rainfall file specified in the RAINFALL environment variables.";
exit 1;
fi
if [[ -z "${OUTPUT}" ]]; then
echo "Error: No output directory specified in the OUTPUT environment variable.";
exit 1;
fi
if [[ ! -r "${RAINFALL}" ]]; then
echo "Error: That input rainfall file either doesn't exist, isn't a directory, or we don't have permission to access it.";
exit 3;
fi
if [[ ! -r "${WATER}" ]]; then
echo "Error: That input water depth file either doesn't exist, isn't a directory, or we don't have permission to access it.";
exit 3;
fi
2022-11-01 18:56:27 +00:00
if [[ ! -d "${OUTPUT}" ]]; then
2022-11-01 19:38:04 +00:00
mkdir "${OUTPUT}";
2022-11-01 18:56:27 +00:00
fi
export PATH=$HOME/software/bin:$PATH;
OUTPUT_UNIQ="${OUTPUT%/}_uniq"; # Stript trailing slash, if present
OUTPUT_TFRECORD="${OUTPUT%/}_tfrecord"; # Stript trailing slash, if present
2022-11-01 19:55:04 +00:00
mkdir -p "${OUTPUT_UNIQ}" "${OUTPUT_TFRECORD}";
2022-11-01 19:38:04 +00:00
2022-11-01 18:56:27 +00:00
echo ">>> Settings";
echo "RAINFALL $RAINFALL";
echo "WATER $WATER";
echo "OUTPUT $OUTPUT";
2022-11-01 19:55:04 +00:00
echo "COUNT_FILE $COUNT_FILE";
2022-11-01 18:56:27 +00:00
echo "ARGS $ARGS";
echo ">>> Installing requirements";
cd ../aimodel || { echo "Error: Failed to cd to ai model directory"; exit 1; };
conda run -n py38 pip install -r requirements.txt;
cd ../rainfallwrangler || { echo "Error: Failed to cd back to rainfallwrangler directory"; exit 1; };
npm install;
echo ">>> Converting dataset to .jsonl.gz";
/usr/bin/env time -v src/index.mjs recordify --verbose --rainfall "${RAINFALL}" --water "${WATER}" --output "${OUTPUT}" --count-file "${COUNT_FILE}" ${ARGS};
echo ">>> Deduplicating dataset";
# This also automatically recompresses for us - hence the source/target rather than in-place
2022-11-04 17:42:50 +00:00
srun --comment 'RainUniq' --exclusive -p compute --exclusive /usr/bin/env time -v src/index.mjs uniq --source "${OUTPUT}" --target "${OUTPUT_UNIQ}" --count-file "${COUNT_FILE}";
2022-11-01 18:56:27 +00:00
echo ">>> Removing intermediate output";
rm -r "${OUTPUT}";
echo ">>> Queuing .jsonl.gz → tfrecord";
INPUT="${OUTPUT_UNIQ}" OUTPUT="${OUTPUT_TFRECORD}" sbatch ./slurm-jsonl2tfrecord.job;
echo ">>> exited with code $?";