|
4 | 4 | import os |
5 | 5 | import sys |
6 | 6 | import time |
| 7 | +import typing |
7 | 8 |
|
8 | 9 | _this_year = time.strftime("%Y") |
9 | 10 | __version__ = '1.3.0dev' |
|
50 | 51 | _PACKAGE_ROOT = os.path.dirname(__file__) |
51 | 52 | _PROJECT_ROOT = os.path.dirname(_PACKAGE_ROOT) |
52 | 53 |
|
53 | | -try: |
54 | | - # This variable is injected in the __builtins__ by the build |
55 | | - # process. It used to enable importing subpackages of skimage when |
56 | | - # the binaries are not built |
57 | | - _ = None if __LIGHTNING_SETUP__ else None |
58 | | -except NameError: |
59 | | - __LIGHTNING_SETUP__: bool = False |
60 | 54 |
|
61 | | -if __LIGHTNING_SETUP__: # pragma: no-cover |
62 | | - sys.stdout.write(f'Partial import of `{__name__}` during the build process.\n') # pragma: no-cover |
63 | | - # We are not importing the rest of the lightning during the build process, as it may not be compiled yet |
64 | | -else: |
| 55 | +if typing.TYPE_CHECKING: |
65 | 56 | from pytorch_lightning import metrics |
66 | 57 | from pytorch_lightning.callbacks import Callback |
67 | 58 | from pytorch_lightning.core import LightningDataModule, LightningModule |
|
76 | 67 | 'seed_everything', |
77 | 68 | 'metrics', |
78 | 69 | ] |
| 70 | +else: |
| 71 | + try: |
| 72 | + # This variable is injected in the __builtins__ by the build |
| 73 | + # process. It used to enable importing subpackages of skimage when |
| 74 | + # the binaries are not built |
| 75 | + _ = None if __LIGHTNING_SETUP__ else None |
| 76 | + except NameError: |
| 77 | + __LIGHTNING_SETUP__: bool = False |
| 78 | + |
| 79 | + if __LIGHTNING_SETUP__: # pragma: no-cover |
| 80 | + sys.stdout.write(f'Partial import of `{__name__}` during the build process.\n') # pragma: no-cover |
| 81 | + # We are not importing the rest of the lightning during the build process, as it may not be compiled yet |
| 82 | + else: |
| 83 | + from pytorch_lightning import metrics |
| 84 | + from pytorch_lightning.callbacks import Callback |
| 85 | + from pytorch_lightning.core import LightningDataModule, LightningModule |
| 86 | + from pytorch_lightning.trainer import Trainer |
| 87 | + from pytorch_lightning.utilities.seed import seed_everything |
| 88 | + |
| 89 | + __all__ = [ |
| 90 | + 'Trainer', |
| 91 | + 'LightningDataModule', |
| 92 | + 'LightningModule', |
| 93 | + 'Callback', |
| 94 | + 'seed_everything', |
| 95 | + 'metrics', |
| 96 | + ] |
79 | 97 |
|
80 | 98 | # for compatibility with namespace packages |
81 | 99 | __import__('pkg_resources').declare_namespace(__name__) |
0 commit comments