Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SacessOptimizer: retry reading, delay deleting #1110

Merged
merged 4 commits into from
Aug 24, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions pypesto/optimize/ess/sacess.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,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(10)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10s might be too long? Shouldn't any latency issues be resolved within fractions of a second?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, depends on the latency 😅
I can also change it to 5s, although I don't think it's really an issue.
Ideally, this will never trigger, but if it does it means we had some latency issue and we are happy to have waited 10s instead of failed. If the file doesn't exist at all, then we will waste a couple of seconds, but if that happens, anyways something went severely wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

tmp_result = read_result(
tmp_result_filename, problem=False, optimize=True
)

if result is None:
result = tmp_result
else:
Expand All @@ -185,6 +192,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