(
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,
)
| 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, |
no test coverage detected