Skip to content

Commit

Permalink
fixed for load artifact from file
Browse files Browse the repository at this point in the history
Signed-off-by: dafnapension <[email protected]>
  • Loading branch information
dafnapension committed Jan 7, 2025
1 parent e532adc commit 8b8c7b2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/unitxt/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def reset(self):

@lru_cache(maxsize=None)
def artifacts_json_cache(artifact_path, catalog):
if catalog.is_local:
if catalog is None or catalog.is_local:
return load_json(artifact_path)
# github catalog
response = requests.get(artifact_path)
Expand Down Expand Up @@ -510,6 +510,9 @@ def load(self, overwrite_args: dict) -> Artifact:
for catalog in catalogs:
if self.artifact_linked_to in catalog:
needed_catalog = catalog
if needed_catalog.is_local:
# prefer a local catalog, if possible
break

if needed_catalog is None:
raise UnitxtArtifactNotFoundError(self.artifact_linked_to, catalogs)
Expand Down Expand Up @@ -594,7 +597,7 @@ def fetch_artifact(artifact_rep) -> Tuple[Artifact, Union[AbstractCatalog, None]

# If local file
if isinstance(artifact_rep, str) and Artifact.is_artifact_file(artifact_rep):
artifact_to_return = Artifact.load(artifact_rep)
artifact_to_return = Artifact.load(catalog=None, path=artifact_rep)
if isinstance(artifact_rep, ArtifactLink):
artifact_to_return = fetch_artifact(artifact_to_return.artifact_linked_to)

Expand Down

0 comments on commit 8b8c7b2

Please sign in to comment.