Skip to content

New flaky test: test_text_query_word_weights #415

@abrookins

Description

@abrookins

Details:

=================================== FAILURES ===================================
_____________________ test_text_query_word_weights[TFIDF] ______________________
[gw0] linux -- Python 3.12.11 /home/runner/work/redis-vl-python/redis-vl-python/.venv/bin/python3

index = <redisvl.index.index.SearchIndex object at 0x7f2658e13500>
scorer = 'TFIDF'

    @pytest.mark.parametrize("scorer", ["BM25", "BM25STD", "TFIDF", "TFIDF.DOCNORM"])
    def test_text_query_word_weights(index, scorer):
        skip_if_redis_version_below(index.client, "7.2.0")
    
        text = "a medical professional with expertise in lung cancers"
        text_field = "description"
        return_fields = ["description"]
    
        weights = ***"medical": 3.4, "cancers": 5***
    
        # test we can run a query with text weights
        weighted_query = TextQuery(
            text=text,
            text_field_name=text_field,
            return_fields=return_fields,
            text_scorer=scorer,
            text_weights=weights,
        )
    
        weighted_results = index.query(weighted_query)
        assert len(weighted_results) == 4
    
        # test that weights do change the scores on results
        unweighted_query = TextQuery(
            text=text,
            text_field_name=text_field,
            return_fields=return_fields,
            text_scorer=scorer,
            text_weights=***,
        )
    
        unweighted_results = index.query(unweighted_query)
    
        for weighted, unweighted in zip(weighted_results, unweighted_results):
            for word in weights:
                if word in weighted["description"] or word in unweighted["description"]:
>                   assert weighted["score"] > unweighted["score"]
E                   assert 4.0 > 4.0

tests/integration/test_query.py:927: AssertionError
=============================== warnings summary ===============================
.venv/lib/python3.12/site-packages/testcontainers/core/waiting_utils.py:215
.venv/lib/python3.12/site-packages/testcontainers/core/waiting_utils.py:215
.venv/lib/python3.12/site-packages/testcontainers/core/waiting_utils.py:215
  /home/runner/work/redis-vl-python/redis-vl-python/.venv/lib/python3.12/site-packages/testcontainers/core/waiting_utils.py:215: DeprecationWarning: The @wait_container_is_ready decorator is deprecated and will be removed in a future version. Use structured wait strategies instead: container.waiting_for(HttpWaitStrategy(8080).for_status_code(200)) or container.waiting_for(LogMessageWaitStrategy('ready'))
    @wait_container_is_ready()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/integration/test_query.py::test_text_query_word_weights[TFIDF] - assert 4.0 > 4.0
====== 1 failed, 920 passed, 118 skipped, 3 warnings in 100.07s (0:01:40) ======
make: *** [Makefile:49: test] Error 1

-- https://github.com/redis/redis-vl-python/actions/runs/18857094802/job/53807786424?pr=408

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions