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

dvcfs: initial docs #3932

Merged
merged 6 commits into from
Sep 19, 2022
Merged

dvcfs: initial docs #3932

merged 6 commits into from
Sep 19, 2022

Conversation

skshetry
Copy link
Member

@skshetry skshetry commented Sep 9, 2022

Fixes partially #3927.

First draft of dvcfs.

@skshetry skshetry self-assigned this Sep 9, 2022
@shcheklein shcheklein temporarily deployed to dvc-org-dvcfs-zfsolvaiaztew0ke September 9, 2022 15:10 Inactive
DVC-tracked into a local directory "data". Similarly, DVC might fetch files from
remote if they don't exist in the cache.

## API Reference
Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member

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.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2022

Link Check Report

All 6 links passed!

@dberenbaum
Copy link
Contributor

@skshetry Is it ready for initial review?

@skshetry
Copy link
Member Author

skshetry commented Sep 9, 2022

@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).

Copy link
Member

@shcheklein shcheklein left a 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.


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
Copy link
Member

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


## Examples

### Listing all DVC-tracked files
Copy link
Member

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

Copy link
Contributor

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

Copy link
Member Author

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. :)

### Listing all DVC-tracked files

```py
>>> fs = DvcFileSystem("https://github.com/iterative/example-get-started.git", rev="main")
Copy link
Member

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

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

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Member Author

@skshetry skshetry Sep 15, 2022

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".

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

@@ -0,0 +1,66 @@
# DvcFileSystem

DvcFileSystem provides a pythonic file interface (aka
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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."

Copy link
Contributor

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?

Copy link
Member Author

@skshetry skshetry Sep 14, 2022

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. 🙂

Copy link
Contributor

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

@jorgeorpinel
Copy link
Contributor

Many comments already so I'll just summarize some thoughts here:

  • Nothing against the example-based approach but

    • It's completely different to the current functions we have listed; Should we group those under dvc.api in the nav and use dvc.fs for this one?
    • Are the examples exhaustive or comprehensive? (How do we decide what to cover?)
  • In general the exact relation with fsspec is currently vague. Is it literally fsspec? The link at the bottom goes to fsspec.spec.AbstractFileSystem, is that what we implement? This link seems a better intro doc on their side BTW: https://filesystem-spec.readthedocs.io/en/latest/usage.html#use-a-file-system

@skshetry
Copy link
Member Author

  • It's completely different to the current functions we have listed; Should we group those under dvc.api in the nav and use dvc.fs for this one?

It's now under dvc.api.

  • Are the examples exhaustive or comprehensive? (How do we decide what to cover?)

I don't think we have to be strict about it, we can always update it and iterate.

  • In general the exact relation with fsspec is currently vague. Is it literally fsspec? The link at the bottom goes to fsspec.spec.AbstractFileSystem, is that what we implement?

yes, fsspec provides a standard interface, "dvcfs" implements it.

@shcheklein shcheklein temporarily deployed to dvc-org-dvcfs-zfsolvaiaztew0ke September 15, 2022 06:52 Inactive
@shcheklein shcheklein temporarily deployed to dvc-org-dvcfs-zfsolvaiaztew0ke September 15, 2022 07:02 Inactive
@shcheklein shcheklein temporarily deployed to dvc-org-dvcfs-zfsolvaiaztew0ke September 15, 2022 12:58 Inactive
* 'dvcfs' of github.com:iterative/dvc.org:
  Update content/docs/api-reference/dvcfilesystem.md
@shcheklein shcheklein temporarily deployed to dvc-org-dvcfs-zfsolvaiaztew0ke September 16, 2022 13:18 Inactive
Copy link
Contributor

@dberenbaum dberenbaum left a 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.

@skshetry
Copy link
Member Author

@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.

@shcheklein
Copy link
Member

@skshetry I see that @dberenbaum has approved it. Are there unresolved things / any blockers / you need help with something?

@skshetry
Copy link
Member Author

I can always get more feedback. 🙂 Is it fine to merge this then?

@shcheklein
Copy link
Member

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)?

@skshetry
Copy link
Member Author

What do you think about keeping the ticket open like Dave (and I guess Jorge suggested)?

Done, thanks.

@skshetry skshetry merged commit 98fe9aa into main Sep 19, 2022
@skshetry skshetry deleted the dvcfs branch September 19, 2022 05:01
@github-actions
Copy link
Contributor

98fe9aa

Link Check Report

There were no links to check!

CML watermark

@dberenbaum dberenbaum mentioned this pull request Sep 19, 2022
Copy link
Contributor

@jorgeorpinel jorgeorpinel left a 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.)

Comment on lines +5 to +8
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.
Copy link
Contributor

Choose a reason for hiding this comment

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

💅🏼

Suggested change
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.

Comment on lines +10 to +14
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).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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?

Comment on lines +16 to +22
```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")
Copy link
Contributor

@jorgeorpinel jorgeorpinel Oct 18, 2022

Choose a reason for hiding this comment

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

💅🏼

Suggested change
```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.

Comment on lines +25 to +26
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.
Copy link
Contributor

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.)

Comment on lines +25 to +32
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
Copy link
Contributor

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)

Comment on lines +121 to +126
## 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.
Copy link
Contributor

@jorgeorpinel jorgeorpinel Oct 18, 2022

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).

@jorgeorpinel jorgeorpinel added A: docs Area: user documentation (gatsby-theme-iterative) C: ref Content of /doc/*-reference labels Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: docs Area: user documentation (gatsby-theme-iterative) C: ref Content of /doc/*-reference
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants