-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed optional imports, documented predictor categorization
- Loading branch information
Showing
7 changed files
with
143 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ python/*.ipynb_checkpoints/* | |
**/META-INF/* | ||
r/tests/testthat/d/tmp2 | ||
**/cache | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,48 @@ | ||
""" | ||
My module docstring | ||
Does this work? | ||
Infinity API client for Pega Decision Management. | ||
""" | ||
|
||
from .client import AsyncInfinity, Infinity | ||
from importlib.util import find_spec | ||
from typing import TYPE_CHECKING, List | ||
|
||
from ..utils.namespaces import MissingDependenciesException | ||
|
||
if TYPE_CHECKING: | ||
from .client import Infinity | ||
|
||
|
||
class DependencyNotFound: | ||
def __init__(self, dependencies: List[str]): | ||
self.dependencies = dependencies | ||
self.namespace = "the DX API Client" | ||
self.deps_group = "api" | ||
|
||
def __repr__(self): | ||
return f"While importing, one or more dependencies were not found: {self.dependencies}" | ||
|
||
def __call__(self): | ||
raise MissingDependenciesException( | ||
self.dependencies, namespace=self.namespace, deps_group=self.deps_group | ||
) | ||
|
||
|
||
def __getattr__(name: str): | ||
"""Lazy import to avoid loading httpx until needed.""" | ||
if name == "Infinity": | ||
missing_dependencies: List[str] = [] | ||
if not find_spec("pydantic"): | ||
missing_dependencies.append("pydantic") | ||
if not find_spec("httpx"): | ||
missing_dependencies.append("httpx") | ||
|
||
if missing_dependencies: | ||
return DependencyNotFound(missing_dependencies) | ||
|
||
from .client import Infinity | ||
|
||
return Infinity | ||
|
||
raise AttributeError(f"module '{__name__}' has no attribute '{name}'") | ||
|
||
|
||
__all__ = ["Infinity", "AsyncInfinity"] | ||
__all__ = ["Infinity", "MissingDependenciesException"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters