-
Notifications
You must be signed in to change notification settings - Fork 203
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
add support for --extra-source-urls
to fetch sources from additional URLs
#4079
add support for --extra-source-urls
to fetch sources from additional URLs
#4079
Conversation
b5a6182
to
de9ed77
Compare
53f3f53
to
2641b81
Compare
2641b81
to
769d6fa
Compare
I see there are now merge conflicts for this. Let me know when you're ready for me to rebase, or if you prefer to handle that. |
go for it; if you have any issues/questions just ping me |
769d6fa
to
f4d05b1
Compare
Suggestion here: For EasyConfigs we have |
ceb9c77
to
dfd4d81
Compare
As suggested, I made sure that this used the same |
…l URLs. Add the --extra-source-urls CLI option, a | separated list of URLs that EasyBuild will fetch sources from. It replaces the hard-coded EASYBUILD_SOURCES_URL, but keeps it as a default value. Uses the add_flex logic to prepend, append, or insert into the default list. Co-authored-by: Alexander Grund <Flamefire@users.noreply.github.com>
e6cced2
to
e9c8f7b
Compare
easybuild/framework/easyblock.py
Outdated
# add https://sources.easybuild.io as fallback source URL | ||
source_urls.append(EASYBUILD_SOURCES_URL + '/' + os.path.join(name_letter, location)) | ||
# add extra-source-urls CLI as either a first check, or a fallback. | ||
self.log.warning("[extra_source_urls] %s", build_option('extra_source_urls')) |
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.
Why are those warnings? I'd suggest to only log if there are any at all, as (at most) info
and the individual urls as debug
. And maybe only log the final value, not each intermediate
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.
Thanks, I added those in for me to make sure the values were making their way in the expected places. I removed these logs completely, the debug logs already print
== 2024-07-16 20:58:08,626 generaloption.py:1604 DEBUG generate_cmd_line adding extra-source-urls value ('https://sources.easybuild.io/',) default found. Not adding to args.
easybuild/framework/easyblock.py
Outdated
@@ -897,8 +895,13 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No | |||
source_urls = [] | |||
source_urls.extend(self.cfg['source_urls']) | |||
|
|||
# add https://sources.easybuild.io as fallback source URL | |||
source_urls.append(EASYBUILD_SOURCES_URL + '/' + os.path.join(name_letter, location)) | |||
# add extra-source-urls CLI as either a first check, or a fallback. |
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.
The comment seems outdated. I don't see an either-or in the code below. Also CLI should rather be "option" or "command line option" as CLI is usually the whole set of (all) CL options
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.
It was, fixed.
easybuild/framework/easyblock.py
Outdated
for url in build_option("extra_source_urls"): | ||
url += "/" + name_letter + "/" + location | ||
self.log.warning("[extra_source_urls] url is %s", url) | ||
source_urls.extend([url]) |
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.
It's only a single element:
source_urls.extend([url]) | |
source_urls.append(url) |
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.
Done.
easybuild/tools/options.py
Outdated
@@ -407,6 +409,8 @@ def override_options(self): | |||
None, 'store_true', False), | |||
'extra-modules': ("List of extra modules to load after setting up the build environment", | |||
'strlist', 'extend', None), | |||
"extra-source-urls": ("Specify URLs to fetch sources from in addition to those in the easyconfig", | |||
"urltuple", "add_flex", DEFAULT_EXTRA_SOURCE_URLS, {'metavar': 'URL[%sURL]' % '|'}), |
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.
I'd rather not use string interpolation for a constant. Just makes loading EB (even) slower:
"urltuple", "add_flex", DEFAULT_EXTRA_SOURCE_URLS, {'metavar': 'URL[%sURL]' % '|'}), | |
"urltuple", "add_flex", DEFAULT_EXTRA_SOURCE_URLS, {'metavar': 'URL[|URL]'}), |
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.
Good point, done.
--sources-url
to fetch sources from additional URLs
easybuild/framework/easyblock.py
Outdated
# Insert --extra-source-urls command line option to the | ||
# urls to try to download from. |
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.
As mentioned earlier this is not only a CLI option, but can be from 2 other places. I suggest something like:
# Insert --extra-source-urls command line option to the | |
# urls to try to download from. | |
# Add additional URLs as configured |
…ting whether specifying it here fixes the tests.
…NE so that init_config has the right default value. Should fix CI tests.
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.
A final round of comments. All minor things, so it's just polishing this up. 👍
easybuild/tools/config.py
Outdated
@@ -120,6 +120,7 @@ | |||
DEFAULT_PR_TARGET_ACCOUNT = 'easybuilders' | |||
DEFAULT_PREFIX = os.path.join(os.path.expanduser('~'), ".local", "easybuild") | |||
DEFAULT_REPOSITORY = 'FileRepository' | |||
DEFAULT_EXTRA_SOURCE_URLS = ('https://sources.easybuild.io',) |
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.
DEFAULT_EXTRA_SOURCE_URLS = ('https://sources.easybuild.io',) | |
EASYBUILD_SOURCES_URL = 'https://sources.easybuild.io' | |
DEFAULT_EXTRA_SOURCE_URLS = (EASYBUILD_SOURCES_URL,) |
…om config in easyblock leads to circular imports. Not sure how to stop houndbot from howling.
--sources-url
to fetch sources from additional URLs--extra-source-urls
to fetch sources from additional URLs
Good to go, thanks a lot for your patience with this one @joeydumont, I'm happy it's finally getting merged :) |
And thank you! I appreciate the feedback! |
This PR adds a --sources-url CLI option. It is a comma separated list of URLs that EasyBuild will fetch sources from. It replaces the hard-coded
EASYBUILD_SOURCES_URL
, but keeps it as a default value. The --sources-url-priority option is used to determine if these URLs are to be queried first, or last, i.e. as a fallback.Unfortunately, this breaks 3 tests related to downloading the file, and I'm unsure of exactly why. It seems that
build_option('sources_url')
might return None when the function is run through the test harness, rather than getting populated with the default value. I've tried adding ainit_config(args=["--sources-url=https://sources.easybuild.io"])
, but that didn't work either.If the feature is of interest, could you give me a hand in fixing the tests?
EDIT: After some discussion on Slack, I was able to fix the tests. I also renamed the options to
--extra-source-urls
and--extra-source-urls-priority
. I changed the commit mesage to be imperative.