Skip to content

Commit

Permalink
add dvc artifacts get --show-url
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Berenbaum authored and dberenbaum committed May 23, 2024
1 parent 0a813bb commit 05db79e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions dvc/commands/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def run(self):
from dvc.scm import CloneError
from dvc.ui import ui

if self.args.show_url:
return self._show_url()

try:
count, out = Artifacts.get(
self.args.url,
Expand All @@ -36,6 +39,28 @@ def run(self):
)
return 1

def _show_url(self):
from dvc.api import artifacts_show, get_url
from dvc.ui import ui

artifact = artifacts_show(
self.args.name,
version=self.args.rev,
stage=self.args.stage,
repo=self.args.url,
)

url = get_url(
artifact["path"],
repo=self.args.url,
rev=artifact["rev"],
remote=self.args.remote,
remote_config=self.args.remote_config,
)
ui.write(url, force=True)

return 0


def add_parser(subparsers, parent_parser):
ARTIFACTS_HELP = "DVC model registry artifact commands."
Expand Down Expand Up @@ -84,6 +109,14 @@ def add_parser(subparsers, parent_parser):
help="Destination path to download artifact to",
metavar="<path>",
).complete = completion.DIR
get_parser.add_argument(
"--show-url",
action="store_true",
help=(
"Print the storage location (URL) the target data would be "
"downloaded from, and exit."
),
)
get_parser.add_argument(
"-j",
"--jobs",
Expand Down

0 comments on commit 05db79e

Please sign in to comment.