creating .apsimx files in parallel while all Config files and master .apsix files are on the same directory triggers System.IO.FileNotFoundException #31
System.Exception: An error occured trying to save a simulation to /agr/persist/projects/2024_apsim_improvements/apsim-simulations/ConfigFiles/19487_Ailsa_5a1.apsimx. System.IO.FileNotFoundException: Could not find file '/agr/persist/projects/2024_apsim_improvements/apsim-simulations/ConfigFiles/LargerExampletemp.apsimx.temp'.
File name: '/agr/persist/projects/2024_apsim_improvements/apsim-simulations/ConfigFiles/LargerExampletemp.apsimx.temp'
at System.IO.File.Move(String sourceFileName, String destFileName, Boolean overwrite)
at Models.Core.Simulations.Write(String currentFileName, String savePath) in /tmp/ApsimX/Models/Core/Simulations.cs:line 187
at Models.Core.Simulations.Write(String currentFileName, String savePath) in /tmp/ApsimX/Models/Core/Simulations.cs:line 193
at Models.Program.ExecuteCommands(Options options, String configFileDirectory, List`1 commandsList, ApplyRunManager& applyRunManager, DataRow row) in /tmp/ApsimX/Models/Main.cs:line 400
at Models.Program.DoCommands(Options options, String[] files, String configFileDirectory, List`1 commandsList) in /tmp/ApsimX/Models/Main.cs:line 313
at Models.Program.Run(Options options) in /tmp/ApsimX/Models/Main.cs:line 175
Reason:
We believe this is due to Models --apply command creates a temporary file to one of the master .apsimx files ( LargerExample.apsimx). If we are to host all of the config files in the same directory and run Models --apply to each one of them in parallel, we can not control the rate of of ...temp.apsimx.temp file being generated and deleted. Hence, we do get multiple failures in an array.
Solution
If there is no time constraint, recommendation is to run the Models --apply command as a serial process. It take ~25 seconds to process a single Config.txt file and generate the corresponding .apsimx file alongside the .db placeholder file
Otherwise, split the config files to multiple directories ( split to smaller groups) and process each group serially.
If we to explore this option, remember to copy all of the required .met files and the master .apsimx files to each directory
For an example
Reason:
Models --apply
command creates a temporary file to one of the master .apsimx files (LargerExample.apsimx
). If we are to host all of the config files in the same directory and runModels --apply
to each one of them in parallel, we can not control the rate of of...temp.apsimx.temp
file being generated and deleted. Hence, we do get multiple failures in an array.Solution
Models --apply
command as a serial process. It take ~25 seconds to process a single Config.txt file and generate the corresponding .apsimx file alongside the .db placeholder file