-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor LanceDB client implementation and error handling
Signed-off-by: Marcel Coetzee <[email protected]>
- Loading branch information
Showing
4 changed files
with
77 additions
and
36 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from functools import wraps | ||
from typing import ( | ||
Any, | ||
) | ||
|
||
from lancedb.exceptions import MissingValueError, MissingColumnError | ||
|
||
from dlt.common.destination.exceptions import ( | ||
DestinationUndefinedEntity, | ||
DestinationTerminalException, | ||
) | ||
from dlt.common.destination.reference import JobClientBase | ||
from dlt.common.typing import TFun | ||
|
||
|
||
def lancedb_error(f: TFun) -> TFun: | ||
@wraps(f) | ||
def _wrap(self: JobClientBase, *args: Any, **kwargs: Any) -> Any: | ||
try: | ||
return f(self, *args, **kwargs) | ||
except ( | ||
MissingValueError, | ||
MissingColumnError, | ||
) as status_ex: | ||
raise DestinationUndefinedEntity(status_ex) from status_ex | ||
except Exception as e: | ||
raise DestinationTerminalException(e) from e | ||
|
||
return _wrap |
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
File renamed without changes.
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