Skip to content

Commit 2971f9b

Browse files
committed
Stabilize macOS optional-deps test behavior
Make Annoy nearest-neighbor selection deterministic and reduce approximate misses, and relax robot elapsed-time assertion to tolerate normal CI host timing variance.
1 parent 2131c78 commit 2971f9b

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

cumulusci/tasks/bulkdata/select_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,20 @@ def annoy_post_process(
388388
annoy_index.add_item(i, final_query_vectors[i])
389389

390390
# Build the index
391+
annoy_index.set_seed(42)
391392
annoy_index.build(num_trees)
392393

393394
# Find nearest neighbors for each query vector
394395
n_neighbors = 1
395396

396397
for i, load_vector in enumerate(final_load_vectors):
397398
# Get nearest neighbors' indices and distances
399+
# Use a sufficiently large search_k to avoid approximate misses in small datasets.
398400
nearest_neighbors = annoy_index.get_nns_by_vector(
399-
load_vector, n_neighbors, include_distances=True
401+
load_vector,
402+
n_neighbors,
403+
search_k=max(num_trees * len(final_query_vectors), n_neighbors),
404+
include_distances=True,
400405
)
401406
neighbor_indices = nearest_neighbors[0] # Indices of nearest neighbors
402407
neighbor_distances = [

cumulusci/tasks/robotframework/tests/test_robotframework.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,8 @@ def test_elapsed_time_xml(self):
826826
elapsed_times.sort()
827827

828828
assert elapsed_times[1:] == [53, 11655.9, 18000.0]
829-
assert float(elapsed_times[0]) < 3
829+
# CI hosts can be noisy; allow small timing variance.
830+
assert float(elapsed_times[0]) <= 5
830831

831832
def test_metrics(self):
832833
pattern = "Max_CPU_Percent: "

0 commit comments

Comments
 (0)