retry_env.sh 984 B

12345678910111213141516171819202122232425262728
  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. pip install -e .
  9. python -m pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
  10. pip install modelscope
  11. wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/scripts/download_models.py -O download_models.py
  12. python download_models.py
  13. exit_code=$?
  14. if [ $exit_code -eq 0 ]; then
  15. echo "test.sh 成功执行!"
  16. break
  17. else
  18. let retry_count+=1
  19. if [ $retry_count -ge $max_retries ]; then
  20. echo "达到最大重试次数 ($max_retries),放弃重试。"
  21. exit 1
  22. fi
  23. echo "test.sh 执行失败 (退出码: $exit_code)。尝试第 $retry_count 次重试..."
  24. sleep 5
  25. fi
  26. done