Skip to content
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

Merged
merged 14 commits into from
Sep 11, 2024

Conversation

joeydumont
Copy link
Contributor

@joeydumont joeydumont commented Sep 15, 2022

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 a init_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.

@joeydumont joeydumont force-pushed the source_url_cli_option branch 2 times, most recently from b5a6182 to de9ed77 Compare September 29, 2022 11:49
@boegel boegel added this to the 4.x milestone Oct 12, 2022
@boegel boegel changed the title Adds a --sources-url CLI option to fetch sources from additional URLs. add support for --sources-url to fetch sources from additional URLs Oct 12, 2022
easybuild/tools/options.py Outdated Show resolved Hide resolved
@joeydumont
Copy link
Contributor Author

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.

@jfgrimm
Copy link
Member

jfgrimm commented Feb 23, 2023

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

@Flamefire
Copy link
Contributor

Flamefire commented May 22, 2024

Suggestion here:
--sources-url supports multiple URLs, doesn't it? How are they separated?

For EasyConfigs we have --robot-paths which accepts a list of paths like /path1:/path2 and works nicely mit the default paths if you append or prepend a colon: :/path1:/path2 appends it to the default, /path1:/path2: prepends it while the original replaces it.
How about replacing the priority option by something like this to have a uniform interface here?

@joeydumont joeydumont force-pushed the source_url_cli_option branch 2 times, most recently from ceb9c77 to dfd4d81 Compare July 15, 2024 19:08
@joeydumont
Copy link
Contributor Author

As suggested, I made sure that this used the same add_flex logic that --robot-paths uses. However, I think URLs should be separated by | rather than a colon (:) or a comma (,), as both are valid in URLs. I added urllist to the list of options in ExtOption to allow for this separator to be used.

…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 <[email protected]>
# 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'))
Copy link
Contributor

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

Copy link
Contributor Author

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.

@@ -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.
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was, fixed.

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])
Copy link
Contributor

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:

Suggested change
source_urls.extend([url])
source_urls.append(url)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -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]' % '|'}),
Copy link
Contributor

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:

Suggested change
"urltuple", "add_flex", DEFAULT_EXTRA_SOURCE_URLS, {'metavar': 'URL[%sURL]' % '|'}),
"urltuple", "add_flex", DEFAULT_EXTRA_SOURCE_URLS, {'metavar': 'URL[|URL]'}),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done.

@boegel boegel modified the milestones: 4.x, release after 4.9.2 Jul 31, 2024
@boegel boegel changed the title add support for --sources-url to fetch sources from additional URLs add support for --sources-url to fetch sources from additional URLs Jul 31, 2024
Comment on lines 898 to 899
# Insert --extra-source-urls command line option to the
# urls to try to download from.
Copy link
Contributor

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:

Suggested change
# 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.
Copy link
Contributor

@Flamefire Flamefire left a 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/base/generaloption.py Outdated Show resolved Hide resolved
easybuild/framework/easyblock.py Outdated Show resolved Hide resolved
easybuild/tools/config.py Outdated Show resolved Hide resolved
easybuild/tools/options.py Outdated Show resolved Hide resolved
easybuild/base/generaloption.py Outdated Show resolved Hide resolved
easybuild/framework/easyblock.py Show resolved Hide resolved
@@ -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',)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DEFAULT_EXTRA_SOURCE_URLS = ('https://sources.easybuild.io',)
EASYBUILD_SOURCES_URL = 'https://sources.easybuild.io'
DEFAULT_EXTRA_SOURCE_URLS = (EASYBUILD_SOURCES_URL,)

@boegel boegel modified the milestones: 4.9.3, release after 4.9.3 Aug 28, 2024
@boegel boegel changed the title add support for --sources-url to fetch sources from additional URLs add support for --extra-source-urls to fetch sources from additional URLs Sep 11, 2024
@boegel
Copy link
Member

boegel commented Sep 11, 2024

Good to go, thanks a lot for your patience with this one @joeydumont, I'm happy it's finally getting merged :)

@boegel boegel merged commit 29c3e60 into easybuilders:develop Sep 11, 2024
37 checks passed
@boegel boegel modified the milestones: release after 4.9.3, 4.9.3 Sep 11, 2024
@joeydumont
Copy link
Contributor Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants