@@ -68,6 +68,7 @@ def log(call: str):
6868_FILE_HASH_CACHE = {}
6969ATTRIBUTE_VISIBILITY_DELAYS = (0 , 3 , 10 , 20 , 35 , 50 , 70 , 90 , 120 )
7070
71+
7172def file_sha256 (path : Path ): # returns (hex_digest, size_bytes)
7273 try :
7374 m = _FILE_HASH_CACHE .get (path )
@@ -166,19 +167,15 @@ def backoff(op, *, delays=(0, 2, 5, 10, 20, 20)):
166167 result = op ()
167168 if attempts > 1 :
168169 retry_count = attempts - 1
169- print (
170- f" [INFO] Backoff succeeded after { retry_count } retry(s); waited { total_delay } s total."
171- )
170+ print (f" [INFO] Backoff succeeded after { retry_count } retry(s); waited { total_delay } s total." )
172171 return result
173172 except Exception as ex : # noqa: BLE001
174173 last = ex
175174 continue
176175 if last :
177176 if attempts :
178177 retry_count = max (attempts - 1 , 0 )
179- print (
180- f" [WARN] Backoff exhausted after { retry_count } retry(s); waited { total_delay } s total."
181- )
178+ print (f" [WARN] Backoff exhausted after { retry_count } retry(s); waited { total_delay } s total." )
182179 raise last
183180
184181
@@ -227,7 +224,7 @@ def ensure_file_attribute_generic(schema_name: str, label: str, key_prefix: str)
227224 f"{ odata .api } /EntityDefinitions({ meta_id } )/Attributes?$select=SchemaName&$filter="
228225 f"SchemaName eq '{ schema_name } '"
229226 )
230- r = backoff (lambda : odata ._request ("get" , url ), delays = ATTRIBUTE_VISIBILITY_DELAYS )
227+ r , _ = backoff (lambda : odata ._request ("get" , url ), delays = ATTRIBUTE_VISIBILITY_DELAYS )
231228 val = []
232229 try :
233230 val = r .json ().get ("value" , [])
@@ -255,7 +252,7 @@ def ensure_file_attribute_generic(schema_name: str, label: str, key_prefix: str)
255252 }
256253 try :
257254 url = f"{ odata .api } /EntityDefinitions({ meta_id } )/Attributes"
258- backoff (lambda : odata ._request ("post" , url , json = payload ), delays = ATTRIBUTE_VISIBILITY_DELAYS )
255+ backoff (lambda : odata ._request ("post" , url , json = payload )[ 0 ] , delays = ATTRIBUTE_VISIBILITY_DELAYS )
259256 print ({f"{ key_prefix } _file_attribute_created" : True })
260257 time .sleep (2 )
261258 return True
@@ -285,7 +282,7 @@ def wait_for_attribute_visibility(logical_name: str, label: str):
285282 time .sleep (delay )
286283 waited += delay
287284 try :
288- resp = odata ._request ("get" , probe_url )
285+ resp , _ = odata ._request ("get" , probe_url )
289286 try :
290287 resp .json ()
291288 except Exception : # noqa: BLE001
@@ -313,7 +310,7 @@ def wait_for_attribute_visibility(logical_name: str, label: str):
313310 payload = {name_attr : "File Sample Record" }
314311 log (f"client.create('{ table_schema_name } ', payload)" )
315312 created_ids = backoff (lambda : client .create (table_schema_name , payload ))
316- if isinstance ( created_ids , list ) and created_ids :
313+ if created_ids and len ( created_ids ) > 0 :
317314 record_id = created_ids [0 ]
318315 else :
319316 raise RuntimeError ("Unexpected create return; expected list[str] with at least one GUID" )
@@ -363,7 +360,7 @@ def get_dataset_info(file_path: Path):
363360 dl_url_single = (
364361 f"{ odata .api } /{ entity_set } ({ record_id } )/{ small_file_attr_logical } /$value" # raw entity_set URL OK
365362 )
366- resp_single = backoff (lambda : odata ._request ("get" , dl_url_single ))
363+ resp_single , _ = backoff (lambda : odata ._request ("get" , dl_url_single ))
367364 content_single = resp_single .content or b""
368365 import hashlib # noqa: WPS433
369366
@@ -393,7 +390,7 @@ def get_dataset_info(file_path: Path):
393390 )
394391 )
395392 print ({"small_replace_upload_completed" : True , "small_replace_source_size" : replace_size_small })
396- resp_single_replace = backoff (lambda : odata ._request ("get" , dl_url_single ))
393+ resp_single_replace , _ = backoff (lambda : odata ._request ("get" , dl_url_single ))
397394 content_single_replace = resp_single_replace .content or b""
398395 downloaded_hash_replace = hashlib .sha256 (content_single_replace ).hexdigest () if content_single_replace else None
399396 hash_match_replace = (
@@ -435,7 +432,7 @@ def get_dataset_info(file_path: Path):
435432 dl_url_chunk = (
436433 f"{ odata .api } /{ entity_set } ({ record_id } )/{ chunk_file_attr_logical } /$value" # raw entity_set for download
437434 )
438- resp_chunk = backoff (lambda : odata ._request ("get" , dl_url_chunk ))
435+ resp_chunk , _ = backoff (lambda : odata ._request ("get" , dl_url_chunk ))
439436 content_chunk = resp_chunk .content or b""
440437 import hashlib # noqa: WPS433
441438
@@ -464,7 +461,7 @@ def get_dataset_info(file_path: Path):
464461 )
465462 )
466463 print ({"chunk_replace_upload_completed" : True })
467- resp_chunk_replace = backoff (lambda : odata ._request ("get" , dl_url_chunk ))
464+ resp_chunk_replace , _ = backoff (lambda : odata ._request ("get" , dl_url_chunk ))
468465 content_chunk_replace = resp_chunk_replace .content or b""
469466 dst_hash_chunk_replace = hashlib .sha256 (content_chunk_replace ).hexdigest () if content_chunk_replace else None
470467 hash_match_chunk_replace = (
0 commit comments