Override code which are already setup and store in the database if needed

Me, @mbercx and @yakutovicha have a discussion about how to make it very easy to have a code setup if users just want to have a very similar code setup.

Use case 1: The user wrongly inputs some parameters during code setup and the code is stored, can the user override it, or it is better to just create and store a new one?

Use case 2: The user has a code and using this code runs a lot of calculations already when he wants to set up a new code that only has a small change from the initial one.

What we have now in the AiiDA are:

  1. verdi code delete to delete code by purging all the nodes it created to avoid dangling nodes in the DB.
  2. verdi code relable to relable a code into another label but keep code nodes unchanged.
  3. verdi code hide to “deactivate” a code by hiding it from verdi code list so user will not notice it.
  4. describe in verdi code setup should warn when setting up a code with existing label · Issue #3303 · aiidateam/aiida-core · GitHub and implemented in https://github.com/aiidateam/aiida-core/pull/5205 when the code set from verdi CLI has the same label, it is forbidden.

So creating a new code can be done in two steps, 1) deleting the wrong setup code, and the 2) setting a new one.
If the code is already used for some calculations, you can delete it as well by deleting the calculation nodes (if the code was wrongly set up, then it is fair to delete the calculation nodes from DB as well).
Therefore, for the UC1, it might be possible just combine delete and create to the override option, or when the new label is found for the new setup, it prompts and asks the user to confirm if he is sure to override it.

For UC2, it is trickier. Users may or may not change things for the original code node that is already in the DB. There are three options:

  1. as @ltalirz proposed in the issue verdi code setup should warn when setting up a code with existing label · Issue #3303 · aiidateam/aiida-core · GitHub but didn’t address by the PR when a new label is set, we could add a prompt
Choose a different label [Y/n]: 
  1. Aggressively make things of code overrideable, which has a risk to mess up the provenance but there is no “real” provenance in terms of code in most cases.
  2. relabel the old one with the deprecated as a suffix and create a new one as it is.

I personally am more on option 1 to mildly add a prompt if the code node exists and can not be deleted. If the user provides --override, it will run delete and create in sequence. If this option not provided, and a duplicate label is found, it will first prompt to ask if you gonna override with default as False, then second prompt to ask for a new name.

Need to mention that this is still only for creating new code from CLI, importing code from the archive is not a problem because the computer label will be attached with extra context and become something like localhost (Imported #0).

Also worth to mention that the verdi code setup is deprecated and replaced by verdi code create.

Another relevant issue in this context is Try and make Computer a mutable object by removing attributes that influence provenance · Issue #4980 · aiidateam/aiida-core (github.com)

It contains a very simple proposition to solve this problem: copy on edit.

1 Like