chore(deps): let download_go_deps.py fetch Go DeepDoc .ort weights (#19376)

Go DeepDoc now uses .ort weights downloaded via download_go_deps.py — no MODEL_DIR needed from repo root. Script fetches 5 model files into rag/res/deepdoc/; supports mirrors; CI updated. .onnx path unchanged.
This commit is contained in:
xugangqiang authored and GitHub committed 2026-09-09 16:07:43 +08:00
1 parent 19acb019d8
commit 8c8253a3be
8 files changed
+256 -32

No files matched your search

+54 -8
View File
@@ -16,9 +16,17 @@
# Env:
# RAGFLOW_TESTDATA_REPO repo "owner/name" (default infiniflow/ragflow-testdata)
# RAGFLOW_TESTDATA_REF override the anchor tag/ref (else read testdata.ref)
# RAGFLOW_TESTDATA_DIR pre-seeded asset repo root (first level: deepdoc/).
# When it carries deepdoc/<pkg>/testdata, that copy is
# used as-is: no ref pinning, no network fetch. This is
# what a CI runner that mounts the asset repo should
# set; a missing subtree falls back to cloning.
# XDG_CACHE_HOME cache base (default ~/.cache)
#
# Behavior:
# - With RAGFLOW_TESTDATA_DIR set, the pre-seeded copy wins over everything
# below. The ref pin is bypassed — whoever seeds the directory owns its
# freshness.
# - If testdata is already present INLINE (a real dir, pre-migration), this
# script leaves it untouched and exits (nothing to fetch).
# - If a correct symlink already exists, it exits.
@@ -40,6 +48,49 @@ PKG="$1"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
TARGET="$ROOT/internal/deepdoc/$PKG/testdata"
# Determine whether we need a writable copy (regeneration) or a symlink.
NEED_WRITE=0
for v in "${!GEN_@}"; do
if [ -n "${!v:-}" ]; then NEED_WRITE=1; break; fi
done
# Pre-seeded testdata: CI runners mount the asset repo at a fixed path instead
# of cloning it. Use that copy directly when it carries this package's subtree.
# This runs before the ref is resolved: a pre-seeded copy carries no ref, so
# packages without a testdata.ref can be served this way too.
if [ -n "${RAGFLOW_TESTDATA_DIR:-}" ]; then
PRESET="$RAGFLOW_TESTDATA_DIR/deepdoc/$PKG/testdata"
if [ -d "$PRESET" ] && [ -n "$(ls -A "$PRESET" 2>/dev/null)" ]; then
if [ -L "$TARGET" ] && [ "$(readlink -f "$TARGET")" = "$(readlink -f "$PRESET")" ] && [ -n "$(ls -A "$PRESET" 2>/dev/null)" ]; then
echo "fetch_deepdoc_testdata: $PKG already linked to pre-seeded $PRESET"
exit 0
fi
if [ -d "$TARGET" ] && [ ! -L "$TARGET" ] && [ -n "$(ls -A "$TARGET" 2>/dev/null)" ]; then
echo "fetch_deepdoc_testdata: $PKG testdata already present inline at $TARGET"
exit 0
fi
# rm -rf, not rm -f: TARGET may be a leftover EMPTY directory (a failed
# GEN_* copy, a half-restored cache). rm -f cannot remove it, and ln -s
# would then nest the link inside it (<TARGET>/testdata) while this script
# still reports success. Both guards above have already returned for a
# non-empty real dir, so nothing real is deleted here.
rm -rf -- "$TARGET"
if [ "$NEED_WRITE" -eq 1 ]; then
echo "fetch_deepdoc_testdata: copying writable pre-seeded testdata for regeneration ($PKG)"
rm -rf "$TARGET"
cp -r "$PRESET" "$TARGET"
else
echo "fetch_deepdoc_testdata: linking $TARGET -> $PRESET (pre-seeded)"
ln -s "$PRESET" "$TARGET"
fi
echo "fetch_deepdoc_testdata: done ($PKG, pre-seeded)"
exit 0
fi
echo "fetch_deepdoc_testdata: RAGFLOW_TESTDATA_DIR set but deepdoc/$PKG/testdata is missing; falling back to clone" >&2
fi
REF_FILE="$ROOT/internal/deepdoc/$PKG/testdata.ref"
REF="${RAGFLOW_TESTDATA_REF:-}"
if [ -z "$REF" ] && [ -f "$REF_FILE" ]; then
@@ -54,13 +105,6 @@ REPO="${RAGFLOW_TESTDATA_REPO:-infiniflow/ragflow-testdata}"
CACHE_BASE="${XDG_CACHE_HOME:-$HOME/.cache}/ragflow-testdata"
CACHE="$CACHE_BASE/$REF"
SRC="$CACHE/deepdoc/$PKG/testdata"
TARGET="$ROOT/internal/deepdoc/$PKG/testdata"
# Determine whether we need a writable copy (regeneration) or a symlink.
NEED_WRITE=0
for v in "${!GEN_@}"; do
if [ -n "${!v:-}" ]; then NEED_WRITE=1; break; fi
done
# Already a correct symlink -> done.
if [ -L "$TARGET" ] && [ "$(readlink -f "$TARGET")" = "$(readlink -f "$SRC")" ] && [ -n "$(ls -A "$SRC" 2>/dev/null)" ]; then
@@ -75,7 +119,9 @@ if [ -d "$TARGET" ] && [ ! -L "$TARGET" ] && [ -n "$(ls -A "$TARGET" 2>/dev/null
fi
# Absent (or stale symlink) -> fetch.
rm -f "$TARGET" 2>/dev/null || true
# rm -rf for the same reason as the pre-seeded branch: a leftover empty
# directory must be removed, not silently turned into a nested symlink.
rm -rf -- "$TARGET"
if [ ! -e "$SRC" ] || [ -z "$(ls -A "$SRC" 2>/dev/null)" ]; then
echo "fetch_deepdoc_testdata: cloning $REPO @ $REF (subtree deepdoc/$PKG/testdata)"