MCPcopy
hub / github.com/treeverse/dvc / get

Method get

dvc/repo/artifacts.py:286–383  ·  view source on GitHub ↗
(
        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,
    )

Source from the content-addressed store, hash-verified

284
285 @classmethod
286 def get(
287 cls,
288 url: str,
289 name: str,
290 version: Optional[str] = None,
291 stage: Optional[str] = None,
292 config: Optional[Union[str, dict[str, Any]]] = None,
293 remote: Optional[str] = None,
294 remote_config: Optional[Union[str, dict[str, Any]]] = None,
295 out: Optional[str] = None,
296 force: bool = False,
297 jobs: Optional[int] = None,
298 ):
299 from dvc.config import Config
300 from dvc.repo import Repo
301
302 if version and stage:
303 raise InvalidArgumentError(
304 "Artifact version and stage are mutually exclusive."
305 )
306
307 # NOTE: We try to download the artifact up to three times
308 # 1. via studio with studio config loaded from environment
309 # 2. via studio with studio config loaded from DVC repo 'studio'
310 # section + environment
311 # 3. via DVC remote
312
313 name = _reformat_name(name)
314 saved_exc: Optional[Exception] = None
315
316 local_dvc_studio_config = Config().get("studio", {})
317 args_dvc_studio_config = {}
318 if config and not isinstance(config, dict):
319 config = Config.load_file(config)
320 args_dvc_studio_config = config.get("studio", {})
321
322 try:
323 logger.trace("Trying studio-only config")
324 return cls._download_studio(
325 url,
326 name,
327 version=version,
328 stage=stage,
329 out=out,
330 force=force,
331 jobs=jobs,
332 dvc_studio_config=local_dvc_studio_config | args_dvc_studio_config,
333 )
334 except FileExistsLocallyError:
335 raise
336 except Exception as exc: # noqa: BLE001
337 saved_exc = exc
338
339 with Repo.open(
340 url=url,
341 subrepos=True,
342 uninitialized=True,
343 config=config,

Callers 15

group_definitionsMethod · 0.45
get_definition_dataMethod · 0.45
to_jsonFunction · 0.45
flat_datapointsMethod · 0.45
_get_xsFunction · 0.45
_get_ysFunction · 0.45
_infer_x_yMethod · 0.45
infer_y_labelMethod · 0.45
infer_x_labelMethod · 0.45
flat_datapointsMethod · 0.45
runFunction · 0.45
ls_urlFunction · 0.45

Calls 8

ConfigClass · 0.90
DvcExceptionClass · 0.90
_reformat_nameFunction · 0.85
_download_studioMethod · 0.80
openMethod · 0.80
load_fileMethod · 0.45
downloadMethod · 0.45

Tested by

no test coverage detected