Skip to content

Commit b405c50

Browse files
Format People.ai connector
1 parent f5c4937 commit b405c50

1 file changed

Lines changed: 28 additions & 8 deletions

File tree

people_ai/connector.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
__REAUTH_RETRY_COUNT = 1
5757

5858

59-
6059
def schema(configuration: dict) -> List[Dict[str, Any]]:
6160
"""
6261
Define the schema function which lets you configure the schema your connector delivers.
@@ -72,7 +71,10 @@ def schema(configuration: dict) -> List[Dict[str, Any]]:
7271
},
7372
{
7473
"table": "participants", # Name of the table in the destination, required.
75-
"primary_key": ["uid", "email"], # Primary key column(s) for the table, optional.
74+
"primary_key": [
75+
"uid",
76+
"email",
77+
], # Primary key column(s) for the table, optional.
7678
},
7779
]
7880

@@ -202,7 +204,12 @@ def get_page(
202204

203205

204206
def sync_base_activities(
205-
access_token: str, state: dict, reauth_func: Callable[[], str], op: op, *, limit: int = 50
207+
access_token: str,
208+
state: dict,
209+
reauth_func: Callable[[], str],
210+
op: op,
211+
*,
212+
limit: int = 50,
206213
) -> int:
207214
"""
208215
Handles the full pagination and upsert logic for the base /activities endpoint.
@@ -239,7 +246,10 @@ def sync_base_activities(
239246
except requests.exceptions.HTTPError as e:
240247
# The retry logic is now inside get_page,
241248
# so an error here means it failed permanently
242-
log.error(f"Permanent failure fetching base activities" f" at offset {offset}: {e}")
249+
log.error(
250+
f"Permanent failure fetching base activities"
251+
f" at offset {offset}: {e}"
252+
)
243253
break
244254

245255
if not page:
@@ -313,11 +323,16 @@ def sync_activity_type(
313323
while True:
314324
try:
315325
# Pass the reauth_func
316-
page = get_page(access_token, reauth_func, activity_type, limit=limit, offset=offset)
326+
page = get_page(
327+
access_token, reauth_func, activity_type, limit=limit, offset=offset
328+
)
317329
except requests.exceptions.HTTPError as e:
318330
# The retry logic is now inside get_page,
319331
# so an error here means it failed permanently
320-
log.error(f"Permanent failure fetching {activity_type}" f" at offset {offset}: {e}")
332+
log.error(
333+
f"Permanent failure fetching {activity_type}"
334+
f" at offset {offset}: {e}"
335+
)
321336
break
322337

323338
if not page:
@@ -448,7 +463,9 @@ def reauthenticate():
448463

449464
# 3. Sync only the specific activity type
450465
# endpoints defined in __ACTIVITY_TYPES
451-
log.info(f"\nStarting sync for the {len(__ACTIVITY_TYPES)} " "specific activity type(s).")
466+
log.info(
467+
f"\nStarting sync for the {len(__ACTIVITY_TYPES)} " "specific activity type(s)."
468+
)
452469

453470
for activity_type in __ACTIVITY_TYPES:
454471
count = sync_activity_type(
@@ -461,7 +478,10 @@ def reauthenticate():
461478
)
462479
total_records_synced += count
463480

464-
log.info(f"\n--- All tables synced. Total records processed: " f"{total_records_synced} ---")
481+
log.info(
482+
f"\n--- All tables synced. Total records processed: "
483+
f"{total_records_synced} ---"
484+
)
465485

466486

467487
# Create the connector object using the schema and update functions

0 commit comments

Comments
 (0)