retry_env.sh 950 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. max_retries=5
  3. retry_count=0
  4. while true; do
  5. # prepare env
  6. #python -m pip install -r requirements-qa.txt
  7. python -m pip install -U magic-pdf[full] --extra-index-url https://wheels.myhloli.com -i https://mirrors.aliyun.com/pypi/simple
  8. python -m pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
  9. pip install modelscope
  10. wget https://gitee.com/myhloli/MinerU/raw/master/scripts/download_models.py -O download_models.py
  11. python download_models.py
  12. exit_code=$?
  13. if [ $exit_code -eq 0 ]; then
  14. echo "test.sh 成功执行!"
  15. break
  16. else
  17. let retry_count+=1
  18. if [ $retry_count -ge $max_retries ]; then
  19. echo "达到最大重试次数 ($max_retries),放弃重试。"
  20. exit 1
  21. fi
  22. echo "test.sh 执行失败 (退出码: $exit_code)。尝试第 $retry_count 次重试..."
  23. sleep 5
  24. fi
  25. done