If ModelHubMixin is added to the model's base class, then metadata (such as repo_url, docs_url, ...) is missed in any class that inherits a class with mixin (its easier to show with an example, see below).
import torch
from huggingface_hub import PyTorchModelHubMixin
class BaseModel(
torch.nn.Module,
PyTorchModelHubMixin,
repo_url="my-repo",
):
pass
class DummyModel(BaseModel): # <--- inherit BaseModel
pass
base_model = BaseModel()
print(base_model._hub_mixin_info.repo_url)
# my-repo
model = DummyModel()
print(model._hub_mixin_info.repo_url)
# None
Is it supposed to be that way or is it unexpected behavior?
Describe the bug
If
ModelHubMixin
is added to the model's base class, then metadata (such asrepo_url
,docs_url
, ...) is missed in any class that inherits a class with mixin (its easier to show with an example, see below).Is it supposed to be that way or is it unexpected behavior?
This happens because in
__init_subclass__
we overridecls._hub_mixin_info
. https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/hub_mixin.py#L215Would it be better to update parameters for
_hub_mixin_info
instead of overriding them?P.S.
Arguments can be provided for
DummyModel
, and that would be correctly handledSystem info