forked from iterative/dvc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request iterative#2160 from efiop/repo
dvc: replace pkg concept with external repo
- Loading branch information
Showing
31 changed files
with
808 additions
and
967 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from __future__ import unicode_literals | ||
|
||
import argparse | ||
import logging | ||
|
||
from dvc.repo import Repo | ||
from dvc.exceptions import DvcException | ||
from .base import CmdBaseNoRepo, append_doc_link | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CmdGet(CmdBaseNoRepo): | ||
def run(self): | ||
try: | ||
Repo.get( | ||
self.args.url, | ||
path=self.args.path, | ||
out=self.args.out, | ||
rev=self.args.rev, | ||
) | ||
return 0 | ||
except DvcException: | ||
logger.exception( | ||
"failed to get '{}' from '{}'".format( | ||
self.args.path, self.args.url | ||
) | ||
) | ||
return 1 | ||
|
||
|
||
def add_parser(subparsers, parent_parser): | ||
GET_HELP = "Download or copy files from URL." | ||
get_parser = subparsers.add_parser( | ||
"get", | ||
parents=[parent_parser], | ||
description=append_doc_link(GET_HELP, "get"), | ||
help=GET_HELP, | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
get_parser.add_argument( | ||
"url", help="DVC repository URL to download data from." | ||
) | ||
get_parser.add_argument("path", help="Path to data within DVC repository.") | ||
get_parser.add_argument( | ||
"-o", "--out", nargs="?", help="Destination path to put data to." | ||
) | ||
get_parser.add_argument( | ||
"--rev", nargs="?", help="DVC repository git revision." | ||
) | ||
get_parser.set_defaults(func=CmdGet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from __future__ import unicode_literals | ||
|
||
import argparse | ||
import logging | ||
|
||
from dvc.repo import Repo | ||
from dvc.exceptions import DvcException | ||
from .base import CmdBaseNoRepo, append_doc_link | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CmdGetUrl(CmdBaseNoRepo): | ||
def run(self): | ||
try: | ||
Repo.get_url(self.args.url, out=self.args.out) | ||
return 0 | ||
except DvcException: | ||
logger.exception("failed to get '{}'".format(self.args.url)) | ||
return 1 | ||
|
||
|
||
def add_parser(subparsers, parent_parser): | ||
GET_HELP = "Download or copy files from URL." | ||
get_parser = subparsers.add_parser( | ||
"get-url", | ||
parents=[parent_parser], | ||
description=append_doc_link(GET_HELP, "get-url"), | ||
help=GET_HELP, | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
get_parser.add_argument( | ||
"url", help="See `dvc import-url -h` for full list of supported URLs." | ||
) | ||
get_parser.add_argument( | ||
"out", nargs="?", help="Destination path to put data to." | ||
) | ||
get_parser.set_defaults(func=CmdGetUrl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from __future__ import unicode_literals | ||
|
||
import argparse | ||
import logging | ||
|
||
from dvc.exceptions import DvcException | ||
from dvc.command.base import CmdBase, append_doc_link | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CmdImportUrl(CmdBase): | ||
def run(self): | ||
try: | ||
self.repo.imp_url( | ||
self.args.url, | ||
out=self.args.out, | ||
resume=self.args.resume, | ||
fname=self.args.file, | ||
) | ||
except DvcException: | ||
logger.exception( | ||
"failed to import {}. You could also try downloading " | ||
"it manually and adding it with `dvc add` command.".format( | ||
self.args.url | ||
) | ||
) | ||
return 1 | ||
return 0 | ||
|
||
|
||
def add_parser(subparsers, parent_parser): | ||
IMPORT_HELP = "Download or copy files from URL and take under DVC control." | ||
|
||
import_parser = subparsers.add_parser( | ||
"import-url", | ||
parents=[parent_parser], | ||
description=append_doc_link(IMPORT_HELP, "import-url"), | ||
help=IMPORT_HELP, | ||
formatter_class=argparse.RawTextHelpFormatter, | ||
) | ||
import_parser.add_argument( | ||
"url", | ||
help="Supported urls:\n" | ||
"/path/to/file\n" | ||
"C:\\\\path\\to\\file\n" | ||
"https://example.com/path/to/file\n" | ||
"s3://bucket/path/to/file\n" | ||
"gs://bucket/path/to/file\n" | ||
"hdfs://example.com/path/to/file\n" | ||
"ssh://example.com:/path/to/file\n" | ||
"remote://myremote/path/to/file (see `dvc remote`)", | ||
) | ||
import_parser.add_argument( | ||
"--resume", | ||
action="store_true", | ||
default=False, | ||
help="Resume previously started download.", | ||
) | ||
import_parser.add_argument( | ||
"out", nargs="?", help="Destination path to put files to." | ||
) | ||
import_parser.add_argument( | ||
"-f", "--file", help="Specify name of the DVC-file it generates." | ||
) | ||
import_parser.set_defaults(func=CmdImportUrl) |
Oops, something went wrong.