nateraw / modelcards

📝 Utility to create, edit, and publish model cards on the Hugging Face Hub. [**Now lives in huggingface_hub**]
MIT License
15 stars 4 forks source link

Loading cards from Hub with unhandled metadata headers fails #17

Closed nateraw closed 2 years ago

nateraw commented 2 years ago

When loading a card from the hub, this package fails when loading one that has unhandled fields in the metadata header. For example, widgets.

To recreate the issue, pip install modelcards, then:

from modelcards import ModelCard

card = ModelCard.load('Maltehb/aelaectra-danish-electra-small-cased')

You'll get TypeError: __init__() got an unexpected keyword argument 'co2_eq_emissions'. This is coming from CardData's init, which doesn't expect this co2_eq_emissions key. This example specifically is related to #14, but it is also true for many other fields that are used in the metadata header ('widgets', etc.)

adrinjalali commented 2 years ago

Should CardData accept arbitrary unknown data? I think it should.

nateraw commented 2 years ago

I think I agree @adrinjalali. In this case, should I stop using DataClasses and just make a class that accepts **kwargs?

nateraw commented 2 years ago

In this case we'll also want to validate that everything here is serializable!

julien-c commented 2 years ago

on the hub side arbitrary data is supported (and outputted as is)

adrinjalali commented 2 years ago

In this case we'll also want to validate that everything here is serializable!

We could also just fail while serializing instead of checking to start with, and see how that goes, and then improve on our error handling/messages if necessary, WDYT?