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

Function run_client_upload_flow

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

Source from the content-addressed store, hash-verified

100
101def run_client_upload_flow(
102 args: argparse.Namespace,
103 s3_client,
104 bucket: str,
105 object_key: str,
106) -> Dict[str, float]:
107 put_url, get_url = generate_presigned_pair(s3_client, bucket, object_key, args.presign_expires)
108
109 payload = build_sync_payload(args, presigned_url="")
110 t0 = time.perf_counter()
111 response = call_sync(args.url, payload, args.timeout_seconds, args.poll_interval_seconds)
112 t1 = time.perf_counter()
113 if response.status_code != 200:
114 raise RuntimeError(f"[client_upload] sync failed ({response.status_code}): {response.text}")
115 image_bytes = response.content
116 t2 = time.perf_counter()
117 upload_resp = requests.put(put_url, data=image_bytes, timeout=args.upload_timeout_seconds)
118 t3 = time.perf_counter()
119 if upload_resp.status_code not in (200, 201, 204):
120 raise RuntimeError(f"[client_upload] upload failed ({upload_resp.status_code}): {upload_resp.text}")
121
122 if args.verify_download:
123 check_resp = requests.get(get_url, timeout=args.download_timeout_seconds)
124 if check_resp.status_code != 200:
125 raise RuntimeError(f"[client_upload] download verify failed ({check_resp.status_code}): {check_resp.text}")
126
127 return {
128 "sync_ms": (t1 - t0) * 1000.0,
129 "upload_ms": (t3 - t2) * 1000.0,
130 "total_ms": (t3 - t0) * 1000.0,
131 "bytes": float(len(image_bytes)),
132 }
133
134
135def run_server_upload_flow(
136 args: argparse.Namespace,

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