@@ -12,54 +12,49 @@ def get_s3_client(kwargs: Optional[Dict[str, Any]] = None):
1212 kwargs = kwargs or {}
1313 session = boto3 .Session ()
1414 client_kwargs = {}
15-
15+
1616 if infra_config ().cloud_provider == "onprem" :
1717 logger .debug ("Using on-prem/MinIO S3-compatible configuration" )
18-
18+
1919 s3_endpoint = getattr (infra_config (), "s3_endpoint_url" , None ) or os .getenv (
2020 "S3_ENDPOINT_URL"
2121 )
2222 if s3_endpoint :
2323 client_kwargs ["endpoint_url" ] = s3_endpoint
2424 logger .debug (f"Using S3 endpoint: { s3_endpoint } " )
25-
25+
2626 addressing_style = getattr (infra_config (), "s3_addressing_style" , "path" )
27- client_kwargs ["config" ] = boto3 .session .Config (
28- s3 = {"addressing_style" : addressing_style }
29- )
27+ client_kwargs ["config" ] = boto3 .session .Config (s3 = {"addressing_style" : addressing_style })
3028 else :
3129 logger .debug ("Using AWS S3 configuration" )
3230 aws_profile = kwargs .get ("aws_profile" )
3331 if aws_profile :
3432 session = boto3 .Session (profile_name = aws_profile )
35-
33+
3634 return session .client ("s3" , ** client_kwargs )
3735
3836
3937def get_s3_resource (kwargs : Optional [Dict [str , Any ]] = None ):
4038 kwargs = kwargs or {}
4139 session = boto3 .Session ()
4240 resource_kwargs = {}
43-
41+
4442 if infra_config ().cloud_provider == "onprem" :
4543 logger .debug ("Using on-prem/MinIO S3-compatible configuration" )
46-
44+
4745 s3_endpoint = getattr (infra_config (), "s3_endpoint_url" , None ) or os .getenv (
4846 "S3_ENDPOINT_URL"
4947 )
5048 if s3_endpoint :
5149 resource_kwargs ["endpoint_url" ] = s3_endpoint
5250 logger .debug (f"Using S3 endpoint: { s3_endpoint } " )
53-
51+
5452 addressing_style = getattr (infra_config (), "s3_addressing_style" , "path" )
55- resource_kwargs ["config" ] = boto3 .session .Config (
56- s3 = {"addressing_style" : addressing_style }
57- )
53+ resource_kwargs ["config" ] = boto3 .session .Config (s3 = {"addressing_style" : addressing_style })
5854 else :
5955 logger .debug ("Using AWS S3 configuration" )
6056 aws_profile = kwargs .get ("aws_profile" )
6157 if aws_profile :
6258 session = boto3 .Session (profile_name = aws_profile )
63-
64- return session .resource ("s3" , ** resource_kwargs )
6559
60+ return session .resource ("s3" , ** resource_kwargs )
0 commit comments