Skip to content

Commit

Permalink
Fix member selection (#46)
Browse files Browse the repository at this point in the history
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"`.
  • Loading branch information
AnnikaLau authored Sep 12, 2024
1 parent e42c7eb commit a96b5b4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions engine/select_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

# finds members and a corresponding tolerance factor validating for all stats files.
def find_members_and_factor_validating_for_all_stats_files(
random_tolerance_file_name,
stats_file_name,
member_type,
min_member_num,
Expand Down Expand Up @@ -66,7 +67,7 @@ def find_members_and_factor_validating_for_all_stats_files(
context.invoke(
tolerance,
stats_file_name=stats_file_name,
tolerance_file_name="random_tolerance.csv",
tolerance_file_name=random_tolerance_file_name,
member_num=random_members,
member_type=member_type,
)
Expand All @@ -76,7 +77,7 @@ def find_members_and_factor_validating_for_all_stats_files(
]
passed, new_vars = test_selection(
stats_file_name,
"random_tolerance.csv",
random_tolerance_file_name,
validation_members,
member_type,
f,
Expand Down Expand Up @@ -284,8 +285,10 @@ def select_members(
stats_file_name, tolerance_file_name, total_member_num, member_type, factor
)
else:
random_tolerance_file_name = f"random_tolerance_{experiment_name}.csv"
start_time = datetime.now()
selection, factor = find_members_and_factor_validating_for_all_stats_files(
random_tolerance_file_name,
stats_file_name,
member_type,
min_member_num,
Expand Down Expand Up @@ -313,4 +316,4 @@ def select_members(

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

0 comments on commit a96b5b4

Please sign in to comment.