Page MenuHomeSoftware Heritage

backend: Add missing psycopg2.pool import

Authored by anlambert on Tue, Feb 4, 4:27 PM.



This fixes the following error when trying to launch the vault server using its CLI (used in docker-compose for instance):

swh-vault_1                     | Traceback (most recent call last):
swh-vault_1                     |   File "/srv/softwareheritage/venv/bin/swh", line 8, in <module>
swh-vault_1                     |     sys.exit(main())
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/core/cli/", line 111, in main
swh-vault_1                     |     return swh(auto_envvar_prefix='SWH')
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/click/", line 764, in __call__
swh-vault_1                     |     return self.main(*args, **kwargs)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/click/", line 717, in main
swh-vault_1                     |     rv = self.invoke(ctx)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/click/", line 1137, in invoke
swh-vault_1                     |     return _process_result(sub_ctx.command.invoke(sub_ctx))
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/click/", line 1137, in invoke
swh-vault_1                     |     return _process_result(sub_ctx.command.invoke(sub_ctx))
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/click/", line 956, in invoke
swh-vault_1                     |     return ctx.invoke(self.callback, **ctx.params)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/click/", line 555, in invoke
swh-vault_1                     |     return callback(*args, **kwargs)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/click/", line 17, in new_func
swh-vault_1                     |     return f(get_current_context(), *args, **kwargs)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/vault/", line 57, in serve
swh-vault_1                     |     app = make_app_from_configfile(config_file, debug=debug)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/vault/api/", line 235, in make_app_from_configfile
swh-vault_1                     |     vault = get_local_backend(cfg)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/vault/api/", line 224, in get_local_backend
swh-vault_1                     |     return get_vault('local', args)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/vault/", line 40, in get_vault
swh-vault_1                     |     return Vault(**args)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/vault/", line 83, in __init__
swh-vault_1                     |     self._pool = psycopg2.pool.ThreadedConnectionPool(
swh-vault_1                     | AttributeError: module 'psycopg2' has no attribute 'pool'
Test Plan

I tried to write a test for the vault cli but did not manage to reproduce the issue
as the psycopg2.pool module is already imported as a side effect of the swh modules
imported in

Diff Detail

rDVAU Software Heritage Vault
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert created this revision.Tue, Feb 4, 4:27 PM
vlorentz accepted this revision.Tue, Feb 4, 4:32 PM
This revision is now accepted and ready to land.Tue, Feb 4, 4:32 PM
This revision was automatically updated to reflect the committed changes.