ADD: using existing DB with `verdi quicksetup`
The command verdi quicksetup represents the ideal way for new users to
set up their aiida profile, since AiiDA will directly use all the defaults without
prompting for the non-essential ones (which can then be overridden via the
command options if necessary). This is in contrast with the behavior of
verdi setup which prompts for a lot of options that new users may not
understand (even if defaults are provided).
The main limitation preventing it from being fully used this way was that
verdi quicksetup would always create new databases. Now an option
--create-db/--reuse-db was added to enable this.
TODOS
- [x] Add docs (explaining, for example, that if the DB is provided, it needs to be empty or otherwise it will except
- [x] If the database already exists and it was not specified to re-use it,
then it needs to except instead of creating one with
_N.
Behaviour
Starting new database easily
(base) jovyan@cff850c30c3d:~/work/aiida-core$ verdi quicksetup
Report: enter ? for help.
Report: enter ! to ignore the default and set no value.
Profile name [quicksetup]: profile_name
Email Address (for sharing data) [aiida@localhost]:
First name [Giuseppe]:
Last name [Verdi]:
Institution [Khedivial]:
Success: created new profile `profile_name`.
Report: initialising the profile storage.
Report: initialising empty storage schema
Report: Migrating to the head of the main branch
Success: storage initialisation completed.
Using an existing database
(base) jovyan@cff850c30c3d:~/work/aiida-core$ verdi quicksetup --reuse-db --db-name external_database --db-username aiida_dbuser
[same prompts/output]
Creating new database with specific name and user
(base) jovyan@cff850c30c3d:~/work/aiida-core$ verdi quicksetup --db-name new_database --db-username new_dbuser
[same prompts/output]
Thanks @ramirezfranciscof . My main question is that if this feature really targets new users, for whom supposedly verdi setup is too complex, would they really already have an existing database lying around? The whole idea of verdi quicksetup was that manually creating a database is not a trivial task and so the command does it for them. So assuming they already have a database seems to be contradicting this presupposition. So which users is this feature really targeting?
@sphuber people who have no admin access to the postgres service (we had a very recent case of someone who was in this situation, they had to make a request at their IT service so they would set up the DB for them)
Functionality finished and tests added.
I also documented the characteristics of the feature in the docstring of the options of the command, but there is no specific place in the general documentation where it describes the verdi quicksetup that needs to be adapted. If we now want to use it in some places instead of verdi setup (for example, move this section into the how-tos and just add in the Troubleshooting a subsection about reusing existing databases with quicksetup), that is a more drastic change of the docs that I think should be done in a separate commit.