@@ -174,12 +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 (
178
- s3 = {"addressing_style" : "path" },
179
- retries = {"mode" : "adaptive" , "max_attempts" : 10 },
180
- connect_timeout = 600 ,
181
- read_timeout = 600 ,
182
- )
177
+ config = generate_s3_config ()
183
178
s3 = boto3 .resource ("s3" , config = config )
184
179
data_bucket = s3 .Bucket (str (self .data_dir ).strip ("\\ /" ))
185
180
len_silnlp_path = len (pt_projects_path )
@@ -213,12 +208,7 @@ def copy_experiment_from_bucket(self, name: Union[str, Path], patterns: Union[st
213
208
raise Exception (
214
209
f"No experiment name is given. Data still in the cache directory of { self .mt_experiments_dir } "
215
210
)
216
- config = Config (
217
- s3 = {"addressing_style" : "path" },
218
- retries = {"mode" : "adaptive" , "max_attempts" : 10 },
219
- connect_timeout = 600 ,
220
- read_timeout = 600 ,
221
- )
211
+ config = generate_s3_config ()
222
212
s3 = boto3 .resource ("s3" , config = config )
223
213
data_bucket = s3 .Bucket (str (self .data_dir ).strip ("\\ /" ))
224
214
len_silnlp_path = len (experiments_path )
@@ -251,12 +241,7 @@ def copy_experiment_to_bucket(self, name: str, patterns: Union[str, Sequence[str
251
241
f"No experiment name is given. Data still in the temp directory of { self .mt_experiments_dir } "
252
242
)
253
243
experiment_path = str (self .mt_dir .relative_to (self .data_dir ) / "experiments" ) + "/"
254
- config = Config (
255
- s3 = {"addressing_style" : "path" },
256
- retries = {"mode" : "adaptive" , "max_attempts" : 10 },
257
- connect_timeout = 600 ,
258
- read_timeout = 600 ,
259
- )
244
+ config = generate_s3_config ()
260
245
s3 = boto3 .resource ("s3" , config = config )
261
246
data_bucket = s3 .Bucket (str (self .data_dir ).strip ("\\ /" ))
262
247
temp_folder = str (self .mt_experiments_dir / name )
@@ -300,12 +285,7 @@ def download_if_s3_paths(paths: Iterable[S3Path]) -> List[Path]:
300
285
if not s3_setup :
301
286
temp_root = Path (tempfile .TemporaryDirectory ().name )
302
287
temp_root .mkdir ()
303
- config = Config (
304
- s3 = {"addressing_style" : "path" },
305
- retries = {"mode" : "adaptive" , "max_attempts" : 10 },
306
- connect_timeout = 600 ,
307
- read_timeout = 600 ,
308
- )
288
+ config = generate_s3_config ()
309
289
s3 = boto3 .resource ("s3" , config = config )
310
290
data_bucket = s3 .Bucket (str (SIL_NLP_ENV .data_dir ).strip ("\\ /" ))
311
291
s3_setup = True
@@ -357,4 +337,14 @@ def get_env_path(name: str, default: str = ".") -> str:
357
337
return path
358
338
359
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
+
360
350
SIL_NLP_ENV = SilNlpEnv ()
0 commit comments