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
ENH: -d^. to point to the top of the current dataset #3242
Conversation
FTR: I think we should be reluctant to add general meaning to argument values that are only needed to shoehorn particular behavior into the existing machinery. This issue is a flavor of "the shell is too dumb". In Python code this should be rather unnecessary (one would use proper Dataset instances). Maybe it is worth implementing such argument transformation in the initial cmdline API layer, and not further complicate path interpretation globally. Given that the example uses |
Codecov Report
@@ Coverage Diff @@
## 0.11.x #3242 +/- ##
=========================================
+ Coverage 81.14% 90.8% +9.66%
=========================================
Files 256 252 -4
Lines 34050 33018 -1032
=========================================
+ Hits 27629 29982 +2353
+ Misses 6421 3036 -3385
Continue to review full report at Codecov.
|
It could be done there but I do not see a real need to break concurrency between python and cmdline APIs for this. |
It makes sense to see how things settle, but
... from the standpoint of someone inspecting the code, I like that in this patch |
I think the usage of "^" is likely to cause some confusion, since it already has meaning to git and the usage here is context sensitive. With this change places referring to datasets it means one thing, while places specifying git revisions it means something completely unrelated. |
Yeah, I could see that, though FWIW: #1024 proposed extending |
Ok, I am with @kyleam now. Good to go. It would be very good, though, to have these symbols and behavior documented somewhere. Thanks in advance! |
What shall we do with this one? |
Ping! |
Shall I change the base and merge this one into master? |
It is often desired to reference current dataset. E.g. to add an existing dataset as subdataset to the current dataset somewhere not at the top of the dataset directories tree. Especially in quite nested hierarchies it becomes a burden to figure out where is the boundary of the dataset to specify it in -d option. -d . would point to the (not installed, and possibly illegit see datalad#3211) subdataset in current directory, whenever actual need is to specify smth like -d ../../.. . With -d^. it becomes possible to say "refer to the current dataset I am in". The only gotcha I am aware of is that shell might like to use "^" as a quick substitution for previous command, that is why I specified it as -d^., i.e. without space - then seems to work as intended -- running "datalad add -d^. ./subds" would add subds in current subdirectory to the dataset without requiring full path in -d. Depending on the outcome of datalad#3230 discussion, this change might not be really needed, e.g. if default context for operations (including on subdatasets) would migrate to be of "current dataset". Otherwise, if -d would be needed to "bind" the context to current dataset - at least with this helper it would be easy to unambigously reference current dataset regardless of the position in the directories hierachy.
Without agreeing on smth like 1. of #3905 I guess we should indeed have something like this. I have rebased and added minimal doc mentioning. Note: Since |
@yarikoptic Thanks for the updates. |
It is often desired to reference current dataset. E.g. to add an existing
dataset as subdataset to the current dataset somewhere not at the top of the
dataset directories tree. Especially in quite nested hierarchies it
becomes a burden to figure out where is the boundary of the dataset to specify
it in -d option. -d . would point to the (not installed, and possibly illegit
see #3211) subdataset in current directory, whenever actual need is to specify
smth like -d ../../.. .
With -d^. it becomes possible to say "refer to the current dataset I am in".
The only gotcha I am aware of is that shell might like to use "^" as
a quick substitution for previous command, that is why I specified it
as -d^., i.e. without space - then seems to work as intended -- running
"datalad add -d^. ./subds" would add subds in current subdirectory to the
dataset without requiring full path in -d.
Depending on the outcome of #3230 discussion, this change might not be really
needed, e.g. if default context for operations (including on subdatasets) would
migrate to be of "current dataset". Otherwise, if -d would be needed to "bind"
the context to current dataset - at least with this helper it would be easy to
unambigously reference current dataset regardless of the position in the
directories hierarchy.
If you have a better suggestion instead of
^.
- please suggest. My choice was because we have^
to point to supermost dataset, thus use it to point to the (very) top. So it kinda made sense to me to point to the top of dataset curdir belongs to with^.
, and have it on the left because that target path is to the left of curdir (although.^
probably would have been better for use in shell due to aforementioned gotcha)Instructions