Skip to content

Commit

Permalink
artifacts get: support --remote, --remote-config
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrowla committed Aug 28, 2023
1 parent 222d234 commit 5c0d79e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
23 changes: 22 additions & 1 deletion dvc/commands/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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}'")
Expand Down Expand Up @@ -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)
6 changes: 5 additions & 1 deletion dvc/repo/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit 5c0d79e

Please sign in to comment.