Skip to content

Commit 8dd0948

Browse files
authored
Deprecate in verdi quicksetup the --db-engine option (#6906)
The `--db-engine` option only supports `postgresql_psycopg`. To avoid failure due the deprecation of `postgresql_psycopg2` (note that unintuitively `postgresql_psycopg` is the newer version) we add the support in the click options and echo a deprecation warning that the option does not have any effect. This change does not have any effect on the actual DB engine being used as it is hardcoded. Fixes renaming of `database` to `dbname` missed in #6362 that raised deprecation warning.
1 parent 88df72a commit 8dd0948

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

docs/source/reference/command_line.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ Below is a list with all available subcommands.
430430
--first-name NONEMPTYSTRING First name of the user. [required]
431431
--last-name NONEMPTYSTRING Last name of the user. [required]
432432
--institution NONEMPTYSTRING Institution of the user. [required]
433-
--db-engine [postgresql_psycopg]
434-
Engine to use to connect to the database. [required]
433+
--db-engine [postgresql_psycopg|postgresql_psycopg2]
434+
Engine to use to connect to the database. (deprecated)
435435
--db-backend [core.psql_dos] Database backend to use. [required]
436436
--db-host HOSTNAME Database server host. Leave empty for "peer"
437437
authentication. [required]
@@ -537,8 +537,8 @@ Below is a list with all available subcommands.
537537
--first-name NONEMPTYSTRING First name of the user. [required]
538538
--last-name NONEMPTYSTRING Last name of the user. [required]
539539
--institution NONEMPTYSTRING Institution of the user. [required]
540-
--db-engine [postgresql_psycopg]
541-
Engine to use to connect to the database. [required]
540+
--db-engine [postgresql_psycopg|postgresql_psycopg2]
541+
Engine to use to connect to the database. (deprecated)
542542
--db-backend [core.psql_dos] Database backend to use. [required]
543543
--db-host HOSTNAME Database server host. Leave empty for "peer"
544544
authentication. [required]

src/aiida/cmdline/commands/cmd_setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ def setup(
8181
if profile_uuid is not None:
8282
profile.uuid = profile_uuid
8383

84+
if non_interactive and db_engine != 'postgresql_psycopg':
85+
echo.echo_deprecated('The `--db-engine` option is deprecated and has no effect.')
86+
8487
profile.set_storage(
8588
db_backend,
8689
{
@@ -205,12 +208,15 @@ def quicksetup(
205208
# store default user settings so user does not have to re-enter them
206209
_store_default_user_settings(ctx.obj.config, email, first_name, last_name, institution)
207210

211+
if non_interactive and db_engine != 'postgresql_psycopg':
212+
echo.echo_deprecated('The `--db-engine` option is deprecated and has no effect.')
213+
208214
dbinfo_su = {
209215
'host': db_host,
210216
'port': db_port,
211217
'user': su_db_username,
212218
'password': su_db_password,
213-
'database': su_db_name,
219+
'dbname': su_db_name,
214220
}
215221
postgres = Postgres(interactive=not non_interactive, quiet=False, dbinfo=dbinfo_su)
216222

src/aiida/cmdline/params/options/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,10 @@ def set_log_level(ctx, _param, value):
397397

398398
DB_ENGINE = OverridableOption(
399399
'--db-engine',
400-
required=True,
401-
help='Engine to use to connect to the database.',
400+
required=False,
401+
help='Engine to use to connect to the database. (deprecated)',
402402
default='postgresql_psycopg',
403-
type=click.Choice(['postgresql_psycopg']),
403+
type=click.Choice(['postgresql_psycopg', 'postgresql_psycopg2']),
404404
)
405405

406406
DB_BACKEND = OverridableOption(

0 commit comments

Comments
 (0)