pgvector / pgvector-python

pgvector support for Python
MIT License
979 stars 63 forks source link

Add save to test #63

Closed ericholscher closed 8 months ago

ericholscher commented 8 months ago

This currently breaks for me, so ensure it isn't totally broken in the tests:

Test case:

>>> url = AnalyzedUrl.objects.filter(embedding__isnull=False).first()
>>> len(url.embedding)
384
>>> url.save()
Traceback (most recent call last):
  File "/usr/lib/python3.10/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/home/django/checkouts/ethical-ad-server/adserver/analyzer/models.py", line 64, in save
    self.full_clean()
  File "/home/django/lib/python3.10/site-packages/django/db/models/base.py", line 1470, in full_clean
    self.clean_fields(exclude=exclude)
  File "/home/django/lib/python3.10/site-packages/django/db/models/base.py", line 1519, in clean_fields
    if f.blank and raw_value in f.empty_values:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Model:

   embedding = VectorField(dimensions=384, default=None, null=True, blank=True)
ericholscher commented 8 months ago

Hrm, I thought tests might run in CI, but doesn't look like it. Will try and test it locally.

ankane commented 8 months ago

Hi @ericholscher, it looks like the tests are passing (CI logs). I'd make sure you're on the latest version. I tried adding blank=True and that didn't reproduce it either, but happy to revisit if you can create a test case that does.

ericholscher commented 8 months ago

Yea, I'm using the latest version -- I will try and see if I can get a better test case. It's just hard to get the full test setup running locally, so was hoping to piggyback on the CI config.

Will take another look at this.