Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions layer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from typing import TYPE_CHECKING

import lazy_loader # noqa

from .context import Context # noqa
from .contracts.datasets import Dataset # noqa
from .contracts.logged_data import Image, Markdown, Video # noqa
Expand All @@ -21,8 +25,6 @@
)
from .flavors.custom import CustomModel # noqa
from .global_context import current_project_full_name # noqa
from .logged_data.callbacks import KerasCallback, XGBoostCallback # noqa
from .logged_data.loggers.pytorch_lightning import PytorchLightningLogger # noqa
from .main.asset import get_dataset, get_model, save_model # noqa
from .main.auth import ( # noqa
login,
Expand All @@ -39,6 +41,20 @@
from .pandas_extensions import Arrays, Images, _register_type_extensions # noqa


# keep the existing type definitions only for autocompletions in the editors and type checks
if TYPE_CHECKING:
from .logged_data.callbacks import KerasCallback, XGBoostCallback # noqa
from .logged_data.loggers.pytorch_lightning import PytorchLightningLogger # noqa

# patch __getattr__, __dir__ and __all__ to lazy load the symbols only when they're required
__getattr__, __dir__, __all__ = lazy_loader.attach(
__name__,
submod_attrs={
"logged_data.callbacks": ["KerasCallback", "XGBoostCallback"],
"logged_data.loggers.pytorch_lightning": ["PytorchLightningLogger"],
},
)

_register_type_extensions()

__version__ = get_version()
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ ignore_missing_imports = true

[mypy-cloudpickle]
ignore_missing_imports = true

[mypy-lazy_loader]
ignore_missing_imports = true
Loading