Skip to content

Commit 2d97b3f

Browse files
rlamyjorgeorpinelDave Berenbaumyathomasi
authored
cmd-ref: Document ls-url command (#3996)
* cmd-ref: Document ls-url command * Update content/docs/command-reference/list-url.md Co-authored-by: Dave Berenbaum <[email protected]> * Use admonitions, consistently use list-url, fix usage * Modify example headings * Describe -R option consistently in list and list-url refs. Fix inaccuracy: dvc ls -R does not print directories. * update linked-terms.js * Add links from get-url and import-url to list-url * improve first paragraph in description Co-authored-by: Jorge Orpinel <[email protected]> Co-authored-by: Dave Berenbaum <[email protected]> Co-authored-by: Thomas Kunwar <[email protected]>
1 parent de0e9cd commit 2d97b3f

File tree

6 files changed

+121
-2
lines changed

6 files changed

+121
-2
lines changed

content/docs/command-reference/get-url.md

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ while `out` can be used to specify the directory and/or file name desired for
3131
the downloaded data. If an existing directory is specified, then the file or
3232
directory will be placed inside.
3333

34+
<admon type="tip">
35+
36+
See `dvc list-url` for a way to browse the external location for files and
37+
directories to download.
38+
39+
</admon>
40+
3441
DVC supports several types of (local or) remote data sources (protocols):
3542

3643
| Type | Description | `url` format example |

content/docs/command-reference/import-url.md

+7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ The imported data is <abbr>cached</abbr>, and linked (or copied) to the current
5252
working directory with its original file name e.g. `data.txt` (or to a location
5353
provided with `out`).
5454

55+
<admon type="tip">
56+
57+
See `dvc list-url` for a way to browse the external location for files and
58+
directories to download.
59+
60+
</admon>
61+
5562
An _import `.dvc` file_ is created in the same location e.g. `data.txt.dvc`
5663
similar to using `dvc add` after downloading the data. This makes it possible to
5764
update the import later, if the data source has changed (see `dvc update`).
+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# list-url
2+
3+
<admon type="info">
4+
5+
Aliased to `dvc ls-url`
6+
7+
</admon>
8+
9+
List contents from a supported URL (for example `s3://`, `ssh://`, and other
10+
protocols).
11+
12+
<admon type="tip">
13+
14+
Useful to find data to `dvc get-url` or `dvc import-url`.
15+
16+
</admon>
17+
18+
## Synopsis
19+
20+
```usage
21+
usage: dvc list-url [-h] [-q | -v] [-R] url
22+
23+
positional arguments:
24+
url (See supported URLs in the description)
25+
```
26+
27+
## Description
28+
29+
Lists files and directories from an external location. `dvc list-url` provides a
30+
uniform interface to browse the contents of an external location using any
31+
protocol that is understood by `dvc get-url` or `dvc import-url`. For example,
32+
it is roughly equivalent to `aws s3 ls` when using the `s3://` protocol, or
33+
`ssh user@host ls -a` when using `ssh://`.
34+
35+
The `url` argument specifies the location of the data to be listed. It supports
36+
several kinds of external data sources:
37+
38+
| Type | Description | `url` format example |
39+
| ------- | ---------------------------- | ------------------------------------- |
40+
| `s3` | Amazon S3 | `s3://bucket/data` |
41+
| `azure` | Microsoft Azure Blob Storage | `azure://container/data` |
42+
| `gs` | Google Cloud Storage | `gs://bucket/data` |
43+
| `ssh` | SSH server | `ssh://[email protected]/path/to/data` |
44+
| `local` | Local path | `/path/to/local/data` |
45+
46+
<admon type="info">
47+
48+
If you installed DVC via `pip` and plan to access cloud services as external
49+
data sources, you might need to install these optional dependencies: `[s3]`,
50+
`[azure]`, `[gs]`, `[oss]`, `[ssh]`. Alternatively, use `[all]` to include them
51+
all. The command should look like this: `pip install "dvc[s3]"`. (This example
52+
installs `boto3` library along with DVC to support S3 storage.)
53+
54+
</admon>
55+
56+
Only the root directory is listed by default, but the `-R` option can be used to
57+
list files recursively.
58+
59+
## Options
60+
61+
- `-R`, `--recursive` - recursively list files in all subdirectories.
62+
63+
- `-h`, `--help` - prints the usage/help message, and exit.
64+
65+
- `-q`, `--quiet` - do not write anything to standard output. Exit with 0 if no
66+
problems arise, otherwise a non-zero value.
67+
68+
- `-v`, `--verbose` - displays detailed tracing information.
69+
70+
## Example: Amazon S3
71+
72+
This command will list objects and common prefixes under the specified path:
73+
74+
```dvc
75+
$ dvc list-url s3://bucket/path
76+
```
77+
78+
DVC expects that AWS CLI is already
79+
[configured](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html).
80+
DVC will use the AWS credentials file to access S3.
81+
82+
## Example: SSH
83+
84+
```dvc
85+
$ dvc list-url ssh://[email protected]/path/to/data
86+
```
87+
88+
Using default SSH credentials, the above command lists files and directories
89+
inside `data`.
90+
91+
## Example: local file system
92+
93+
```dvc
94+
$ dvc list-url /local/path/to/data
95+
```
96+
97+
The above command will list the `/local/path/to/data` directory.

content/docs/command-reference/list.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ accessed with `dvc get`, `dvc import`, or `dvc.api`.
5858

5959
## Options
6060

61-
- `-R`, `--recursive` - recursively prints contents of all subdirectories.
61+
- `-R`, `--recursive` - recursively list files in all subdirectories.
6262

6363
- `--dvc-only` - show only DVC-tracked files and directories
6464
(<abbr>outputs</abbr>).
@@ -111,7 +111,7 @@ We can now, for example, download the model file with:
111111
$ dvc get https://github.com/iterative/example-get-started model.pkl
112112
```
113113

114-
## Example: List all files and directories in a data registry
114+
## Example: List all files in a data registry
115115

116116
Let's imagine a DVC repo used as a
117117
[data registry](/doc/use-cases/data-registry#using-registries), structured with

content/docs/sidebar.json

+4
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@
323323
"label": "install",
324324
"slug": "install"
325325
},
326+
{
327+
"label": "list-url",
328+
"slug": "list-url"
329+
},
326330
{
327331
"label": "list",
328332
"slug": "list"

content/linked-terms.js

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ module.exports = [
2323
matches: 'dvc experiments',
2424
url: '/doc/command-reference/exp'
2525
},
26+
{
27+
matches: 'dvc ls-url',
28+
url: '/doc/command-reference/list-url'
29+
},
2630
{
2731
matches: 'dvc ls',
2832
url: '/doc/command-reference/list'

0 commit comments

Comments
 (0)