|
54 | 54 | from easybuild.framework.easyconfig.parser import EasyConfigParser
|
55 | 55 | from easybuild.tools import LooseVersion
|
56 | 56 | from easybuild.tools.build_log import EasyBuildError, EasyBuildExit, print_msg, print_warning
|
57 |
| -from easybuild.tools.config import build_option |
| 57 | +from easybuild.tools.config import DEFAULT_DOWNLOAD_MAX_ATTEMPTS, build_option |
58 | 58 | from easybuild.tools.filetools import apply_patch, copy_dir, copy_easyblocks, copy_file, copy_framework_files
|
59 | 59 | from easybuild.tools.filetools import det_patched_files, download_file, extract_file
|
60 | 60 | from easybuild.tools.filetools import get_easyblock_class_name, mkdir, read_file, symlink, which, write_file
|
@@ -545,9 +545,16 @@ def fetch_files_from_pr(pr, path=None, github_user=None, github_account=None, gi
|
545 | 545 | github_user=github_user)
|
546 | 546 |
|
547 | 547 | # determine list of changed files via diff
|
548 |
| - diff_fn = os.path.basename(pr_data['diff_url']) |
| 548 | + diff_url = pr_data['diff_url'] |
| 549 | + diff_fn = os.path.basename(diff_url) |
549 | 550 | diff_filepath = os.path.join(path, diff_fn)
|
550 |
| - download_file(diff_fn, pr_data['diff_url'], diff_filepath, forced=True, trace=False) |
| 551 | + # max. 6 attempts + initial wait time of 10sec -> max. 10 * (2^6) = 640sec (~10min) before giving up on download |
| 552 | + # see also https://github.com/easybuilders/easybuild-framework/issues/4869 |
| 553 | + max_attempts = DEFAULT_DOWNLOAD_MAX_ATTEMPTS |
| 554 | + download_file(diff_fn, diff_url, diff_filepath, forced=True, trace=False, |
| 555 | + max_attempts=max_attempts) |
| 556 | + if not os.path.exists(diff_filepath): |
| 557 | + raise EasyBuildError(f"Failed to download {diff_url}, even after {max_attempts} attempts and being patient...") |
551 | 558 | diff_txt = read_file(diff_filepath)
|
552 | 559 | _log.debug("Diff for PR #%s:\n%s", pr, diff_txt)
|
553 | 560 |
|
@@ -699,17 +706,21 @@ def fetch_files_from_commit(commit, files=None, path=None, github_account=None,
|
699 | 706 | diff_url = os.path.join(GITHUB_URL, github_account, github_repo, 'commit', commit + '.diff')
|
700 | 707 | diff_fn = os.path.basename(diff_url)
|
701 | 708 | diff_filepath = os.path.join(path, diff_fn)
|
702 |
| - if download_file(diff_fn, diff_url, diff_filepath, forced=True, trace=False): |
| 709 | + # max. 6 attempts + initial wait time of 10sec -> max. 10 * (2^6) = 640sec (~10min) before giving up on download |
| 710 | + # see also https://github.com/easybuilders/easybuild-framework/issues/4869 |
| 711 | + max_attempts = DEFAULT_DOWNLOAD_MAX_ATTEMPTS |
| 712 | + download_file(diff_fn, diff_url, diff_filepath, forced=True, trace=False, |
| 713 | + max_attempts=max_attempts) |
| 714 | + if os.path.exists(diff_filepath): |
703 | 715 | diff_txt = read_file(diff_filepath)
|
704 | 716 | _log.debug("Diff for commit %s:\n%s", commit, diff_txt)
|
705 | 717 |
|
706 | 718 | files = det_patched_files(txt=diff_txt, omit_ab_prefix=True, github=True, filter_deleted=True)
|
707 | 719 | _log.debug("List of patched files for commit %s: %s", commit, files)
|
708 | 720 | else:
|
709 |
| - raise EasyBuildError( |
710 |
| - "Failed to download diff for commit %s of %s/%s", commit, github_account, github_repo, |
711 |
| - exit_code=EasyBuildExit.FAIL_GITHUB |
712 |
| - ) |
| 721 | + msg = f"Failed to download diff for commit {commit} of {github_account}/{github_repo} " |
| 722 | + msg += " (after {max_attempts} attempts)" |
| 723 | + raise EasyBuildError(msg, exit_code=EasyBuildExit.FAIL_GITHUB) |
713 | 724 |
|
714 | 725 | # download tarball for specific commit
|
715 | 726 | repo_commit = download_repo(repo=github_repo, commit=commit, account=github_account)
|
|
0 commit comments