Open lie112 opened 1 month ago
So what you're really asking is for apsim to not allow saving over certain files that have this flag set on them. Kind of like how if you open an example, it asks you to save it as a new file before it runs (and saves).
Yes, it's not exactly saving that is the problem, but preventing the Upgrade code from running and modifying the apsimx file from which there is no going back. Thus, not opening the simulation which requires the JSON to be upgraded to the latest software version. This does mean these 'locked' files cannot be viewed or edited in the UI without considerable changes (only showing the simulations model to access the lock and saving this back to the file accordingly), but an error would suffice reporting the latest version the file can be opened in, or instructions to remove the 'lock' from the apsimx file. Oh wait, when does the apsimxbak file get created? is that when an upgrade happens or just before any save?
The .bak file is created everytime the .apsimx file saved. Not helpful in your use case.
Would the simplest be to ask a yes/no question if a file is opened in the GUI and it needs to upgrade it? If you answer is no then the file isn't loaded.
If you want a file from the command line, then it will still be upgraded though.
Yes, that would suffice. It only happens when the system detects that an apsimx file needs to go through the upgrade code, and also highlights to the user that their file is about to be overwritten with no going back. This checkbox would avoid the situation I am preventing where a file used in an older version than the dev version should not be accidently upgraded, causing endless grief and hair pulling.
Describe the new feature
It would be useful to be able to lock an .apsimx file and not allow upgrades from the current version of the file. This would be an additional property to the Simulations model along with version (i.e. IsLocked = True). I have not been able to find this functionality in the current version. The benefit would be that simulation files provided with publications could be locked at the version that is used to generate the results, enforcing reproducibility of published, peer-reviewed results. It could also be used by developers working in different version space to protect files from being accidently, automatically upgraded when opened in a later version. This is important because the upgrade code is not reversible and old files can accidently be lost. The lock could easily be removed in a text or JSON editor, but there would be no way of unlocking the file in APSIM UI unless just the simulations model was included with the lock property to show what is going on.