2525from onyx .redis .redis_connector_utils import get_deletion_attempt_snapshot
2626from onyx .server .documents .models import IndexAttemptSnapshot
2727
28- def get_connectors_state (
29- db_session , tenant_id
30- ) -> list [ConnectorIndexingStatus ]:
28+
29+ def get_connectors_state (db_session , tenant_id ) -> list [ConnectorIndexingStatus ]:
3130 indexing_statuses : list [ConnectorIndexingStatus ] = []
3231
3332 user = None
@@ -42,14 +41,13 @@ def get_connectors_state(
4241 # to avoid the complexity of trying to error check throughout the function
4342 cc_pairs = get_connector_credential_pairs (
4443 db_session = db_session ,
45- # user=user,
46- # get_editable=False,
44+ # user=user,
45+ # get_editable=False,
4746 )
4847
4948 cc_pair_identifiers = [
5049 ConnectorCredentialPairIdentifier (
51- connector_id = cc_pair .connector_id , credential_id = cc_pair .credential_id
52- )
50+ connector_id = cc_pair .connector_id , credential_id = cc_pair .credential_id )
5351 for cc_pair in cc_pairs
5452 ]
5553
@@ -68,22 +66,19 @@ def get_connectors_state(
6866
6967 document_count_info = get_document_counts_for_cc_pairs (
7068 db_session = db_session ,
71- cc_pair_identifiers = cc_pair_identifiers ,
69+ cc_pairs = cc_pair_identifiers ,
7270 )
73- cc_pair_to_document_cnt = {
74- (connector_id , credential_id ): cnt
75- for connector_id , credential_id , cnt in document_count_info
76- }
71+ cc_pair_to_document_cnt = {(connector_id , credential_id )
72+ : cnt for connector_id , credential_id , cnt in document_count_info }
7773
7874 group_cc_pair_relationships = get_cc_pair_groups_for_ids (
7975 db_session = db_session ,
8076 cc_pair_ids = [cc_pair .id for cc_pair in cc_pairs ],
8177 )
8278 group_cc_pair_relationships_dict : dict [int , list [int ]] = {}
8379 for relationship in group_cc_pair_relationships :
84- group_cc_pair_relationships_dict .setdefault (relationship .cc_pair_id , []).append (
85- relationship .user_group_id
86- )
80+ group_cc_pair_relationships_dict .setdefault (
81+ relationship .cc_pair_id , []).append (relationship .user_group_id )
8782
8883 search_settings : SearchSettings | None = None
8984 if not secondary_index :
@@ -105,18 +100,18 @@ def get_connectors_state(
105100 in_progress = False
106101 if search_settings :
107102 redis_connector = RedisConnector (tenant_id , cc_pair .id )
108- redis_connector_index = redis_connector .new_index (search_settings .id )
103+ redis_connector_index = redis_connector .new_index (
104+ search_settings .id )
109105 if redis_connector_index .fenced :
110106 in_progress = True
111107
112- # if search_settings:
113- # rci = RedisConnectorIndexing(cc_pair.id, search_settings.id)
114- # if r.exists(rci.fence_key):
115- # in_progress = True
108+ # if search_settings:
109+ # rci = RedisConnectorIndexing(cc_pair.id, search_settings.id)
110+ # if r.exists(rci.fence_key):
111+ # in_progress = True
116112
117113 latest_index_attempt = cc_pair_to_latest_index_attempt .get (
118- (connector .id , credential .id )
119- )
114+ (connector .id , credential .id ))
120115
121116 latest_finished_attempt = get_latest_index_attempt_for_cc_pair_id (
122117 db_session = db_session ,
@@ -131,29 +126,23 @@ def get_connectors_state(
131126 name = cc_pair .name ,
132127 cc_pair_status = cc_pair .status ,
133128 connector = ConnectorSnapshot .from_connector_db_model (connector ),
134- credential = CredentialSnapshot .from_credential_db_model (credential ),
129+ credential = CredentialSnapshot .from_credential_db_model (
130+ credential ),
135131 access_type = cc_pair .access_type ,
136132 owner = credential .user .email if credential .user else "" ,
137133 groups = group_cc_pair_relationships_dict .get (cc_pair .id , []),
138134 last_finished_status = (
139- latest_finished_attempt .status if latest_finished_attempt else None
140- ),
135+ latest_finished_attempt .status if latest_finished_attempt else None ),
141136 last_status = (
142- latest_index_attempt .status if latest_index_attempt else None
143- ),
137+ latest_index_attempt .status if latest_index_attempt else None ),
144138 last_success = cc_pair .last_successful_index_time ,
145139 docs_indexed = cc_pair_to_document_cnt .get (
146- (connector .id , credential .id ), 0
147- ),
140+ (connector .id , credential .id ), 0 ),
148141 error_msg = (
149- latest_index_attempt .error_msg if latest_index_attempt else None
150- ),
142+ latest_index_attempt .error_msg if latest_index_attempt else None ),
151143 latest_index_attempt = (
152144 IndexAttemptSnapshot .from_index_attempt_db_model (
153- latest_index_attempt
154- )
155- if latest_index_attempt
156- else None
145+ latest_index_attempt ) if latest_index_attempt else None
157146 ),
158147 deletion_attempt = get_deletion_attempt_snapshot (
159148 connector_id = connector .id ,
0 commit comments