Skip to content

Commit 66ae3c8

Browse files
committed
Dynamically import entrypoint in root __init__
1 parent 21a3b81 commit 66ae3c8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/zenml/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"""Initialization for ZenML."""
1515

1616
import os
17+
from typing import Any
1718

1819
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
1920

@@ -26,6 +27,16 @@
2627

2728
init_logging()
2829

30+
def __getattr__(name: str) -> Any:
31+
# We allow directly accessing the entrypoint module as `zenml.entrypoint`
32+
# as this is needed for some orchestrators. Instead of directly importing
33+
# the entrypoint module here, we import it dynamically. This avoids a
34+
# warning when running the `zenml.entrypoints.entrypoint` module directly.
35+
if name == "entrypoint":
36+
from zenml.entrypoints import entrypoint
37+
return entrypoint
38+
39+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
2940

3041
# Need to import zenml.models before zenml.config to avoid circular imports
3142
from zenml.models import * # noqa: F401
@@ -50,7 +61,7 @@
5061
from zenml.steps.utils import log_step_metadata
5162
from zenml.utils.metadata_utils import log_metadata
5263
from zenml.utils.tag_utils import Tag, add_tags, remove_tags
53-
from zenml.entrypoints import entrypoint
64+
5465

5566
__all__ = [
5667
"add_tags",
@@ -72,5 +83,4 @@
7283
"register_artifact",
7384
"show",
7485
"step",
75-
"entrypoint",
7686
]

0 commit comments

Comments
 (0)