Skip to content

Commit 990775f

Browse files
Add force=true to preferences operations for robust handling
- Added force=true to all set_preferences\! and delete_preferences\! calls - This allows overwriting existing preferences and ensures clean deletion - Prevents conflicts when running autotune multiple times - Tested locally with full end-to-end functionality verification 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 8c354d0 commit 990775f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/LinearSolveAutotune/src/preferences.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ function set_algorithm_preferences(categories::Dict{String, String})
1111

1212
for (range, algorithm) in categories
1313
pref_key = "best_algorithm_$(replace(range, "+" => "plus", "-" => "_"))"
14-
# Set preferences in LinearSolve.jl, not LinearSolveAutotune
15-
Preferences.set_preferences!(LinearSolve, pref_key => algorithm)
14+
# Set preferences in LinearSolve.jl, not LinearSolveAutotune (force=true allows overwriting)
15+
Preferences.set_preferences!(LinearSolve, pref_key => algorithm; force = true)
1616
@info "Set preference $pref_key = $algorithm in LinearSolve.jl"
1717
end
1818

1919
# Set a timestamp for when these preferences were created
20-
Preferences.set_preferences!(LinearSolve, "autotune_timestamp" => string(Dates.now()))
20+
Preferences.set_preferences!(LinearSolve, "autotune_timestamp" => string(Dates.now()); force = true)
2121

2222
@info "Preferences updated in LinearSolve.jl. You may need to restart Julia for changes to take effect."
2323
end
@@ -58,11 +58,11 @@ function clear_algorithm_preferences()
5858

5959
for range in ranges
6060
pref_key = "best_algorithm_$range"
61-
# Delete preferences from LinearSolve.jl
62-
Preferences.delete_preferences!(LinearSolve, pref_key)
61+
# Delete preferences from LinearSolve.jl (force=true ensures deletion works)
62+
Preferences.delete_preferences!(LinearSolve, pref_key; force = true)
6363
end
6464

65-
Preferences.delete_preferences!(LinearSolve, "autotune_timestamp")
65+
Preferences.delete_preferences!(LinearSolve, "autotune_timestamp"; force = true)
6666

6767
@info "Preferences cleared from LinearSolve.jl."
6868
end

0 commit comments

Comments
 (0)