Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove-np-ninf #782

Merged
merged 2 commits into from
Sep 24, 2024
Merged

Remove-np-ninf #782

merged 2 commits into from
Sep 24, 2024

Conversation

icfly2
Copy link
Contributor

@icfly2 icfly2 commented Sep 19, 2024

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you installed pre-commit with pip3 install pre-commit and set up hooks with pre-commit install?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Numpy 2 dropped support for the np.INF and NINF and instead it recomends np.inf and - np.inf

WIP: I'm still looking for the contribution guide, inparticular the how to run the tests locally bit, as I'm not familiar with poetry. Tests pass in the runners but I'm pretty sure the current test suite doesn't cover the changed code.

Copy link

netlify bot commented Sep 19, 2024

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 66e9cba
🔍 Latest deploy log https://app.netlify.com/sites/poetic-froyo-8baba7/deploys/66f30dcef9de1b00088f6ac5
😎 Deploy Preview https://deploy-preview-782--poetic-froyo-8baba7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@icfly2
Copy link
Contributor Author

icfly2 commented Sep 23, 2024

I can show that if you upgrade numpy to 2.x it fails the current test suite, but with the change, the client doesn't fail the tests. This requires the client without fastembed, as that is pinned to below 2 for numpy:


qdrant-client on  dev is 📦 v1.11.2 via 🐍 v3.10.13 
❯ poetry run pytest -x
============================== test session starts ==============================
platform linux -- Python 3.12.3, pytest-7.4.4, pluggy-1.5.0
rootdir: /home/rum/qdrant-client
configfile: pyproject.toml
plugins: asyncio-0.21.2, anyio-4.4.0, timeout-2.3.1
asyncio: mode=Mode.STRICT
collected 370 items                                                             

qdrant_client/hybrid/test_reranking.py .                                  [  0%]
qdrant_client/local/tests/test_datetimes.py ..................            [  5%]
qdrant_client/local/tests/test_distances.py .                             [  5%]
qdrant_client/local/tests/test_payload_filters.py ..                      [  5%]
qdrant_client/local/tests/test_payload_utils.py ...                       [  6%]
qdrant_client/local/tests/test_referenced_vectors.py .................... [ 12%]
..........                                                                [ 14%]
qdrant_client/local/tests/test_vectors.py .                               [ 15%]
tests/test_async_qdrant_client.py .....                                   [ 16%]
tests/test_fastembed.py .ssssss                                           [ 18%]
tests/test_in_memory.py .F

=================================== FAILURES ====================================
_______________ test_sparse_in_memory_key_filter_returns_results ________________

qdrant = <qdrant_client.qdrant_client.QdrantClient object at 0x7f58e905e8d0>

    def test_sparse_in_memory_key_filter_returns_results(qdrant: QdrantClient):
        qdrant.create_collection(
            collection_name="test_collection",
            vectors_config={},
            sparse_vectors_config={"text": models.SparseVectorParams()},
        )
    
        operation_info = qdrant.upsert(
            collection_name="test_collection",
            wait=True,
            points=[
                models.PointStruct(
                    id=1,
                    vector={
                        "text": models.SparseVector(
                            indices=[0, 1, 2, 3], values=[0.05, 0.61, 0.76, 0.74]
                        )
                    },
                    payload={"city": "Berlin"},
                ),
                models.PointStruct(
                    id=2,
                    vector={
                        "text": models.SparseVector(
                            indices=[0, 1, 2, 3], values=[0.19, 0.81, 0.75, 0.11]
                        )
                    },
                    payload={"city": ["Berlin", "London"]},
                ),
                models.PointStruct(
                    id=3,
                    vector={
                        "text": models.SparseVector(
                            indices=[0, 1, 2, 3], values=[0.36, 0.55, 0.47, 0.94]
                        )
                    },
                    payload={"city": ["Berlin", "Moscow"]},
                ),
                models.PointStruct(
                    id=4,
                    vector={
                        "text": models.SparseVector(
                            indices=[0, 1, 2, 3], values=[0.18, 0.01, 0.85, 0.80]
                        )
                    },
                    payload={"city": ["London", "Moscow"]},
                ),
            ],
        )
    
        assert operation_info.operation_id == 0
        assert operation_info.status == models.UpdateStatus.COMPLETED
    
>       search_result = qdrant.search(
            collection_name="test_collection",
            query_vector=models.NamedSparseVector(
                name="text",
                vector=models.SparseVector(indices=[0, 1, 2, 3], values=[0.2, 0.1, 0.9, 0.7]),
            ),
            query_filter=models.Filter(
                must=[models.FieldCondition(key="city", match=models.MatchValue(value="London"))]
            ),
            limit=3,
        )

tests/test_in_memory.py:110: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
qdrant_client/qdrant_client.py:387: in search
    return self._client.search(
qdrant_client/local/qdrant_local.py:204: in search
    return collection.search(
qdrant_client/local/local_collection.py:618: in search
    if sparse_scoring and score == np.NINF:

@icfly2 icfly2 marked this pull request as ready for review September 23, 2024 13:15
@joein
Copy link
Member

joein commented Sep 24, 2024

Thank you for addressing this

@joein joein self-requested a review September 24, 2024 19:07
@joein joein merged commit 52d9697 into qdrant:dev Sep 24, 2024
8 of 9 checks passed
joein added a commit that referenced this pull request Sep 24, 2024
* change np.NINF to -np.inf

* Update qdrant_client/local/local_collection.py

---------

Co-authored-by: George <panchuk.george@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants