Skip to content

Commit

Permalink
Simplify hubconf
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: fairinternal/fairseq-py#758

Differential Revision: D16418932

Pulled By: myleott

fbshipit-source-id: 59f005164b61b9fa712922eeb23525f7eec38f38
  • Loading branch information
Myle Ott authored and facebook-github-bot committed Jul 22, 2019
1 parent 906411d commit 51ba352
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hubconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.

import functools

from fairseq.models import MODEL_REGISTRY


Expand All @@ -18,5 +20,11 @@
]


for model, cls in MODEL_REGISTRY.items():
globals()[model] = cls.from_pretrained
for model_type, _cls in MODEL_REGISTRY.items():
for model_name in _cls.hub_models().keys():
globals()[model_name] = functools.partial(
_cls.from_pretrained,
model_name_or_path=model_name,
)
# to simplify the interface we only expose named models
#globals()[model_type] = _cls.from_pretrained

0 comments on commit 51ba352

Please # to comment.