aiidateam / aiida-core

The official repository for the AiiDA code
https://aiida-core.readthedocs.io
Other
431 stars 187 forks source link

`verdi computer delete` should allow user to delete computers with associated nodes #5395

Closed ltalirz closed 5 months ago

ltalirz commented 2 years ago

Currently, trying to verdi computer delete a computer on which calculations have run results in an error like

Message: '\x1b[22mUnable to delete the requested computer: it is possible that there is at least one node using this computer (original message: (psycopg2.errors.NotNullViolation) null value in column "dbcomputer_id" violates not-null constraint\nDETAIL:  Failing row contains (1, 1, null, {}, {"safe_interval": 0.0, "use_login_shell": true}, t).\n\n[SQL: UPDATE db_dbauthinfo SET dbcomputer_id=%(dbcomputer_id)s WHERE db_dbauthinfo.id = %(db_dbauthinfo_id)s]\n[parameters: {\'dbcomputer_id\': None, \'db_dbauthinfo_id\': 1}]\n(Background on this error at: https://sqlalche.me/e/14/gkpj))\x1b[0m'
Arguments: ()

A user who wants to delete this computer then has to figure out how to manually delete the nodes on this computer before they can delete the computer itself.

We should simplify this: verdi computer delete should allow users - with an extra prompt - to delete a computer and all nodes associated it (just as verdi node delete deletes nodes connected via the provenance).

ltalirz commented 2 years ago

Just ran into this issue again...

khsrali commented 6 months ago

@sphuber do you agree with this? I think it makes sense to do something like verdi computer delete --force to kill & delete running nodes. This is again one of those features that could help new users to play around and if something went wrong, easily purge everything..

sphuber commented 6 months ago

Sure, I think it makes sense to add this. I would propose the following:

  1. Add a check in the command whether the computer has any associated nodes.
  2. If it does, prompt the user to confirm they also want to delete all those nodes (include the number of nodes that would be deleted in the message)
  3. If confirmed, delete the nodes first, and then delete the computer
  4. Add a --force flag to bypass the confirmation