FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
feast/sdk/python/feast/importer.py at featureview-versioning · feast-dev/feast · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
feast-dev
/
feast
Public
Notifications
You must be signed in to change notification settings
Fork
1.4k
Star
7.2k
Code
Issues
218
Pull requests
191
Discussions
Actions
Security and quality
1
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
feast
/
sdk
/
python
/
feast
/
importer.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
47 lines (39 loc) · 1.66 KB
Breadcrumbs
feast
/
sdk
/
python
/
feast
/
importer.py
Copy path
File metadata and controls
47 lines (39 loc) · 1.66 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import
importlib
from
feast
.
errors
import
(
FeastClassImportError
,
FeastInvalidBaseClass
,
FeastModuleImportError
,
)
def
import_class
(
module_name
:
str
,
class_name
:
str
,
class_type
:
str
=
""
):
"""
Dynamically loads and returns a class from a module.
Args:
module_name: The name of the module.
class_name: The name of the class.
class_type: Optional name of a base class of the class.
Raises:
FeastInvalidBaseClass: If the class name does not end with the specified suffix.
FeastModuleImportError: If the module cannot be imported.
FeastClassImportError: If the class cannot be imported.
"""
# Try importing the module.
try
:
module
=
importlib
.
import_module
(
module_name
)
except
Exception
as
e
:
# The original exception can be anything - either module not found,
# or any other kind of error happening during the module import time.
# So we should include the original error as well in the stack trace.
raise
FeastModuleImportError
(
module_name
,
class_name
)
from
e
# Try getting the class.
try
:
_class
=
getattr
(
module
,
class_name
)
except
AttributeError
:
# This can only be one type of error, when class_name attribute does not exist in the module
# So we don't have to include the original exception here
raise
FeastClassImportError
(
module_name
,
class_name
)
from
None
# Check if the class is a subclass of the base class.
if
class_type
and
not
any
(
base_class
.
__name__
==
class_type
for
base_class
in
_class
.
mro
()
):
raise
FeastInvalidBaseClass
(
class_name
,
class_type
)
return
_class
Back
|
FazBrowse Home
|
New Git URL