turkic-ocr-code / scripts /release2 /rel2_d5_data.sbatch
treoa's picture
Release 1
24aaa76
Raw History Blame Contribute Delete
4.94 kB
#!/bin/bash
#SBATCH --job-name=rel2_d5_data
#SBATCH --partition=ZEN4
#SBATCH --qos=nu-zen4
#SBATCH --gres=none
#SBATCH --cpus-per-task=4
#SBATCH --mem=8G
#SBATCH --time=01:00:00
#SBATCH --output=/path/to/TURKIC_OCR_DATA/logs/%x_%j.out
# RELEASE2 D5 finish, data packages: owner decisions of 26 Nov 2026 (D1/D2: real data sets cited with where to obtain them; D8: licensor,
# copyright line and citation). Replaces datasheet.json and LICENSE in DATA/release/rc1_data and DATA/release/rc1_data_parquet, updates
# their two SHA256SUMS lines the way rel2_decide (job 55668) did, verifies every file in full and checks that no file is outside the sums.
# Preconditions (abort with nothing changed): the installed datasheet and LICENSE are the expected files; the staged files have the
# expected sha256 and name no cluster path or user; no backup folder exists. Backups: DATA/release/rc1_data_before_d5/. Nothing is uploaded.
set -u
D=/path/to/TURKIC_OCR_DATA
S=$D/tmp/release2/d5_finish/stage/data
B=$D/release/rc1_data_before_d5
P1=$D/release/rc1_data
P2=$D/release/rc1_data_parquet
DS_OLD=8b7240db503ab829bdbcda4e21e446fc44d64b619ea59b807cb48286a316c660
LIC_OLD=9876343cc676afb26d717943c5f90d726150c162e56285c63ebf268612eb158f
DS_NEW=f5567430b73a5a4963512780e8dfcb3e878d5ed29d609f5d5197cbbfb6fdd729
LIC_NEW=a81225134df5a6d4c3d57895e9f6d0f2fb0ab9fa678629bae86ec82ec7d15d2c
SCRUB='/datahub|/shared/home|CLUSTER_GROUP|CLUSTER_USER|LOCAL_USER|/Users/|/private/'
die() { echo "ABORT: $*"; exit 1; }
h() { sha256sum "$1" | cut -d' ' -f1; }
echo "job $SLURM_JOB_ID host $(hostname) start $(date -u +%FT%TZ)"
echo "== 0 preconditions"
test "$(h $P1/datasheet.json)" = "$DS_OLD" || die "rc1_data datasheet differs; nothing changed"
test "$(h $P2/datasheet.json)" = "$DS_OLD" || die "rc1_data_parquet datasheet differs; nothing changed"
test "$(h $P1/LICENSE)" = "$LIC_OLD" || die "rc1_data LICENSE differs; nothing changed"
test "$(h $P2/LICENSE)" = "$LIC_OLD" || die "rc1_data_parquet LICENSE differs; nothing changed"
test "$(h $S/datasheet.json)" = "$DS_NEW" || die "staged datasheet differs; nothing changed"
test "$(h $S/LICENSE)" = "$LIC_NEW" || die "staged LICENSE differs; nothing changed"
grep -l -i -E "$SCRUB" $S/datasheet.json $S/LICENSE && die "a staged file names a cluster path or user; nothing changed"
grep -l -E "LICENSOR:|authors of this release" $S/datasheet.json $S/LICENSE && die "a staged file still holds a licensor placeholder; nothing changed"
test ! -e $B || die "$B exists; nothing changed"
echo "sums lines before: rc1_data $(wc -l < $P1/SHA256SUMS), rc1_data_parquet $(wc -l < $P2/SHA256SUMS)"
echo "preconditions ok"
echo "== 1 backups"
mkdir -p $B/rc1_data $B/rc1_data_parquet
cp -p $P1/datasheet.json $P1/LICENSE $P1/SHA256SUMS $B/rc1_data/
cp -p $P2/datasheet.json $P2/LICENSE $P2/SHA256SUMS $B/rc1_data_parquet/
ls -l $B/rc1_data $B/rc1_data_parquet
echo "== 2 rc1_data"
cp $S/datasheet.json $P1/datasheet.json
cp $S/LICENSE $P1/LICENSE
chmod a+r $P1/datasheet.json $P1/LICENSE
cd $P1
grep -v -E " (datasheet.json|LICENSE)$" SHA256SUMS > $D/tmp/release2/d5_finish/data_sums_1.tmp
sha256sum datasheet.json LICENSE >> $D/tmp/release2/d5_finish/data_sums_1.tmp
sort -k2 $D/tmp/release2/d5_finish/data_sums_1.tmp > SHA256SUMS
chmod a+r SHA256SUMS
sha256sum -c --quiet SHA256SUMS && echo "data_sha256sums_ok rc1_data files $(wc -l < SHA256SUMS)"
echo "files_not_in_sums rc1_data $(find . -type f ! -name SHA256SUMS -printf '%P\n' | sort | comm -23 - <(cut -c67- SHA256SUMS | sort) | wc -l)"
echo "changed_lines rc1_data: $(diff <(sort -k2 $B/rc1_data/SHA256SUMS) <(sort -k2 SHA256SUMS) | grep '^>' | cut -c69- | tr '\n' ' ')"
echo "rc1_data datasheet $(h datasheet.json) LICENSE $(h LICENSE)"
echo "== 3 rc1_data_parquet"
cp $S/datasheet.json $P2/datasheet.json
cp $S/LICENSE $P2/LICENSE
chmod a+r $P2/datasheet.json $P2/LICENSE
cd $P2
grep -v -E " (datasheet.json|LICENSE)$" SHA256SUMS > $D/tmp/release2/d5_finish/data_sums_2.tmp
sha256sum datasheet.json LICENSE >> $D/tmp/release2/d5_finish/data_sums_2.tmp
sort -k2 $D/tmp/release2/d5_finish/data_sums_2.tmp > SHA256SUMS
chmod a+r SHA256SUMS
sha256sum -c --quiet SHA256SUMS && echo "data_sha256sums_ok rc1_data_parquet files $(wc -l < SHA256SUMS)"
echo "files_not_in_sums rc1_data_parquet $(find . -type f ! -name SHA256SUMS -printf '%P\n' | sort | comm -23 - <(cut -c67- SHA256SUMS | sort) | wc -l)"
echo "changed_lines rc1_data_parquet: $(diff <(sort -k2 $B/rc1_data_parquet/SHA256SUMS) <(sort -k2 SHA256SUMS) | grep '^>' | cut -c69- | tr '\n' ' ')"
echo "rc1_data_parquet datasheet $(h datasheet.json) LICENSE $(h LICENSE)"
echo "== 4 left over"
echo "licensor placeholders left in top-level text files (build_report.json keeps the build-time LICENSE text as a record):"
grep -l -E "LICENSOR:|authors of this release" $P1/* $P2/* $P1/attribution/* $P2/attribution/* $P1/excluded/* $P2/excluded/* 2>/dev/null
chmod -R a+rX $B
echo "end $(date -u +%FT%TZ)"