Skip to content

Commit

Permalink
Merge branch 'develop' into fix_sacess_logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Aug 24, 2023
2 parents f89ade7 + 09bfa4c commit ecce49d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pypesto/optimize/ess/sacess.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,17 @@ def _create_result(self, problem: Problem) -> pypesto.Result:
tmp_result_filename = SacessWorker.get_temp_result_filename(
worker_idx
)
tmp_result = read_result(
tmp_result_filename, problem=False, optimize=True
)
os.remove(tmp_result_filename)
try:
tmp_result = read_result(
tmp_result_filename, problem=False, optimize=True
)
except FileNotFoundError:
# wait and retry, maybe the file wasn't found due to some filesystem latency issues
time.sleep(5)
tmp_result = read_result(
tmp_result_filename, problem=False, optimize=True
)

if result is None:
result = tmp_result
else:
Expand All @@ -201,6 +208,13 @@ def _create_result(self, problem: Problem) -> pypesto.Result:
sort=False,
prefix=f"{worker_idx}-",
)

# delete temporary files only after successful consolidation
for filename in map(
SacessWorker.get_temp_result_filename, range(self.num_workers)
):
os.remove(filename)

result.optimize_result.sort()

result.problem = problem
Expand Down

0 comments on commit ecce49d

Please sign in to comment.