Skip to content

Commit

Permalink
fix exception types
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 committed Jul 26, 2024
1 parent f5fc70d commit 4db9421
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion metadata-ingestion/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
},
# FIXME: I don't think tableau uses sqllineage anymore so we should be able
# to remove that dependency.
"tableau": {"tableauserverclient>=0.30.0"} | sqllineage_lib | sqlglot_lib,
"tableau": {"tableauserverclient>=0.24.0"} | sqllineage_lib | sqlglot_lib,
"teradata": sql_common
| usage_common
| sqlglot_lib
Expand Down
27 changes: 16 additions & 11 deletions metadata-ingestion/src/datahub/ingestion/source/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Optional,
Set,
Tuple,
Type,
Union,
cast,
)
Expand All @@ -31,10 +32,7 @@
SiteItem,
TableauAuth,
)
from tableauserverclient.server.endpoint.exceptions import (
NonXMLResponseError,
NotSignedInError,
)
from tableauserverclient.server.endpoint.exceptions import NonXMLResponseError
from urllib3 import Retry

import datahub.emitter.mce_builder as builder
Expand Down Expand Up @@ -162,6 +160,19 @@
from datahub.utilities import config_clean
from datahub.utilities.urns.dataset_urn import DatasetUrn

try:
# On earlier versions of the tableauserverclient, the NonXMLResponseError
# was thrown when reauthentication was needed. We'll keep both exceptions
# around for now, but can remove this in the future.
from tableauserverclient.server.endpoint.exceptions import NotSignedInError

REAUTHENTICATE_ERRORS: Tuple[Type[Exception], ...] = (
NotSignedInError,
NonXMLResponseError,
)
except ImportError:
REAUTHENTICATE_ERRORS = (NonXMLResponseError,)

logger: logging.Logger = logging.getLogger(__name__)

# Replace / with |
Expand Down Expand Up @@ -969,13 +980,7 @@ def get_connection_object_page(
query_data = query_metadata(
self.server, query, connection_type, count, offset, query_filter
)
except (
# On earlier versions of the tableauserverclient, the NonXMLResponseError
# was thrown when reauthentication was needed. We'll keep both exceptions
# around for now, but can remove this in the future.
NonXMLResponseError,
NotSignedInError,
):
except REAUTHENTICATE_ERRORS:
if not retry_on_auth_error:
raise

Expand Down

0 comments on commit 4db9421

Please sign in to comment.