MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / run_server_upload_flow

Function run_server_upload_flow

scripts/server/benchmark_sync_s3_latency.py:136–165  ·  view source on GitHub ↗
(
    args: argparse.Namespace,
    s3_client,
    bucket: str,
    object_key: str,
)

Source from the content-addressed store, hash-verified

134
135def run_server_upload_flow(
136 args: argparse.Namespace,
137 s3_client,
138 bucket: str,
139 object_key: str,
140) -> Dict[str, float]:
141 put_url, get_url = generate_presigned_pair(s3_client, bucket, object_key, args.presign_expires)
142 payload = build_sync_payload(args, presigned_url=put_url)
143
144 t0 = time.perf_counter()
145 response = call_sync(args.url, payload, args.timeout_seconds, args.poll_interval_seconds)
146 t1 = time.perf_counter()
147 if response.status_code != 200:
148 raise RuntimeError(f"[server_upload] sync failed ({response.status_code}): {response.text}")
149
150 content_type = response.headers.get("content-type", "")
151 if "application/json" not in content_type:
152 raise RuntimeError(f"[server_upload] expected JSON but got content-type={content_type!r}")
153 body = response.json()
154 if not body.get("uploaded_to_presigned_url"):
155 raise RuntimeError(f"[server_upload] upload flag is false, response={json.dumps(body, ensure_ascii=False)}")
156
157 if args.verify_download:
158 check_resp = requests.get(get_url, timeout=args.download_timeout_seconds)
159 if check_resp.status_code != 200:
160 raise RuntimeError(f"[server_upload] download verify failed ({check_resp.status_code}): {check_resp.text}")
161
162 return {
163 "sync_total_ms": (t1 - t0) * 1000.0,
164 }
165
166
167def print_summary(label: str, values: List[float]) -> None:
168 print(f"{label}: avg={statistics.mean(values):.2f} ms, p50={percentile(values, 0.5):.2f} ms, p90={percentile(values, 0.9):.2f} ms, min={min(values):.2f} ms, max={max(values):.2f} ms")

Callers 1

mainFunction · 0.85

Calls 4

generate_presigned_pairFunction · 0.85
build_sync_payloadFunction · 0.85
call_syncFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected