Skip to content

Commit

Permalink
fix: catch exceptions in windows CI runner related to file removal (f…
Browse files Browse the repository at this point in the history
…or files that may still be in use)
  • Loading branch information
Stefan Strömer committed Nov 20, 2024
1 parent 3275025 commit 304f87a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/IESopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,13 @@ function _optimize!(model::JuMP.Model; @nospecialize(kwargs...))
lcsn = lowercase(JuMP.solver_name(model))
scenario_name = @config(model, general.name.scenario)
log_file = abspath(@config(model, paths.results), "$(scenario_name).$(lcsn).log")
rm(log_file; force=true)

try
rm(log_file; force=true)
catch
@warn "Failed to cleanup solver log file; maybe it appends, maybe it overwrites, maybe it fails - we do not know" log_file
end

if JuMP.solver_name(model) == "Gurobi"
@info "Logging solver output" log_file
JuMP.set_attribute(model, "LogFile", log_file)
Expand Down
9 changes: 7 additions & 2 deletions src/precompile/precompile_tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@
)
end

# Clean up output files after testing is done.
rm(normpath(__dir, "out"); force=true, recursive=true)
try
# Clean up output files after testing is done.
rm(normpath(__dir, "out"); force=true, recursive=true)
catch
@warn "Failed to cleanup output files after precompilation, left-overs might be present" path =
normpath(__dir, "out")
end
end

precompile(_attach_optimizer, (JuMP.Model,))

0 comments on commit 304f87a

Please sign in to comment.