Experimental planned references planned-v2026.09.05
Browse files
experimental/planned-reference/planned-v2026.09.05/download.py
CHANGED
|
@@ -11,6 +11,8 @@ from __future__ import annotations
|
|
| 11 |
import argparse
|
| 12 |
from collections import Counter
|
| 13 |
from contextlib import contextmanager
|
|
|
|
|
|
|
| 14 |
import gzip
|
| 15 |
import hashlib
|
| 16 |
import json
|
|
@@ -21,6 +23,7 @@ import shutil
|
|
| 21 |
import subprocess
|
| 22 |
import sys
|
| 23 |
import tempfile
|
|
|
|
| 24 |
|
| 25 |
ROOT = Path(__file__).resolve().parents[1]
|
| 26 |
if str(ROOT) not in sys.path:
|
|
@@ -486,10 +489,45 @@ def prepare(args):
|
|
| 486 |
|
| 487 |
def verify_remote(api, repo, commit, files):
|
| 488 |
# Hub metadata requests are bounded; the native helper compares Git blobs or
|
| 489 |
-
# LFS SHA-256.
|
|
|
|
| 490 |
names = sorted(files)
|
| 491 |
-
|
| 492 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
|
| 494 |
|
| 495 |
def publish(args):
|
|
|
|
| 11 |
import argparse
|
| 12 |
from collections import Counter
|
| 13 |
from contextlib import contextmanager
|
| 14 |
+
from datetime import datetime, timezone
|
| 15 |
+
from email.utils import parsedate_to_datetime
|
| 16 |
import gzip
|
| 17 |
import hashlib
|
| 18 |
import json
|
|
|
|
| 23 |
import subprocess
|
| 24 |
import sys
|
| 25 |
import tempfile
|
| 26 |
+
import time
|
| 27 |
|
| 28 |
ROOT = Path(__file__).resolve().parents[1]
|
| 29 |
if str(ROOT) not in sys.path:
|
|
|
|
| 489 |
|
| 490 |
def verify_remote(api, repo, commit, files):
|
| 491 |
# Hub metadata requests are bounded; the native helper compares Git blobs or
|
| 492 |
+
# LFS SHA-256. Only read-only verification is retried, never publication.
|
| 493 |
+
# A global retry/sleep budget also bounds failures spread across many batches.
|
| 494 |
names = sorted(files)
|
| 495 |
+
retries = 0
|
| 496 |
+
slept = 0.0
|
| 497 |
+
for offset in range(0, len(names), 20):
|
| 498 |
+
batch = {name: files[name] for name in names[offset:offset+20]}
|
| 499 |
+
for attempt in range(6):
|
| 500 |
+
try:
|
| 501 |
+
common.verify_public_files(api, repo, commit, batch)
|
| 502 |
+
break
|
| 503 |
+
except Exception as exc:
|
| 504 |
+
response = getattr(exc, 'response', None)
|
| 505 |
+
if (getattr(response, 'status_code', None) not in (429, 503) or
|
| 506 |
+
attempt == 5 or retries >= 12):
|
| 507 |
+
raise
|
| 508 |
+
delay = float(2 ** (attempt+1))
|
| 509 |
+
value = response.headers.get('Retry-After')
|
| 510 |
+
if value:
|
| 511 |
+
# Accept standard nonnegative delay-seconds or timezone-aware
|
| 512 |
+
# HTTP dates. Malformed headers fall back to exponential delay.
|
| 513 |
+
try:
|
| 514 |
+
if re.fullmatch(r'[0-9]+', value.strip()):
|
| 515 |
+
requested = float(value.strip())
|
| 516 |
+
else:
|
| 517 |
+
date = parsedate_to_datetime(value)
|
| 518 |
+
if date.tzinfo is None:
|
| 519 |
+
raise ValueError('Retry-After date needs a timezone')
|
| 520 |
+
requested = max(0.0, (date-datetime.now(timezone.utc)).total_seconds())
|
| 521 |
+
delay = max(delay, requested)
|
| 522 |
+
except (TypeError, ValueError, OverflowError):
|
| 523 |
+
pass
|
| 524 |
+
# Do not retry earlier than a long server-requested wait. Fail
|
| 525 |
+
# with the original HTTP error if it exceeds this bounded call.
|
| 526 |
+
if delay > 60 or slept+delay > 180:
|
| 527 |
+
raise
|
| 528 |
+
retries += 1
|
| 529 |
+
slept += delay
|
| 530 |
+
time.sleep(delay)
|
| 531 |
|
| 532 |
|
| 533 |
def publish(args):
|
experimental/planned-reference/planned-v2026.09.05/release.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|