-
Notifications
You must be signed in to change notification settings - Fork 394
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
dvcfs: initial docs #3932
dvcfs: initial docs #3932
Conversation
content/docs/api-reference/dvcfs.md
Outdated
DVC-tracked into a local directory "data". Similarly, DVC might fetch files from | ||
remote if they don't exist in the cache. | ||
|
||
## API Reference |
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 am not really seeing much value from "API reference" right now compared to Scenarios/Recipes that we can cover.
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.
Goes back to #3927 (comment). If we have the API ref auto-generated then I agree. Or do you suggest skipping it completely and let people/IDEs check docstrings?
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.
fsspec is supposed to be a documented API that this library implements, we don't want to repeat everything here. Also, it makes sense to start small, with examples. I hope a lot of things here will be self descriptive through examples.
Link Check Report
All 6 links passed! |
@skshetry Is it ready for initial review? |
@dberenbaum, I'd say yes. This is a bare-bones version, as I wanted to start simple. And there are open questions regarding docs organization and API reference. I think in these docs, I am going to approach this with more code examples/recipes instead of API references. Here's the PR: iterative/dvc#8277 that this is based on (I made some changes to the constructor of the filesystem). |
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 like the approach. I also don't see a benefit of repeating the whole fsspec (even though it doesn't have proper docs at all). We might need to iterate of the text on the first two paragraphs and merge it.
content/docs/api-reference/dvcfs.md
Outdated
|
||
DvcFileSystem provides a single view of all the files/directories in your | ||
repository, be it Git-tracked or DVC-tracked, or untracked (in case of a local | ||
repository). DvcFileSystem is smart to reuse the files in your cache directory |
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.
Internally it avoids downloading DVC-tracked files unless it's needed. It's using DVC cache [make it abbr] to avoid downloading objects every time and support streaming for supported remote storages [link] for operations like ...
content/docs/api-reference/dvcfs.md
Outdated
|
||
## Examples | ||
|
||
### Listing all DVC-tracked files |
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.
suggestion: make title look like command/calls - ls
: list DVC-tracked files
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 snippet here uses find
, not ls
. The title should probably reflect that
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.
Like @daavoo said, it's equivalent to ls --recursive
, so I don't want to force commands in the title. I do mention that after the snippets now. :)
content/docs/api-reference/dvcfs.md
Outdated
### Listing all DVC-tracked files | ||
|
||
```py | ||
>>> fs = DvcFileSystem("https://github.com/iterative/example-get-started.git", rev="main") |
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.
may be worth mentioning in those examples important aspects of their behavior - e.g. it doesn't download files, streams, etc. Can be brief
content/docs/api-reference/dvcfs.md
Outdated
## API Reference | ||
|
||
As DvcFileSystem is based on [fsspec](https://filesystem-spec.readthedocs.io/), | ||
it is compatible with most of the APIs that it offers. Please check the fsspec's |
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 is compatible with most of the APIs that it offers. Please check the fsspec's | |
it is compatible with most of the read-only methods that it offers. Please check the fsspec's |
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 not the API that is read-only, but the filesystem and its operation in general. I have also struggled to explain this, but tbh I don't think we need to mention anything other than "... is a read-only filesystem".
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 it's better to even skip it and raise a EROFS
.
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.
What is an EROFS
?
I must be missing your point here because I don't see what's confusing or ambiguous. Is dvcfs compatible with the read-only methods of https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem?
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.
EROFS is an errno which is raised for "Read Only FileSystem". What I am trying to say is that the filesystem in general is read-only, not the methods. Take fs.open()
for example. It works with mode="rb"
but mode="wb"
raises EROFS
. So I am trying to distinguish between the method open
vs the operations: writing/reading, etc.
content/docs/api-reference/dvcfs.md
Outdated
@@ -0,0 +1,66 @@ | |||
# DvcFileSystem | |||
|
|||
DvcFileSystem provides a pythonic file interface (aka |
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.
Maybe it can be further simplified to stress the main points that it's read-only and fsspec comapitable. I think it should start with something like, "DVCFileSystem is a read-only fsspec-compatible interface." Then you could go on to describe the typical operations and everything else.
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.
Initially I wrote like that, but I later thought that the end users does not care about fsspec or need to care about it to use it.
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 read-only
part is important
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.
Initially I wrote like that, but I later thought that the end users does not care about fsspec or need to care about it to use it.
Good point, but if we are not documenting the available methods, we need to point out clearly that it implements the read-only methods available in fsspec.
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.
If you want to first focus on it being a filesytem-like interface and read-only, you could say something like: "DvcFileSystem provides read-only operations like ls
, du
, glob
, get
, download
, etc. for a DVC repo. The API implements most read-only methods of fsspec."
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 end users does not care about fsspec or need to care about it to use it.
So why do we even mention it?
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 is an fsspec-based filesystem. We do need to mention it, I just don't think we should lead with that in the intro. 🙂
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.
Sounds good. Please see #3932 (comment) below. Thanks
Many comments already so I'll just summarize some thoughts here:
|
It's now under
I don't think we have to be strict about it, we can always update it and iterate.
yes, |
* 'dvcfs' of github.com:iterative/dvc.org: Update content/docs/api-reference/dvcfilesystem.md
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 makes sense to start small with examples for this PR, but can we hold off closing #3927 until have a reference of supported methods either in the docs or linked from the docs (to an auto-generated docs site)? Compare to the s3fs docs and gcsfs docs. Both of those document the full API of methods they support. Otherwise, we are leaving users to either look through the codebase (without pointing to where they should look) or go to the fsspec AbstractFileSystem docs and use trial and error to find which methods are implemented.
@jorgeorpinel @shcheklein, I am leaving for a vacation next week, so it'd be great if you could review them, I can iterate on these docs this week. |
@skshetry I see that @dberenbaum has approved it. Are there unresolved things / any blockers / you need help with something? |
I can always get more feedback. 🙂 Is it fine to merge this then? |
Yes, I think so, one approval should be enough. What do you think about keeping the ticket open like Dave (and I guess Jorge suggested)? |
Done, thanks. |
Link Check ReportThere were no links to check! |
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.
Just some suggested follow-ups post-merge, concentrated on the intro (the subsections are pretty good I think 👍🏼 -- may just need double checking grammar, etc.)
DVCFileSystem provides a pythonic file interface ( | ||
[fsspec-compatible](https://filesystem-spec.readthedocs.io/)) for a DVC repo. It | ||
is a read-only filesystem, hence it does not support any write operations, like | ||
`put_file`, `cp`, `rm`, `mv`, `mkdir` etc. |
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.
💅🏼
DVCFileSystem provides a pythonic file interface ( | |
[fsspec-compatible](https://filesystem-spec.readthedocs.io/)) for a DVC repo. It | |
is a read-only filesystem, hence it does not support any write operations, like | |
`put_file`, `cp`, `rm`, `mv`, `mkdir` etc. | |
`DVCFileSystem` is a Python class that provides a file interface for <abbr>DVC repositories</abbr> | |
(compatible with [fsspec](https://filesystem-spec.readthedocs.io/)). It | |
is read-only, hence it does not support any write operations like | |
`put_file`, `cp`, `rm`, `mv`, `mkdir` etc. |
DVCFileSystem provides a unified view of all the files/directories in your | ||
repository, be it Git-tracked or DVC-tracked, or untracked (in case of a local | ||
repository). It can reuse the files in DVC <abbr>cache</abbr> and can otherwise | ||
stream from | ||
[supported remote storage](/doc/command-reference/remote/add#supported-storage-types). |
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.
DVCFileSystem provides a unified view of all the files/directories in your | |
repository, be it Git-tracked or DVC-tracked, or untracked (in case of a local | |
repository). It can reuse the files in DVC <abbr>cache</abbr> and can otherwise | |
stream from | |
[supported remote storage](/doc/command-reference/remote/add#supported-storage-types). | |
`DVCFileSystem` objects construct a unified view of all the files and directories in your | |
repo, be it Git-tracked, DVC-tracked, or untracked (in the case of local | |
repos). It can reuse files in the <abbr>DVC cache</abbr>, and it can otherwise | |
stream from [supported remote storage]. | |
[supported remote storage]: /doc/command-reference/remote/add#supported-storage-types |
It can reuse files in the DVC cache
What does this mean though? Reuse them for what purpose?
```py | ||
>>> from dvc.api import DVCFileSystem | ||
# opening a local repository | ||
>>> fs = DVCFileSystem("/path/to/local/repository") | ||
# opening a remote repository | ||
>>> url = "https://github.com/iterative/example-get-started.git" | ||
>>> fs = DVCFileSystem(url, rev="main") |
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.
💅🏼
```py | |
>>> from dvc.api import DVCFileSystem | |
# opening a local repository | |
>>> fs = DVCFileSystem("/path/to/local/repository") | |
# opening a remote repository | |
>>> url = "https://github.com/iterative/example-get-started.git" | |
>>> fs = DVCFileSystem(url, rev="main") | |
```py | |
from dvc.api import DVCFileSystem | |
# Opening a local repository | |
fs = DVCFileSystem("/path/to/local/repository") | |
# Opening a remote repository | |
url = "https://github.com/iterative/example-get-started.git" | |
fs = DVCFileSystem(url, rev="main") |
Applies to other
py
code blocks.
The optional positional argument can be a URL or a local path to the DVC | ||
project. If unspecified, the DVC project in current working directory is used. |
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.
Does it work with any DVC project or does it have to be a Git repo? (We currently use the term "repo" specifically in a few places.)
The optional positional argument can be a URL or a local path to the DVC | ||
project. If unspecified, the DVC project in current working directory is used. | ||
|
||
The optional `rev` argument can be passed to open a filesystem from a certain | ||
Git commit (any [revision](https://git-scm.com/docs/revisions) such as a branch | ||
or a tag name, a commit hash, or an [experiment name]). | ||
|
||
[experiment name]: /doc/command-reference/exp/run#-n |
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.
Would it be better to put the class signature up somewhere? With param names, etc. (may need to make a mixed definition combined with FileSystem)
## API Reference | ||
|
||
As DVCFileSystem is based on [fsspec](https://filesystem-spec.readthedocs.io/), | ||
it is compatible with most of the APIs that it offers. Please check the fsspec's | ||
[API Reference](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem) | ||
for more details. |
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.
Last note: we could use terms "properties" and "methods" instead in here, to clarify we mean the reference of this specific class/object, not some larger API.
p.s. we could put this section earlier too, probably before the example sections, even as a note (<admon>
or not).
Fixes partially #3927.
First draft of
dvcfs
.