Upload artifact.py with huggingface_hub
Browse files- artifact.py +11 -1
artifact.py
CHANGED
|
@@ -8,13 +8,15 @@ from copy import deepcopy
|
|
| 8 |
from functools import lru_cache
|
| 9 |
from typing import Dict, List, Union, final
|
| 10 |
|
| 11 |
-
from .dataclass import Dataclass, Field, InternalField, fields
|
| 12 |
from .logging_utils import get_logger
|
|
|
|
| 13 |
from .text_utils import camel_to_snake_case, is_camel_case
|
| 14 |
from .type_utils import issubtype
|
| 15 |
from .utils import load_json, save_json
|
| 16 |
|
| 17 |
logger = get_logger()
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
class Artifactories:
|
|
@@ -255,6 +257,8 @@ class ArtifactList(list, Artifact):
|
|
| 255 |
|
| 256 |
|
| 257 |
class Artifactory(Artifact):
|
|
|
|
|
|
|
| 258 |
@abstractmethod
|
| 259 |
def __contains__(self, name: str) -> bool:
|
| 260 |
pass
|
|
@@ -270,6 +274,9 @@ class UnitxtArtifactNotFoundError(Exception):
|
|
| 270 |
self.artifactories = artifactories
|
| 271 |
|
| 272 |
def __str__(self):
|
|
|
|
|
|
|
|
|
|
| 273 |
return f"Artifact {self.name} does not exist, in artifactories:{self.artifactories}"
|
| 274 |
|
| 275 |
|
|
@@ -279,6 +286,9 @@ def fetch_artifact(name):
|
|
| 279 |
return Artifact.load(name), None
|
| 280 |
|
| 281 |
for artifactory in Artifactories():
|
|
|
|
|
|
|
|
|
|
| 282 |
if name in artifactory:
|
| 283 |
return artifactory[name], artifactory
|
| 284 |
|
|
|
|
| 8 |
from functools import lru_cache
|
| 9 |
from typing import Dict, List, Union, final
|
| 10 |
|
| 11 |
+
from .dataclass import AbstractField, Dataclass, Field, InternalField, fields
|
| 12 |
from .logging_utils import get_logger
|
| 13 |
+
from .settings_utils import get_settings
|
| 14 |
from .text_utils import camel_to_snake_case, is_camel_case
|
| 15 |
from .type_utils import issubtype
|
| 16 |
from .utils import load_json, save_json
|
| 17 |
|
| 18 |
logger = get_logger()
|
| 19 |
+
settings = get_settings()
|
| 20 |
|
| 21 |
|
| 22 |
class Artifactories:
|
|
|
|
| 257 |
|
| 258 |
|
| 259 |
class Artifactory(Artifact):
|
| 260 |
+
is_local: bool = AbstractField()
|
| 261 |
+
|
| 262 |
@abstractmethod
|
| 263 |
def __contains__(self, name: str) -> bool:
|
| 264 |
pass
|
|
|
|
| 274 |
self.artifactories = artifactories
|
| 275 |
|
| 276 |
def __str__(self):
|
| 277 |
+
msg = f"Artifact {self.name} does not exist, in artifactories:{self.artifactories}."
|
| 278 |
+
if settings.use_only_local_catalogs:
|
| 279 |
+
msg += f" Notice that unitxt.settings.use_only_local_catalogs is set to True, if you want to use remote catalogs set this settings or the environment variable {settings.use_only_local_catalogs_key}."
|
| 280 |
return f"Artifact {self.name} does not exist, in artifactories:{self.artifactories}"
|
| 281 |
|
| 282 |
|
|
|
|
| 286 |
return Artifact.load(name), None
|
| 287 |
|
| 288 |
for artifactory in Artifactories():
|
| 289 |
+
if settings.use_only_local_catalogs:
|
| 290 |
+
if not artifactory.is_local:
|
| 291 |
+
continue
|
| 292 |
if name in artifactory:
|
| 293 |
return artifactory[name], artifactory
|
| 294 |
|