Page MenuHomeSoftware Heritage

backend: Add missing psycopg2.pool import
ClosedPublic

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

Details

Summary

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/__init__.py", 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/core.py", 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/core.py", line 717, in main
swh-vault_1                     |     rv = self.invoke(ctx)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/click/core.py", 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/core.py", 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/core.py", 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/core.py", line 555, in invoke
swh-vault_1                     |     return callback(*args, **kwargs)
swh-vault_1                     |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/click/decorators.py", 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/cli.py", 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/server.py", 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/server.py", 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/__init__.py", 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/backend.py", 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 conftest.py.

Diff Detail

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