@@ -621,6 +621,12 @@ def update_table(
621
621
self .parsed_columns = parsed_columns
622
622
623
623
624
+ @dataclass
625
+ class SiteIdContentUrl :
626
+ site_id : str
627
+ site_content_url : str
628
+
629
+
624
630
class TableauSourceReport (StaleEntityRemovalSourceReport ):
625
631
get_all_datasources_query_failed : bool = False
626
632
num_get_datasource_query_failures : int = 0
@@ -773,7 +779,6 @@ def get_workunits_internal(self) -> Iterable[MetadataWorkUnit]:
773
779
config = self .config ,
774
780
ctx = self .ctx ,
775
781
site = site ,
776
- site_id = site .id ,
777
782
report = self .report ,
778
783
server = self .server ,
779
784
platform = self .platform ,
@@ -792,8 +797,11 @@ def get_workunits_internal(self) -> Iterable[MetadataWorkUnit]:
792
797
site_source = TableauSiteSource (
793
798
config = self .config ,
794
799
ctx = self .ctx ,
795
- site = site ,
796
- site_id = self .server .site_id ,
800
+ site = site
801
+ if site
802
+ else SiteIdContentUrl (
803
+ site_id = self .server .site_id , site_content_url = self .config .site
804
+ ),
797
805
report = self .report ,
798
806
server = self .server ,
799
807
platform = self .platform ,
@@ -826,8 +834,7 @@ def __init__(
826
834
self ,
827
835
config : TableauConfig ,
828
836
ctx : PipelineContext ,
829
- site : Optional [SiteItem ],
830
- site_id : Optional [str ],
837
+ site : Union [SiteItem , SiteIdContentUrl ],
831
838
report : TableauSourceReport ,
832
839
server : Server ,
833
840
platform : str ,
@@ -838,13 +845,18 @@ def __init__(
838
845
self .ctx : PipelineContext = ctx
839
846
self .platform = platform
840
847
841
- self .site : Optional [SiteItem ] = site
842
- if site_id is not None :
843
- self .site_id : str = site_id
848
+ self .site : Optional [SiteItem ] = None
849
+ if isinstance (site , SiteItem ):
850
+ self .site = site
851
+ assert site .id is not None , "Site ID is required"
852
+ self .site_id = site .id
853
+ self .site_content_url = site .content_url
854
+ elif isinstance (site , SiteIdContentUrl ):
855
+ self .site = None
856
+ self .site_id = site .site_id
857
+ self .site_content_url = site .site_content_url
844
858
else :
845
- assert self .site is not None , "site or site_id is required"
846
- assert self .site .id is not None , "site_id is required when site is provided"
847
- self .site_id = self .site .id
859
+ raise AssertionError ("site or site id+content_url pair is required" )
848
860
849
861
self .database_tables : Dict [str , DatabaseTable ] = {}
850
862
self .tableau_stat_registry : Dict [str , UsageStat ] = {}
@@ -898,16 +910,14 @@ def dataset_browse_prefix(self) -> str:
898
910
# datasets also have the env in the browse path
899
911
return f"/{ self .config .env .lower ()} { self .no_env_browse_prefix } "
900
912
901
- def _re_authenticate (self ):
913
+ def _re_authenticate (self ) -> None :
914
+ self .report .info (
915
+ message = "Re-authenticating to Tableau" ,
916
+ context = f"site='{ self .site_content_url } '" ,
917
+ )
902
918
# Sign-in again may not be enough because Tableau sometimes caches invalid sessions
903
919
# so we need to recreate the Tableau Server object
904
- self .server = self .config .make_tableau_client (self .site_id )
905
-
906
- @property
907
- def site_content_url (self ) -> Optional [str ]:
908
- if self .site and self .site .content_url :
909
- return self .site .content_url
910
- return None
920
+ self .server = self .config .make_tableau_client (self .site_content_url )
911
921
912
922
def _populate_usage_stat_registry (self ) -> None :
913
923
if self .server is None :
0 commit comments