Skip to content

Commit

Permalink
build: added engine dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino committed Nov 12, 2024
1 parent 542b7e8 commit 8c94837
Show file tree
Hide file tree
Showing 5 changed files with 321 additions and 143 deletions.
1 change: 1 addition & 0 deletions cognite/neat/_session/_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self, state: SessionState, client: CogniteClient | None, verbose: b
self.cdf = CDFReadAPI(state, client, verbose)
self.rdf = RDFReadAPI(state, client, verbose)
self.excel = ExcelReadAPI(state, client, verbose)
self.csv = CSVReadAPI(state, client, verbose)


@intercept_session_exceptions
Expand Down
2 changes: 1 addition & 1 deletion cognite/neat/_session/engine/_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def primary_key(self, key: str) -> None: ...


class NeatEngine(Protocol):
version: ClassVar[str] = "0.1.0"
version: ClassVar[str] = "1.0.0"

@property
def set(self) -> SetterAPI: ...
Expand Down
16 changes: 13 additions & 3 deletions cognite/neat/_session/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@ def wrapper(*args: Any, **kwargs: Any):
try:
return func(*args, **kwargs)
except NeatSessionError as e:
action = func.__name__
if action == "__call__":
action = func.__qualname__.removesuffix(".__call__").removesuffix("API")
action = _get_action()
print(f"{_PREFIX} Cannot {action}: {e}")
except ModuleNotFoundError as e:
if e.name == "neatengine":
action = _get_action()
print(f"{_PREFIX} The functionality {action} requires the NeatEngine.")
else:
raise e

def _get_action():
action = func.__name__
if action == "__call__":
action = func.__qualname__.removesuffix(".__call__").removesuffix("API")
return action

return wrapper

Expand Down
Loading

0 comments on commit 8c94837

Please sign in to comment.