I have a Julia script which does some calculations and in the end, the output is written to an Excel file using the following function:
function populate_spreadsheet(sol, instance_number, sheet_number, stat::Symbol)
XLSX.openxlsx("test.xlsx", mode = "rw") do xf
sheet = xf[sheet_number]
if stat == :obj
sheet[string("A", instance_number)] = sol.objective
elseif stat == :gap
sheet[string("B", instance_number)] = sol.gap
elseif stat == :time
sheet[string("C", instance_number)] = sol.solvetime
end
end
end
This works perfectly fine when I run a single instance of my script (say for instance_number=1
); however, I start to run into problems when I run multiple instances of the script at once. I am using an HPC cluster, and run an array of jobs using a slurm script. For example, I run an array of jobs for instance_number
1 to 40. The errors are not consistent. Two of the most common errors I get are unable to parse XML file
or AssertionError: Couldn't find xl/sharedStrings.xml
. I suspect it is because the independent jobs are trying to access and write to the file at once. Is there a way to overcome this problem? Any help is appreciated. Thanks!