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

Function build_s3_client

scripts/server/benchmark_sync_s3_latency.py:32–61  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

30
31
32def build_s3_client(args: argparse.Namespace):
33 if boto3 is None or BotoConfig is None:
34 raise RuntimeError("boto3/botocore is required. Please install boto3 or aioboto3.")
35
36 region = args.s3_region or os.getenv("AWS_DEFAULT_REGION", "us-east-1")
37 access_key = args.s3_access_key or os.getenv("AWS_ACCESS_KEY_ID")
38 secret_key = args.s3_secret_key or os.getenv("AWS_SECRET_ACCESS_KEY")
39 session_token = args.s3_session_token or os.getenv("AWS_SESSION_TOKEN")
40 addressing_style = (args.s3_addressing_style or os.getenv("S3_ADDRESSING_STYLE", "auto")).strip().lower()
41 signature_version = (args.s3_signature_version or os.getenv("S3_SIGNATURE_VERSION", "s3v4")).strip()
42
43 if addressing_style not in {"auto", "path", "virtual"}:
44 raise ValueError("--s3_addressing_style must be one of: auto, path, virtual")
45
46 client_kwargs: Dict[str, Any] = {
47 "service_name": "s3",
48 "region_name": region,
49 "config": BotoConfig(
50 signature_version=signature_version,
51 s3={"addressing_style": addressing_style},
52 ),
53 }
54 if args.s3_endpoint_url:
55 client_kwargs["endpoint_url"] = args.s3_endpoint_url
56 if access_key and secret_key:
57 client_kwargs["aws_access_key_id"] = access_key
58 client_kwargs["aws_secret_access_key"] = secret_key
59 if session_token:
60 client_kwargs["aws_session_token"] = session_token
61 return boto3.client(**client_kwargs)
62
63
64def generate_presigned_pair(s3_client, bucket: str, object_key: str, expires_in: int) -> tuple[str, str]:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected