pgvector / pgvector-python

pgvector support for Python
MIT License
886 stars 61 forks source link

examples seem to not work #49

Closed bionicles closed 8 months ago

bionicles commented 8 months ago

psycopg.errors.InsufficientPrivilege: permission denied to create extension "vector" ok, commented out, installed it manually, that didn't just work either note, if someone does this with sudo, could screw stuff up

raise psycopg.ProgrammingError('vector type not found in the database')

psycopg.ProgrammingError: vector type not found in the database uhhh, yes it does

can you please test your examples.

why does this happen when i run pytest in the base of your folder

~/hax/externals/pgvector/pgvector-python (master) $
> pytest
=============================================== test session starts ===============================================
platform linux -- Python 3.10.9, pytest-7.4.4, pluggy-1.0.0
rootdir: /home/bion/hax/externals/pgvector/pgvector-python
configfile: pytest.ini
plugins: order-1.2.0, dotenv-0.5.2, ordering-0.6, envfiles-0.1.0, asyncio-0.23.3, xdist-3.2.0, anyio-3.6.2, hypothesis-6.70.2
asyncio: mode=auto
collected 0 items
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/python.py", line 617, in _importtestmodule
INTERNALERROR>     mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/pathlib.py", line 567, in import_path
INTERNALERROR>     importlib.import_module(module_name)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/importlib/__init__.py", line 126, in import_module
INTERNALERROR>     return _bootstrap._gcd_import(name[level:], package, level)
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
INTERNALERROR>   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
INTERNALERROR>   File "/home/bion/hax/externals/pgvector/pgvector-python/pgvector/asyncpg/__init__.py", line 1, in <module>
INTERNALERROR>     from ..utils import from_db, from_db_binary, to_db, to_db_binary
INTERNALERROR> ImportError: attempted relative import beyond top-level package
INTERNALERROR>
INTERNALERROR> The above exception was the direct cause of the following exception:
INTERNALERROR>
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/main.py", line 271, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/main.py", line 324, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/main.py", line 335, in pytest_collection
INTERNALERROR>     session.perform_collect()
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/main.py", line 675, in perform_collect
INTERNALERROR>     self.items.extend(self.genitems(node))
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/main.py", line 842, in genitems
INTERNALERROR>     rep = collect_one_node(node)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/runner.py", line 546, in collect_one_node
INTERNALERROR>     ihook.pytest_collectstart(collector=collector)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/pytest_asyncio/plugin.py", line 626, in pytest_collectstart
INTERNALERROR>     pyobject = collector.obj
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/python.py", line 310, in obj
INTERNALERROR>     self._obj = obj = self._getobj()
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/python.py", line 528, in _getobj
INTERNALERROR>     return self._importtestmodule()
INTERNALERROR>   File "/home/bion/miniconda3/envs/py310/lib/python3.10/site-packages/_pytest/python.py", line 642, in _importtestmodule
INTERNALERROR>     raise self.CollectError(
INTERNALERROR> _pytest.nodes.Collector.CollectError: ImportError while importing test module '/home/bion/hax/externals/pgvector/pgvector-python/pgvector/asyncpg/__init__.py'.
INTERNALERROR> Hint: make sure your test modules/packages have valid Python names.
INTERNALERROR> Traceback:
INTERNALERROR> /home/bion/miniconda3/envs/py310/lib/python3.10/importlib/__init__.py:126: in import_module
INTERNALERROR>     return _bootstrap._gcd_import(name[level:], package, level)
INTERNALERROR> pgvector/asyncpg/__init__.py:1: in <module>
INTERNALERROR>     from ..utils import from_db, from_db_binary, to_db, to_db_binary
INTERNALERROR> E   ImportError: attempted relative import beyond top-level package

============================================== no tests ran in 0.02s ==============================================

if a special command is needed, where's make test?

bionicles commented 8 months ago

psycopg2 section of readme

cur = conn.cursor()

conn is undefined here at this point in your readme, so this code example will crash

ankane commented 8 months ago

Hi @bionicles, check out #16 for the vector type not found in the database error and the contributing section for how to run the tests.

The readme examples currently assume the database library is already set up (may revisit this in the future).

bionicles commented 8 months ago

Yeah, why would we want reproducible examples when we could just leave it all as an exercise for the reader