-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fetch strategies: new global option no_cache, new git options full_depth and all_branches. #12122
Fetch strategies: new global option no_cache, new git options full_depth and all_branches. #12122
Conversation
lib/spack/spack/fetch_strategy.py
Outdated
# The stage is initialized late, so that fetch strategies can be | ||
# constructed at package construction time. This is where things | ||
# will be fetched. | ||
self.stage = None | ||
# Possibly disable caching for this strategy. | ||
self._no_cache_opt = kwargs.pop('no_cache', False) |
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.
Is there a reason you want to remove no_cache
from kwargs
using pop
(versus get
)?
Also, given the checks below tend toward (not self._no_cache_opt)
, using something more positive (e.g., cache
, enable_caching
) would simplify the checks.
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 popped it from kwargs
since the option has now been dealt with and does not need to be in kwargs
as seen by sub-classes: just separation of concerns, basically.
Per your second point: I have a natural inclination to avoid options that are true by default. I could certainly see the attribute being something like self.cache_enabled
, but I'd like to continue to have the option name reflect what happens when it is set to the non-default True
case. Does this make sense to you?
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 can see your reasoning in both cases and neither point is a blocker.
I am curious about the basis for your natural inclination simply for my own edification.
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'm not sure I would claim my natural inclination had a conscious, "basis"—or was even entirely rational—but I guess that when I'm adding an option to something, I like specifying the option to be an affirmative act i.e. I'm specifying the option explicitly because I want to change something about how it (function, command, etc.) behaves. I would therefore like the name of the option to reflect what I want to happen when I specify it, which (in my mind) equates to wanting the option to be True
when I specify it.
I hope that makes sense to you. It's a bit of a post hoc rationalization since I can't actually put my finger on exactly when or why I started feeling this way.
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 can appreciate your perspective. Thanks for sharing.
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.
LGTM. I do suggest the following changes:
- Clearer if explain (in docs) what the new options mean when
True
first - Add the missing underscore at line 329 of
fetch_strategy.py
e27c4ea
to
5aeb9e5
Compare
|
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.
LGTM. Thanks for the changes.
@chissg Could you expand a bit on what the use cases for these options are? I'm not sure I quite get it yet. For the no-cache option I understand we shouldn't cache versions that are moving heads of branches, but what are the others for? |
@becker33 For the For |
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 have a few minor (hopefully) requests and one possibly larger request to merge --full-depth
and --all-branches
(if that wouldn't cause problems for your use cases).
Also regarding the PR description:
The try / catch block attempting --depth 1 and retrying on failure has been removed in favor of more accurately ascertaining when the --depth option should work based on git version and protocol choice. Any failure is now treated as a real problem, and the clone is only attempted once.
To be clear, is this to avoid cases where a temporary connectivity failure changes Spack's behavior? If so, I'm definitely a fan of this.
5aeb9e5
to
47f738b
Compare
@scheibelp, I believe I have addressed your outstanding issues with 47f738b. Please let me know if you have any further comments on the latest commit.
Yes, that's exactly what this was for. |
cdf2e1a
to
880d445
Compare
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.
This looks nearly there but I have a question and a couple minor comments. Probably the most work would be pulling out the emacs
directives into their own commit and then rebasing the PR into a set of clean commits (normally that doesn't matter since I would squash the commits but here I think a separate commit for the Emacs directives would be good).
@@ -4280,3 +4289,8 @@ Autotools-based packages would be easy (and should be done by a | |||
developer who actively uses Autotools). Packages that use | |||
non-standard build systems can gain ``setup`` functionality by | |||
subclassing ``StagedPackage`` directly. | |||
|
|||
.. Emacs local variables |
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.
This looks good but it would be ideal to move this to a different commit; in that case if you could rebase the PR that would be great (e.g. to remove flake commits).
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. Does the commit history match what you want, now?
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.
Sorry no I was not clear, I think this should be collapsed into 2 commits: one which contains the emacs
directives and one that contains all the other changes. The commit messages would have to be "clean" as well (since I plan to merge the commits as-is into develop), e.g. avoid messages like "address review comments from X".
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.
@scheibelp How about now?
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.
Yes this organization is excellent
BUT I think the first commit message has at least one stale note:
New git-specific version keyword options
full_depth
andall_branches
(both Boolean). The former disables the--depth 1
optimization and the latter the--single-branch
optimization.
I think as of now there is only get_full_repo
Once that is addressed, this will be set
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.
@scheibelp Done, I think. Let me know if there's anything else.
cadc6fd
to
c024d8d
Compare
…ull_repo`. * All fetch strategies now accept the Boolean version keyword option `no_cache` in order to allow per-version control of cache-ability. * New git-specific version keyword option `get_full_repo` (Boolean). When true, disables the default `--depth 1` and `--single-branch` optimizations that are applied if supported by the git version and (in the former case) transport protocol. * The try / catch blog attempting `--depth 1` and retrying on failure has been removed in favor of more accurately ascertaining when the `--depth` option should work based on git version and protocol choice. Any failure is now treated as a real problem, and the clone is only attempted once. * Test improvements: * `mock_git_repository.checks[type_of_test].args['git']` is now specified as the URL (with leading `file://`) in order to avoid complaints when using `--depth`. * New type_of_test `tag-branch`. * mock_git_repository now provides `git_exe`. * Improved the action of the `git_version` fixture, which was previously hard-wired. * New tests of `--single-branch` and `--depth 1` behavior. * Add documentation of new options to the packaging guide.
c024d8d
to
f9cf574
Compare
Thanks! |
Fetch strategies: new global option
no_cache
, new git optionget_full_repo
.no_cache
in order to allow per-version control of cache-ability.get_full_repo
(Boolean). When true, disables the default--depth 1
and--single-branch
optimizations that are applied if supported by the git version and (in the former case) transport protocol.--depth 1
and retrying on failure has been removed in favor of more accurately ascertaining when the--depth
option should work based on git version and protocol choice. Any failure is now treated as a real problem, and the clone is only attempted once.mock_git_repository.checks[type_of_test].args['git']
is now specified as the URL (with leadingfile://
) in order to avoid complaints when using--depth
.tag-branch
.git_exe
.git_version
fixture, which was previously hard-wired.--single-branch
and--depth 1
behavior.