File size: 3,475 Bytes
24aaa76 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #!/bin/bash
#SBATCH --job-name=rel2_cards
#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 job D. Weights are never touched.
# 1 back up the rc1 model cards and SHA256SUMS to DATA/release/rc1_cards_before_release2/<package>/
# 2 install the extended model_card.json of every package (prepared in DATA/tmp/release2/cards_new/<package>/)
# 3 remove the stray __pycache__ folder that appeared in turkic-ocr-ppocrv6-medium after the rc1 check (not part of the package)
# 4 rewrite SHA256SUMS of every package (all files except SHA256SUMS) and verify it; record the weights hashes before and after
# 5 copy datasheet.json into DATA/release/rc1_data and add it to that package's SHA256SUMS; verify the whole data package
set -u
D=/path/to/TURKIC_OCR_DATA
R=$D/release/rc1
B=$D/release/rc1_cards_before_release2
S=$D/tmp/release2/cards_new
P=$D/release/rc1_data
echo "job $SLURM_JOB_ID host $(hostname) start $(date -u +%Y-%m-%dT%H:%M:%SZ)"
mkdir -p $B
# pre-check: every card on disk must be the card the extension was built on; otherwise change nothing
for pkg in turkic-ocr-paddleocr-vl-1.6 turkic-ocr-qwen3-vl-2b turkic-ocr-ppocrv6-medium turkic-line-detector-yolo11s page-pipeline; do
want=$(grep "^$pkg " $S/expected_old_card_sha256.txt | cut -d' ' -f2)
have=$(sha256sum $R/$pkg/model_card.json | cut -d' ' -f1)
if [ "$want" != "$have" ]; then echo "ABORT $pkg: card on disk $have differs from the card the extension was built on $want; nothing changed"; exit 1; fi
done
for pkg in turkic-ocr-paddleocr-vl-1.6 turkic-ocr-qwen3-vl-2b turkic-ocr-ppocrv6-medium turkic-line-detector-yolo11s page-pipeline; do
echo "== $pkg"
mkdir -p $B/$pkg
cp -p $R/$pkg/model_card.json $R/$pkg/SHA256SUMS $B/$pkg/
for w in model/model.safetensors best.pt lm/char6.klm; do
if [ -f $R/$pkg/$w ]; then echo "weights_before $pkg $w $(sha256sum $R/$pkg/$w | cut -d' ' -f1)"; fi
done
cp $S/$pkg/model_card.json $R/$pkg/model_card.json
if [ -d $R/$pkg/__pycache__ ]; then echo "removing stray $pkg/__pycache__: $(ls $R/$pkg/__pycache__)"; rm -rf $R/$pkg/__pycache__; fi
cd $R/$pkg
rm -f SHA256SUMS
find . -type f | sort | xargs sha256sum > $D/tmp/release2/sums_$pkg.tmp
cp $D/tmp/release2/sums_$pkg.tmp SHA256SUMS
chmod a+r SHA256SUMS model_card.json
echo "files $(wc -l < SHA256SUMS)"
sha256sum -c --quiet SHA256SUMS && echo "sha256sums_ok $pkg"
for w in model/model.safetensors best.pt lm/char6.klm; do
if [ -f $R/$pkg/$w ]; then echo "weights_after $pkg $w $(sha256sum $R/$pkg/$w | cut -d' ' -f1)"; fi
done
echo "card_sha256 $pkg $(sha256sum model_card.json | cut -d' ' -f1)"
done
if [ -d $P ] && [ -f $S/datasheet.json ]; then
cp $S/datasheet.json $P/datasheet.json
chmod a+r $P/datasheet.json
cd $P
grep -v " datasheet.json$" SHA256SUMS > $D/tmp/release2/data_sums.tmp
sha256sum datasheet.json >> $D/tmp/release2/data_sums.tmp
sort -k2 $D/tmp/release2/data_sums.tmp > SHA256SUMS
echo "data package files $(wc -l < SHA256SUMS)"
sha256sum -c --quiet SHA256SUMS && echo "data_sha256sums_ok"
echo "datasheet_sha256 $(sha256sum datasheet.json | cut -d' ' -f1)"
echo "files_not_in_sums $(find . -type f ! -name SHA256SUMS -printf '%P\n' | sort | comm -23 - <(cut -c67- SHA256SUMS | sort) | wc -l)"
fi
chmod -R a+rX $R $P 2>/dev/null
echo "end $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|