@@ -174,7 +174,7 @@ def copy_pt_project_from_bucket(self, name: Union[str, Path], patterns: Union[st
174
174
raise Exception (
175
175
f"No paratext project name is given. Data still in the cache directory of { self .pt_projects_dir } "
176
176
)
177
- config = Config ( read_timeout = 600 )
177
+ config = generate_s3_config ( )
178
178
s3 = boto3 .resource ("s3" , config = config )
179
179
data_bucket = s3 .Bucket (str (self .data_dir ).strip ("\\ /" ))
180
180
len_silnlp_path = len (pt_projects_path )
@@ -208,7 +208,7 @@ def copy_experiment_from_bucket(self, name: Union[str, Path], patterns: Union[st
208
208
raise Exception (
209
209
f"No experiment name is given. Data still in the cache directory of { self .mt_experiments_dir } "
210
210
)
211
- config = Config ( read_timeout = 600 )
211
+ config = generate_s3_config ( )
212
212
s3 = boto3 .resource ("s3" , config = config )
213
213
data_bucket = s3 .Bucket (str (self .data_dir ).strip ("\\ /" ))
214
214
len_silnlp_path = len (experiments_path )
@@ -241,7 +241,7 @@ def copy_experiment_to_bucket(self, name: str, patterns: Union[str, Sequence[str
241
241
f"No experiment name is given. Data still in the temp directory of { self .mt_experiments_dir } "
242
242
)
243
243
experiment_path = str (self .mt_dir .relative_to (self .data_dir ) / "experiments" ) + "/"
244
- config = Config ( read_timeout = 600 )
244
+ config = generate_s3_config ( )
245
245
s3 = boto3 .resource ("s3" , config = config )
246
246
data_bucket = s3 .Bucket (str (self .data_dir ).strip ("\\ /" ))
247
247
temp_folder = str (self .mt_experiments_dir / name )
@@ -285,7 +285,7 @@ def download_if_s3_paths(paths: Iterable[S3Path]) -> List[Path]:
285
285
if not s3_setup :
286
286
temp_root = Path (tempfile .TemporaryDirectory ().name )
287
287
temp_root .mkdir ()
288
- config = Config ( read_timeout = 600 )
288
+ config = generate_s3_config ( )
289
289
s3 = boto3 .resource ("s3" , config = config )
290
290
data_bucket = s3 .Bucket (str (SIL_NLP_ENV .data_dir ).strip ("\\ /" ))
291
291
s3_setup = True
@@ -337,4 +337,14 @@ def get_env_path(name: str, default: str = ".") -> str:
337
337
return path
338
338
339
339
340
+ def generate_s3_config () -> Config :
341
+ s3_config = Config (
342
+ s3 = {"addressing_style" : "path" },
343
+ retries = {"mode" : "adaptive" , "max_attempts" : 10 },
344
+ connect_timeout = 600 ,
345
+ read_timeout = 600 ,
346
+ )
347
+ return s3_config
348
+
349
+
340
350
SIL_NLP_ENV = SilNlpEnv ()
0 commit comments