Skip to content

Commit

Permalink
Move dep checks before fairseq imports in hubconf.py (fixes facebookr…
Browse files Browse the repository at this point in the history
…esearch#3093) (facebookresearch#3104)

Summary: Pull Request resolved: facebookresearch#3104

Reviewed By: alexeib

Differential Revision: D25786013

Pulled By: myleott

fbshipit-source-id: 894b104f275573ce824d7f2318d043516f0e0c5c
  • Loading branch information
myleott authored and facebook-github-bot committed Jan 5, 2021
1 parent 7e5e45b commit 540fb42
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions hubconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""isort:skip_file"""

import functools
import importlib

from fairseq.hub_utils import ( # noqa; noqa
BPEHubInterface as bpe,
TokenizerHubInterface as tokenizer,
)
from fairseq.models import MODEL_REGISTRY # noqa


dependencies = [
"dataclasses",
Expand Down Expand Up @@ -40,6 +35,14 @@
raise RuntimeError("Missing dependencies: {}".format(", ".join(missing_deps)))


# only do fairseq imports after checking for dependencies
from fairseq.hub_utils import ( # noqa; noqa
BPEHubInterface as bpe,
TokenizerHubInterface as tokenizer,
)
from fairseq.models import MODEL_REGISTRY # noqa


# torch.hub doesn't build Cython components, so if they are not found then try
# to build them here
try:
Expand Down

0 comments on commit 540fb42

Please sign in to comment.