-
Notifications
You must be signed in to change notification settings - Fork 110
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
run: Add dry run mode #5539
run: Add dry run mode #5539
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5539 +/- ##
==========================================
+ Coverage 90.32% 90.33% +0.01%
==========================================
Files 305 305
Lines 41577 41654 +77
==========================================
+ Hits 37554 37630 +76
- Misses 4023 4024 +1
Continue to review full report at Codecov.
|
Thank you @kyleam - yet to review changes etc, I see myself using it so good. |
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.
Looks good to me. Didn't try, but left some comments to consider.
@@ -231,6 +237,13 @@ class Run(Interface): | |||
'.datalad/runinfo' directory (customizable via the | |||
'datalad.run.record-directory' configuration variable).""", | |||
constraints=EnsureNone() | EnsureBool()), | |||
dry_run=Parameter( | |||
# Leave out common -n short flag to avoid confusion with | |||
# `containers-run [-n|--container-name]`. |
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.
yeah, --dry-run
is good enough as to me -- to be used sparingly anyways, and better be this explicit.
datalad/core/local/run.py
Outdated
lines = [fmt_line("location", dry_run_info["pwd_full"])] | ||
|
||
# TODO: Inputs and outputs could be pretty long. These may be worth | ||
# truncating. |
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.
oh well... at least expanded command is printed last, and it is the main target IMHO. Otherwise it would need some additional option or configuration parameter to either truncate or not and at what length etc - could be done later if/when need arises. There is also always > /tmp/file; vim /tmp/file
to navigate conveniently ;)
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 think the expansion of the inputs/outputs in conjunction with the command is instrumental, not just the command. I gave an example in #5539 (comment)
datalad/core/local/run.py
Outdated
args=("--dry-run",), | ||
action="store_true", | ||
doc="""Do not run the command; just display details about the | ||
command execution."""), |
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 wonder if it is worth adding a note that glob
s in input/output
s might not expand (at all or fully) if pointing to some paths within not yet installed subdatasets.
I do not think we should be getting all those inputs etc, even though a "perfect" --dry-run
could have included listing of (sub)datasets to install, and a number/size of files to get - I think it would bring up its run time considerably, thus possibly making it less convenient for typical use cases, and thus not done until need is expressed.
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, but I fear that the overhead to be able to state this clearly would be substantial. I would lean towards keeping it simple, for a start.
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've added a sentence to the docstring mentioning that globs from uninstalled datasets aren't expanded.
First an impulse comment after having played with it for a bit....YES! This alone will have enormous impact:
Oh, yes...
|
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 is great! Thx @kyleam
I am still struggling with the API and (limited) potential for extending with different reporting strategies, as you already pointed out. I tried a few alternatives that all came out inferior to your's. It would be great to already have this implemented as an option that could take values, but doesn't have to. I have no good approach to suggest right now, though...
datalad/core/local/run.py
Outdated
args=("--dry-run",), | ||
action="store_true", | ||
doc="""Do not run the command; just display details about the | ||
command execution."""), |
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, but I fear that the overhead to be able to state this clearly would be substantial. I would lean towards keeping it simple, for a start.
datalad/core/local/run.py
Outdated
lines = [fmt_line("location", dry_run_info["pwd_full"])] | ||
|
||
# TODO: Inputs and outputs could be pretty long. These may be worth | ||
# truncating. |
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 think the expansion of the inputs/outputs in conjunction with the command is instrumental, not just the command. I gave an example in #5539 (comment)
Thanks for the feedback, @yarikoptic and @mih. @mih:
Moving to an option with values sounds fine to me. My thinking was that using a bare option (until there are concrete ideas for other modes) doesn't block adding values because we could tack on optional values later (in the same way |
But it is difficult here. The command will pretty much always be last. I tried and the potential for confusion is high (swallow first item of a command). |
Ah, true, that's a good reason to avoid the optional value approach. |
I've switched the option over to taking values and added a mode that shows only the expanded command. Given the issue you pointed out with extended a flag later in this case, I think supporting values right away is the way to go, though now I'm on the fence about whether |
The hirni failure is the same one that has been occurring in gh-5534. https://github.com/datalad/datalad/pull/5539/checks?check_run_id=2254534141 error
|
windows fails seems to be legit but then why in only one of the runs?
|
I somehow overlooked that failure. Thanks!
Of the Windows jobs, I think that's the only one that runs the |
run() puts the run information into a dictionary right before it formats the JSON record for the commit message or sidecar file. Instead do it before the command execution so that this information can be used in the dry run mode added by the next commit.
As suggested by @mih, adding a way to easily view information about the execution, particularly the expanded command, 'could shorten the "design phase" of a run command'. Closes dataladgh-5538
Thanks, @yarikoptic, for noting that this was untested/undocumented.
It's likely that the need for more modes will come up in the future, and, as pointed out by @mih, tacking on optional values later is awkward/confusing because '--dry-run command arg ...' would take "command" as the argument to --dry-run. So, put the current mode under "basic" (inspired by `status --annex=basic`), and add a mode that shows just the expanded command. If --dry-run=basic ends up being too verbose, we can add an empty string value as a shortcut.
As of 56bc402 (Use dedicated action name for dry-run operation, 2021-04-08), create_sibling_github(..., dry_run=True) appends "[dry-run]" to its action name. Do the same for consistency and to reduce the chance that result hooks are unintentionally triggered.
I've rebased to resolve conflicts and also appended "[dry-run]" to the action name to follow the recent change in |
Thanks for the review, @yarikoptic. @mih Are you okay with the current state, in particular with |
eh, codespell already started to negatively effect the DX... hopefully would not happen that often ;-) |
I like it! thx much! |
This PR implements the dry-run operation proposed in gh-5538 by adding a
--dry-run
flag torun
along with a custom result renderer. I went light on the reported details, but, if desired, I think it should be straightforward to extend this approach later with more information.I decided to go with the name
--dry-run
because I think that's the most familiar/obvious name, though--report
would align withrerun
. Also,--report
might be a bit more natural if this option is later extended to take an optional value (e.g., to restrict or extend what is reported).