Skip to content

Commit 9618cd6

Browse files
authored
Import integration libraries first (huggingface#7650)
* Import intergration libraries first * isort and black happiness * flake8 happiness * Add a test * Black reformat * Ignore import order in tests * A heavy-handed method of disabling comet for tests * Remove comet_ml tests * Run black on setup.py
1 parent 4dcc424 commit 9618cd6

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

setup.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@
134134
"sacremoses",
135135
],
136136
extras_require=extras,
137-
entry_points={
138-
"console_scripts": ["transformers-cli=transformers.commands.transformers_cli:main"]
139-
},
137+
entry_points={"console_scripts": ["transformers-cli=transformers.commands.transformers_cli:main"]},
140138
python_requires=">=3.6.0",
141139
classifiers=[
142140
"Development Status :: 5 - Production/Stable",

src/transformers/integrations.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
import math
33
import os
44

5-
from .file_utils import is_torch_tpu_available
6-
from .trainer_callback import TrainerCallback
7-
from .trainer_utils import PREFIX_CHECKPOINT_DIR, BestRun
8-
from .utils import logging
95

6+
# Import 3rd-party integrations first:
107

118
try:
9+
# Comet needs to be imported before any ML frameworks
1210
import comet_ml # noqa: F401
1311

1412
_has_comet = True
@@ -53,6 +51,14 @@
5351
except ImportError:
5452
_has_tensorboard = False
5553

54+
# No transformer imports above this point
55+
56+
from .file_utils import is_torch_tpu_available
57+
from .trainer_callback import TrainerCallback
58+
from .trainer_utils import PREFIX_CHECKPOINT_DIR, BestRun
59+
from .utils import logging
60+
61+
5662
logger = logging.get_logger(__name__)
5763

5864

0 commit comments

Comments
 (0)