You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Handle the push to Synapse of the croissant file link. This is done by using
256
+
an authenticated Synapse client to first query the table to determine if an
257
+
update is needed. If the link already exists with the expected S3 URL, then
258
+
skip the update. If the link does not exist or the S3 URL is different, then
259
+
update the link with the new S3 URL using the authenticated Synapse client.
260
+
261
+
Arguments:
262
+
push_to_synapse: A boolean to indicate if the results should be pushed to
263
+
Synapse. When set to `False`, the results will be printed to the logs.
264
+
dataset: The dataset to push to Synapse.
265
+
dataset_id: The ID of the dataset.
266
+
s3_url: The S3 URL to use for the value of the cell in the table.
267
+
syn_client: The unauthenticated Synapse client to use to query the table.
268
+
context: The context of the DAG run.
269
+
270
+
Returns:
271
+
None
272
+
"""
273
+
try:
274
+
ifnotpush_to_synapse:
275
+
otel_logger.info(
276
+
f"Croissant file link for [dataset: {dataset.name}, id: {dataset_id}]: {s3_url}")
277
+
return
278
+
279
+
otel_logger.info(
280
+
f"Uploading croissant file link to Synapse table {SYNAPSE_TABLE_FOR_CROISSANT_LINKS}"
281
+
)
282
+
283
+
# Warning: Using an authenticated Synapse Client during this section of code
284
+
syn_hook=SynapseHook(
285
+
context["params"]["synapse_conn_id"])
286
+
authenticated_syn_client: Synapse=syn_hook.client
287
+
authenticated_syn_client._rest_call=MethodType(
288
+
_rest_call_replacement, authenticated_syn_client)
289
+
existing_row_df=query(query=f"SELECT * FROM {SYNAPSE_TABLE_FOR_CROISSANT_LINKS} WHERE dataset = '{dataset_id}'", synapse_client=authenticated_syn_client)
0 commit comments