-
Notifications
You must be signed in to change notification settings - Fork 312
implement custom implementation of obtain_file method in QuantumESPRESSO easyblock #618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ | |
| from easybuild.framework.easyconfig import CUSTOM | ||
| from easybuild.tools.build_log import EasyBuildError | ||
| from easybuild.tools.modules import get_software_root | ||
| from easybuild.tools.run import run_cmd | ||
|
|
||
|
|
||
| class EB_QuantumESPRESSO(ConfigureMake): | ||
|
|
@@ -62,6 +63,59 @@ def __init__(self, *args, **kwargs): | |
|
|
||
| self.install_subdir = "espresso-%s" % self.version | ||
|
|
||
| def obtain_file(self, *args, **kwargs): | ||
| """Custom implementation of obtain_file, to deal with problematic downloads from qe-forge.org.""" | ||
| filename = args[0] | ||
| source_urls = self.cfg['source_urls'] | ||
|
|
||
| # check whether file is already there, by running obtain_file without providing any source_urls | ||
| path = None | ||
| self.cfg['source_urls'] = [] | ||
| try: | ||
| path = super(EB_QuantumESPRESSO, self).obtain_file(*args, **kwargs) | ||
| except EasyBuildError, err: | ||
| self.log.debug("Ignoring expected download error: %s", err) | ||
|
|
||
| # restore source_urls value | ||
| self.cfg['source_urls'] = source_urls | ||
|
|
||
| if path: | ||
| self.log.info("Source file %s already there at %s, assuming it's OK.", filename, path) | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove empty line |
||
| elif filename.endswith('tar.gz') or filename.endswith('.tgz'): | ||
| # put copy of provided source_urls in place to play around with | ||
| kwargs.update({'urls': source_urls[:]}) | ||
|
|
||
| # if source is not available yet, try to download it | ||
| path = super(EB_QuantumESPRESSO, self).obtain_file(*args, **kwargs) | ||
|
|
||
| # check whether downloaded tarball can be unpacked | ||
| _, ec = run_cmd("tar tfz %s" % path, simple=False, log_ok=False, log_all=False) | ||
|
|
||
| # download may result in an HTML page when wrong source URL was used (rather than a proper 404 HTML code) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. woudn't the md5sum pick this up?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only if it is set, which is still a minority of the easyconfigs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, but it's a lot faster and easier to set the md5sum for the sources here then to try to fix it this way?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there's an MD5sum available, it will detect this issue, yes, but simply complain that things don't match. Checking the MD5sum if you know that the download is faulty is pretty useless. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the sum only get's checked after the download stage, not after each individual download? |
||
| # retry download if unpacking downloaded tarball fails, until it works or we run out of source URLs to try | ||
| while ec and kwargs['urls']: | ||
| self.log.warning("Faulty download for %s (not a valid tarball), retrying with other source URLs...", | ||
| filename) | ||
|
|
||
| # clean up faulty download to try again | ||
| try: | ||
| os.remove(path) | ||
| except OSError, err: | ||
| raise EasyBuildError("Failed to remove faulty download for %s: %s", filename, err) | ||
|
|
||
| # retry download with tail of source URLs | ||
| kwargs['urls'].pop(0) | ||
| path = super(EB_QuantumESPRESSO, self).obtain_file(*args, **kwargs) | ||
|
|
||
| # retest unpacking | ||
| _, ec = run_cmd("tar tfz %s" % path, simple=False, log_ok=False, log_all=False) | ||
|
|
||
| else: | ||
| self.log.debug("Don't know how to retry downloading for filetype of %s...", filename) | ||
|
|
||
| return path | ||
|
|
||
| def patch_step(self): | ||
| """Patch files from build dir (not start dir).""" | ||
| super(EB_QuantumESPRESSO, self).patch_step(beginpath=self.builddir) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're ignoring every EasyBuildError, not just download errors?