Skip to content

Commit a96b5b4

Browse files
authored
Fix member selection (#46)
In case several member selections were run at the same time (as can happen on BB), all member selections were using the same name for the temporary file `"random_tolerances.csv"` leading to a race condition. This should be solved by changing the name of the file to `"random_tolerances_${experiment_name}.csv"`.
1 parent e42c7eb commit a96b5b4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

engine/select_members.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
# finds members and a corresponding tolerance factor validating for all stats files.
2626
def find_members_and_factor_validating_for_all_stats_files(
27+
random_tolerance_file_name,
2728
stats_file_name,
2829
member_type,
2930
min_member_num,
@@ -66,7 +67,7 @@ def find_members_and_factor_validating_for_all_stats_files(
6667
context.invoke(
6768
tolerance,
6869
stats_file_name=stats_file_name,
69-
tolerance_file_name="random_tolerance.csv",
70+
tolerance_file_name=random_tolerance_file_name,
7071
member_num=random_members,
7172
member_type=member_type,
7273
)
@@ -76,7 +77,7 @@ def find_members_and_factor_validating_for_all_stats_files(
7677
]
7778
passed, new_vars = test_selection(
7879
stats_file_name,
79-
"random_tolerance.csv",
80+
random_tolerance_file_name,
8081
validation_members,
8182
member_type,
8283
f,
@@ -284,8 +285,10 @@ def select_members(
284285
stats_file_name, tolerance_file_name, total_member_num, member_type, factor
285286
)
286287
else:
288+
random_tolerance_file_name = f"random_tolerance_{experiment_name}.csv"
287289
start_time = datetime.now()
288290
selection, factor = find_members_and_factor_validating_for_all_stats_files(
291+
random_tolerance_file_name,
289292
stats_file_name,
290293
member_type,
291294
min_member_num,
@@ -313,4 +316,4 @@ def select_members(
313316

314317
# The last created file was successful
315318
logger.info("Writing tolerance file to %s", tolerance_file_name)
316-
os.rename("random_tolerance.csv", tolerance_file_name)
319+
os.rename(random_tolerance_file_name, tolerance_file_name)

0 commit comments

Comments
 (0)