Page MenuHomeSoftware Heritage

Naive attempt to add support for dsn url config style for production db
ClosedPublic

Authored by douardda on Sep 24 2021, 12:03 PM.

Details

Summary

This should allow to write your config file like:

web.yaml:

production_db:
  name: postgresql:///?service=swh-web

thus allowing to use pg_services and pgpass to declare postgresl access
configuration.

Might help for containerized execution environment where db
configuration can be dynamic.

Depends on D6335

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

No idea how to actually test this (besides in swh-env/docker I mean)

Build is green

Patch application report for D6336 (id=23041)

Could not rebase; Attempt merge onto 3c78440d47...

Updating 3c78440d..759c38f8
Fast-forward
 README.md                      | 149 ++++++++++++++++++++++++++++++-----------
 mypy.ini                       |   3 +
 swh/web/settings/production.py |  13 ++++
 3 files changed, 127 insertions(+), 38 deletions(-)
Changes applied before test
commit 759c38f8f113166b602082f8cde74c79074ebc7d
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Sep 23 18:00:07 2021 +0200

    Naive attempt to add support for dsn url config style for production db
    
    This should allow to write your config file like:
    
    web.yaml:
    
      production_db:
        name: postgresql:///?service=swh-web
    
    thus allowing to use pg_services and pgpass to declare postgresl access
    configuration.
    
    Might help for containerized execution environment where db
    configuration can be dynamic.

commit 15b0e84456ae174f934e7a3bea099a6a03e56654
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Sep 23 18:04:11 2021 +0200

    Wrap long lines in the README file

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1121/ for more details.

ardumont added inline comments.
mypy.ini
40 ↗(On Diff #23041)

Add types-psycopg2 dependency requirements to requirements-test.txt instead.
That's how we deal with it in other swh packages now.

swh/web/settings/production.py
42–45

?

ardumont added a subscriber: anlambert.

Yes, thanks. I agree it would simplify setup in container solutions.

Couple of suggestions inline.

@anlambert What do you think?

This revision is now accepted and ready to land.Sep 24 2021, 1:59 PM
mypy.ini
40 ↗(On Diff #23041)

indeed!

swh/web/settings/production.py
42–45

ah yes, reamainings of former stuff, thx

swh/web/settings/production.py
42–45

Note that there will be an extra dbname key in db_conf (but hopefully, it's fine, well ignored downstream).

swh/web/settings/production.py
42–45

Actually no, that was a former implementation, but since only those keys are used (in the DATABASES setup below) I prefer keeping it explicit.

swh/web/settings/production.py
42–45

fine with me ;)

use types-psycopg2 instead of ignore it in mymy.ini

Build is green

Patch application report for D6336 (id=23054)

Could not rebase; Attempt merge onto 3c78440d47...

Updating 3c78440d..dd6dde3e
Fast-forward
 README.md                      | 149 ++++++++++++++++++++++++++++++-----------
 requirements-test.txt          |   1 +
 swh/web/settings/production.py |  13 ++++
 3 files changed, 125 insertions(+), 38 deletions(-)
Changes applied before test
commit dd6dde3e44cd245e1c63260aa2ec767520f1c238
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Sep 23 18:00:07 2021 +0200

    Naive attempt to add support for dsn url config style for production db
    
    This should allow to write your config file like:
    
    web.yaml:
    
      production_db:
        name: postgresql:///?service=swh-web
    
    thus allowing to use pg_services and pgpass to declare postgresl access
    configuration.
    
    Might help for containerized execution environment where db
    configuration can be dynamic.

commit 15b0e84456ae174f934e7a3bea099a6a03e56654
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Sep 23 18:04:11 2021 +0200

    Wrap long lines in the README file

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1122/ for more details.