Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_from_catalog does not return a fresh copy of the catalog object #1364

Open
yoavkatz opened this issue Nov 18, 2024 · 4 comments
Open

get_from_catalog does not return a fresh copy of the catalog object #1364

yoavkatz opened this issue Nov 18, 2024 · 4 comments

Comments

@yoavkatz
Copy link
Member

yoavkatz commented Nov 18, 2024

get_from_catalog does not return a fresh copy of the catalog object

   card = get_from_catalog("cards.banking77")
   card.task="...." 
   card = get_from_catalog("cards.banking77")
   /// same card object is returned from cache, and is the modified version

fetch_artifact returns a new value every time:

    card , _ = fetch_artifact("cards.banking77")
    card.task="...." 
     card , _ = fetch_artifact("cards.banking77")
     /// card is created a new, with the original task
@elronbandel
Copy link
Member

elronbandel commented Nov 18, 2024

A not fresh copy meaning it is effectively a singleton? not sure I understand

@dafnapension
Copy link
Collaborator

dafnapension commented Nov 27, 2024

from unitxt.artifact import fetch_artifact
from unitxt.catalog import get_from_catalog


card1, _ = fetch_artifact("cards.banking77")
print(card1.task.metrics)  # prints ['metrics.f1_micro', 'metrics.accuracy', 'metrics.f1_macro']
card1.task.metrics = ['metrics.accuracy']
print(card1.task.metrics)  # prints ['metrics.accuracy']
card2, _ = fetch_artifact("cards.banking77")
print(card2.task.metrics)  # prints ['metrics.f1_micro', 'metrics.accuracy', 'metrics.f1_macro']

card3 = get_from_catalog("cards.banking77")
print(card3.task.metrics)  # prints ['metrics.f1_micro', 'metrics.accuracy', 'metrics.f1_macro']
card3.task.metrics = ['metrics.accuracy']
print(card3.task.metrics)  # prints ['metrics.accuracy']
card4 = get_from_catalog("cards.banking77")
print(card4.task.metrics)  # prints ['metrics.accuracy']

@dafnapension
Copy link
Collaborator

dafnapension commented Nov 27, 2024

and it seems that the reason is the cache, that is only employed for get_from_catalog, and not for fetch_artifact:
image

@dafnapension
Copy link
Collaborator

Perhaps that cache needs to return a recursive copy of what it has to offer, like the ArtifactFetcherMixin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants