I had 460 FWs that were reserved in my launchpad but not actually reserved in slurm (from cancelling them in slurm without updating my launchpad).
Anyway, I thought doing detect_unreserved would throw out all my FWs that were marked reserved on launchpad but not in SLURM. So I did that, and defused those FWs. It turned out that for some reason this action decided to turn FWs that were successfully completed into DEFUSED mode (again, not sure why?).
So now I had a WF that had many FWs that were complete that are now DEFUSED.
Is there a way to make the last archived launch which was COMPLETED as the FW’s launches and mark the FW as COMPLETED as well? What is the best way to achieve this with minimal edits to the database?
Sorry for the late response; I imagine you’ve already worked around this by this point, but answering anyway.
detect_unreserved should really only detect RESERVED FireWorks. The only possible exception might be if you are using duplicate checking mode, and there is a copy of the same Firework (two FireWorks with the same spec) with one in COMPLETED and the other in RESERVED states.
detect_unreserved only has an option to rerun, not defuse. So I am not sure how anything was defused at all? Do you remember what command you ran that would case them to be defused?
Finally, if you do end up in the situation you described, there is no single command that would fix it. You’d have to write some code to repair the database similar to what you suggested. One tricky thing to watch out for is that if you manually update the state of a Firework in the fireworks collection, you should also update its state in the Workflows collection (fw_states); the latter is a duplication of data for speed purposes.