From 5c0d79ed53a6b3ca1e4d087985d85ca52f647707 Mon Sep 17 00:00:00 2001 From: Peter Rowlands Date: Mon, 28 Aug 2023 14:24:02 +0900 Subject: [PATCH] artifacts get: support --remote, --remote-config --- dvc/commands/artifacts.py | 23 ++++++++++++++++++++++- dvc/repo/artifacts.py | 6 +++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/dvc/commands/artifacts.py b/dvc/commands/artifacts.py index 88b2fa51fe..a2a8a564fd 100644 --- a/dvc/commands/artifacts.py +++ b/dvc/commands/artifacts.py @@ -3,7 +3,7 @@ from dvc.cli import completion from dvc.cli.command import CmdBaseNoRepo -from dvc.cli.utils import append_doc_link, fix_subparsers +from dvc.cli.utils import DictAction, append_doc_link, fix_subparsers from dvc.exceptions import DvcException logger = logging.getLogger(__name__) @@ -23,6 +23,8 @@ def run(self): stage=self.args.stage, force=self.args.force, config=self.args.config, + remote=self.args.remote, + remote_config=self.args.remote_config, out=self.args.out, ) ui.write(f"Downloaded {count} file(s) to '{out}'") @@ -109,4 +111,23 @@ def add_parser(subparsers, parent_parser): "in the target repository." ), ) + get_parser.add_argument( + "--remote", + type=str, + help=( + "Remote name to set as a default in the target repository " + "(only applicable when downloading from DVC remote)." + ), + ) + get_parser.add_argument( + "--remote-config", + type=str, + nargs="*", + action=DictAction, + help=( + "Remote config options to merge with a remote's config (default or one " + "specified by '--remote') in the target repository (only applicable " + "when downloading from DVC remote)." + ), + ) get_parser.set_defaults(func=CmdArtifactsGet) diff --git a/dvc/repo/artifacts.py b/dvc/repo/artifacts.py index 5e1990e6d2..f42ce4f051 100644 --- a/dvc/repo/artifacts.py +++ b/dvc/repo/artifacts.py @@ -241,13 +241,15 @@ def _download_studio( return len(to_infos), relpath(localfs.path.commonpath(to_infos)) @classmethod - def get( # noqa: C901 + def get( # noqa: C901, PLR0913 cls, url: str, name: str, version: Optional[str] = None, stage: Optional[str] = None, config: Optional[Union[str, Dict[str, Any]]] = None, + remote: Optional[str] = None, + remote_config: Optional[Union[str, Dict[str, Any]]] = None, out: Optional[str] = None, force: bool = False, jobs: Optional[int] = None, @@ -291,6 +293,8 @@ def get( # noqa: C901 subrepos=True, uninitialized=True, config=config, + remote=remote, + remote_config=remote_config, ) as repo: logger.trace("Trying repo [studio] config") # type: ignore[attr-defined] studio_config = dict(repo.config.get("studio"))