mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-18 19:46:44 +08:00
Fix: pipeline ignore MinerU backend config and vllm module is missing (#11955)
### What problem does this PR solve? Fix pipeline ignore MinerU backend config and vllm module is missing. #11944, #11947. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -209,23 +209,42 @@ function ensure_mineru() {
|
|||||||
local default_prefix="/ragflow/uv_tools"
|
local default_prefix="/ragflow/uv_tools"
|
||||||
local venv_dir="${default_prefix}/.venv"
|
local venv_dir="${default_prefix}/.venv"
|
||||||
local exe="${MINERU_EXECUTABLE:-${venv_dir}/bin/mineru}"
|
local exe="${MINERU_EXECUTABLE:-${venv_dir}/bin/mineru}"
|
||||||
|
local mineru_backend="${MINERU_BACKEND:-pipeline}"
|
||||||
|
local mineru_pkg="mineru[core]"
|
||||||
|
|
||||||
|
if [[ "${mineru_backend}" == vlm-* ]]; then
|
||||||
|
mineru_pkg="mineru[core,vlm]"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -x "${exe}" ]]; then
|
if [[ -x "${exe}" ]]; then
|
||||||
echo "[mineru] found: ${exe}"
|
echo "[mineru] found: ${exe} (MINERU_BACKEND=${mineru_backend})"
|
||||||
export MINERU_EXECUTABLE="${exe}"
|
export MINERU_EXECUTABLE="${exe}"
|
||||||
|
|
||||||
|
if [[ "${mineru_backend}" == vlm-* ]]; then
|
||||||
|
if ! "${venv_dir}/bin/python3" -c "import importlib.util, sys; sys.exit(0 if importlib.util.find_spec('vllm') else 1)" >/dev/null 2>&1; then
|
||||||
|
echo "[mineru] vllm not found for MINERU_BACKEND=${mineru_backend}, installing ${mineru_pkg} ..."
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
source "${venv_dir}/bin/activate"
|
||||||
|
uv pip install -U "${mineru_pkg}" -i https://mirrors.aliyun.com/pypi/simple --extra-index-url https://pypi.org/simple
|
||||||
|
deactivate
|
||||||
|
) || return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[mineru] not found, bootstrapping with uv ..."
|
echo "[mineru] not found, bootstrapping with uv ... (MINERU_BACKEND=${mineru_backend}, pkg=${mineru_pkg})"
|
||||||
|
|
||||||
(
|
(
|
||||||
set -e
|
set -e
|
||||||
mkdir -p "${default_prefix}"
|
mkdir -p "${default_prefix}"
|
||||||
cd "${default_prefix}"
|
cd "${default_prefix}"
|
||||||
[[ -d "${venv_dir}" ]] || uv venv "${venv_dir}"
|
[[ -d "${venv_dir}" ]] || { echo "[mineru] creating venv at ${venv_dir} ..."; uv venv "${venv_dir}"; }
|
||||||
|
|
||||||
|
echo "[mineru] installing ${mineru_pkg} into ${venv_dir} ..."
|
||||||
source "${venv_dir}/bin/activate"
|
source "${venv_dir}/bin/activate"
|
||||||
uv pip install -U "mineru[core]" -i https://mirrors.aliyun.com/pypi/simple --extra-index-url https://pypi.org/simple
|
uv pip install -U "${mineru_pkg}" -i https://mirrors.aliyun.com/pypi/simple --extra-index-url https://pypi.org/simple
|
||||||
deactivate
|
deactivate
|
||||||
)
|
)
|
||||||
export MINERU_EXECUTABLE="${exe}"
|
export MINERU_EXECUTABLE="${exe}"
|
||||||
|
|||||||
@ -34,18 +34,28 @@ class MinerUOcrModel(Base, MinerUParser):
|
|||||||
|
|
||||||
def __init__(self, key: str | dict, model_name: str, **kwargs):
|
def __init__(self, key: str | dict, model_name: str, **kwargs):
|
||||||
Base.__init__(self, key, model_name, **kwargs)
|
Base.__init__(self, key, model_name, **kwargs)
|
||||||
config = {}
|
raw_config = {}
|
||||||
if key:
|
if key:
|
||||||
try:
|
try:
|
||||||
config = json.loads(key)
|
raw_config = json.loads(key)
|
||||||
except Exception:
|
except Exception:
|
||||||
config = {}
|
raw_config = {}
|
||||||
config = config["api_key"]
|
|
||||||
self.mineru_api = config.get("mineru_apiserver", os.environ.get("MINERU_APISERVER", ""))
|
# nested {"api_key": {...}} from UI
|
||||||
self.mineru_output_dir = config.get("mineru_output_dir", os.environ.get("MINERU_OUTPUT_DIR", ""))
|
# flat {"MINERU_*": "..."} payload auto-provisioned from env vars
|
||||||
self.mineru_backend = config.get("mineru_backend", os.environ.get("MINERU_BACKEND", "pipeline"))
|
config = raw_config.get("api_key", raw_config)
|
||||||
self.mineru_server_url = config.get("mineru_server_url", os.environ.get("MINERU_SERVER_URL", ""))
|
if not isinstance(config, dict):
|
||||||
self.mineru_delete_output = bool(int(config.get("mineru_delete_output", os.environ.get("MINERU_DELETE_OUTPUT", 1))))
|
config = {}
|
||||||
|
|
||||||
|
def _resolve_config(key: str, env_key: str, default=""):
|
||||||
|
# lower-case keys (UI), upper-case MINERU_* (env auto-provision), env vars
|
||||||
|
return config.get(key, config.get(env_key, os.environ.get(env_key, default)))
|
||||||
|
|
||||||
|
self.mineru_api = _resolve_config("mineru_apiserver", "MINERU_APISERVER", "")
|
||||||
|
self.mineru_output_dir = _resolve_config("mineru_output_dir", "MINERU_OUTPUT_DIR", "")
|
||||||
|
self.mineru_backend = _resolve_config("mineru_backend", "MINERU_BACKEND", "pipeline")
|
||||||
|
self.mineru_server_url = _resolve_config("mineru_server_url", "MINERU_SERVER_URL", "")
|
||||||
|
self.mineru_delete_output = bool(int(_resolve_config("mineru_delete_output", "MINERU_DELETE_OUTPUT", 1)))
|
||||||
self.mineru_executable = os.environ.get("MINERU_EXECUTABLE", "mineru")
|
self.mineru_executable = os.environ.get("MINERU_EXECUTABLE", "mineru")
|
||||||
|
|
||||||
logging.info(f"Parsed MinerU config: {config}")
|
logging.info(f"Parsed MinerU config: {config}")
|
||||||
|
|||||||
Reference in New Issue
Block a user