Skip to content

Commit 6ccef2c

Browse files
authored
Merge pull request #642 from sillsdev/#640_ssl_error
#640 ssl error
2 parents 8d4ea10 + 82f7342 commit 6ccef2c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

silnlp/common/environment.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def copy_pt_project_from_bucket(self, name: Union[str, Path], patterns: Union[st
174174
raise Exception(
175175
f"No paratext project name is given. Data still in the cache directory of {self.pt_projects_dir}"
176176
)
177-
config = Config(read_timeout=600)
177+
config = generate_s3_config()
178178
s3 = boto3.resource("s3", config=config)
179179
data_bucket = s3.Bucket(str(self.data_dir).strip("\\/"))
180180
len_silnlp_path = len(pt_projects_path)
@@ -208,7 +208,7 @@ def copy_experiment_from_bucket(self, name: Union[str, Path], patterns: Union[st
208208
raise Exception(
209209
f"No experiment name is given. Data still in the cache directory of {self.mt_experiments_dir}"
210210
)
211-
config = Config(read_timeout=600)
211+
config = generate_s3_config()
212212
s3 = boto3.resource("s3", config=config)
213213
data_bucket = s3.Bucket(str(self.data_dir).strip("\\/"))
214214
len_silnlp_path = len(experiments_path)
@@ -241,7 +241,7 @@ def copy_experiment_to_bucket(self, name: str, patterns: Union[str, Sequence[str
241241
f"No experiment name is given. Data still in the temp directory of {self.mt_experiments_dir}"
242242
)
243243
experiment_path = str(self.mt_dir.relative_to(self.data_dir) / "experiments") + "/"
244-
config = Config(read_timeout=600)
244+
config = generate_s3_config()
245245
s3 = boto3.resource("s3", config=config)
246246
data_bucket = s3.Bucket(str(self.data_dir).strip("\\/"))
247247
temp_folder = str(self.mt_experiments_dir / name)
@@ -285,7 +285,7 @@ def download_if_s3_paths(paths: Iterable[S3Path]) -> List[Path]:
285285
if not s3_setup:
286286
temp_root = Path(tempfile.TemporaryDirectory().name)
287287
temp_root.mkdir()
288-
config = Config(read_timeout=600)
288+
config = generate_s3_config()
289289
s3 = boto3.resource("s3", config=config)
290290
data_bucket = s3.Bucket(str(SIL_NLP_ENV.data_dir).strip("\\/"))
291291
s3_setup = True
@@ -337,4 +337,14 @@ def get_env_path(name: str, default: str = ".") -> str:
337337
return path
338338

339339

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+
340350
SIL_NLP_ENV = SilNlpEnv()

0 commit comments

Comments
 (0)