Skip to content

Commit

Permalink
Add permissions check
Browse files Browse the repository at this point in the history
  • Loading branch information
irenedea committed Sep 12, 2024
1 parent 8a8de18 commit e124942
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions llmfoundry/command_utils/data_prep/convert_delta_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ClusterDoesNotExistError,
FailedToConnectToDatabricksError,
FailedToCreateSQLConnectionError,
InsufficientPermissionsError,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -454,6 +455,13 @@ def fetch(
sparkSession,
)
except Exception as e:
from pyspark.errors import AnalysisException
if isinstance(e, AnalysisException):
if 'INSUFFICIENT_PERMISSIONS' in e.message:
raise InsufficientPermissionsError(
action=
f'reading from {tablename}. Please check your permissions.',
) from e
raise RuntimeError(
f'Error in get rows from {tablename}. Restart sparkSession and try again',
) from e
Expand Down
8 changes: 8 additions & 0 deletions llmfoundry/utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,11 @@ def __init__(
window_size=window_size,
loss_window=loss_window,
)


class InsufficientPermissionsError(UserError):
"""Error thrown when the user does not have sufficient permissions."""

def __init__(self, action: str) -> None:
message = f'Insufficient permissions when {action}.'
super().__init__(message, action=action)

0 comments on commit e124942

Please sign in to comment.