Skip to content

Commit 3d23d9e

Browse files
authored
Merge branch 'master' into anyio
2 parents 2c91e81 + 0d28291 commit 3d23d9e

29 files changed

+2085
-520
lines changed

.github/actions/run-tests/action.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
description: 'hiredis version to test against'
1515
required: false
1616
default: '>3.0.0'
17+
hiredis-branch:
18+
description: 'hiredis branch to test against'
19+
required: false
20+
default: 'master'
1721
event-loop:
1822
description: 'Event loop to use'
1923
required: false
@@ -28,6 +32,14 @@ runs:
2832
python-version: ${{ inputs.python-version }}
2933
cache: 'pip'
3034

35+
- uses: actions/checkout@v4
36+
if: ${{ inputs.parser-backend == 'hiredis' && inputs.hiredis-version == 'unstable' }}
37+
with:
38+
repository: redis/hiredis-py
39+
submodules: true
40+
path: hiredis-py
41+
ref: ${{ inputs.hiredis-branch }}
42+
3143
- name: Setup Test environment
3244
env:
3345
REDIS_VERSION: ${{ inputs.redis-version }}
@@ -40,15 +52,21 @@ runs:
4052
pip uninstall -y redis # uninstall Redis package installed via redis-entraid
4153
pip install -e .[jwt] # install the working copy
4254
if [ "${{inputs.parser-backend}}" == "hiredis" ]; then
43-
pip install "hiredis${{inputs.hiredis-version}}"
44-
echo "PARSER_BACKEND=$(echo "${{inputs.parser-backend}}_${{inputs.hiredis-version}}" | sed 's/[^a-zA-Z0-9]/_/g')" >> $GITHUB_ENV
55+
if [[ "${{inputs.hiredis-version}}" == "unstable" ]]; then
56+
echo "Installing unstable version of hiredis from local directory"
57+
pip install -e ./hiredis-py
58+
else
59+
pip install "hiredis${{inputs.hiredis-version}}"
60+
fi
61+
echo "PARSER_BACKEND=$(echo "${{inputs.parser-backend}}_${{inputs.hiredis-version}}" | sed 's/[^a-zA-Z0-9]/_/g')" >> $GITHUB_ENV
4562
else
4663
echo "PARSER_BACKEND=${{inputs.parser-backend}}" >> $GITHUB_ENV
4764
fi
4865
echo "::endgroup::"
4966
5067
echo "::group::Starting Redis servers"
5168
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
69+
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
5270
5371
if (( redis_major_version < 8 )); then
5472
echo "Using redis-stack for module tests"
@@ -70,8 +88,7 @@ runs:
7088
7189
if (( redis_major_version < 7 )); then
7290
export REDIS_STACK_EXTRA_ARGS="--tls-auth-clients optional --save ''"
73-
export REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"
74-
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
91+
export REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"
7592
fi
7693
7794
invoke devenv --endpoints=all-stack
@@ -108,12 +125,10 @@ runs:
108125
fi
109126

110127
echo "::endgroup::"
111-
112-
if [ "$protocol" == "2" ] || [ "${{inputs.parser-backend}}" != 'hiredis' ]; then
113-
echo "::group::RESP${protocol} cluster tests"
114-
invoke cluster-tests $eventloop --protocol=${protocol}
115-
echo "::endgroup::"
116-
fi
128+
129+
echo "::group::RESP${protocol} cluster tests"
130+
invoke cluster-tests $eventloop --protocol=${protocol}
131+
echo "::endgroup::"
117132
}
118133

119134
run_tests 2 "${{inputs.event-loop}}"

.github/wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ APM
22
ARGV
33
BFCommands
44
CacheImpl
5+
CAS
56
CFCommands
67
CMSCommands
78
ClusterNode
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Hiredis-py integration tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
redis-py-branch:
7+
description: 'redis-py branch to run tests on'
8+
required: true
9+
default: 'master'
10+
hiredis-branch:
11+
description: 'hiredis-py branch to run tests on'
12+
required: true
13+
default: 'master'
14+
15+
concurrency:
16+
group: ${{ github.event.pull_request.number || github.ref }}-hiredis-integration
17+
cancel-in-progress: true
18+
19+
permissions:
20+
contents: read # to fetch code (actions/checkout)
21+
22+
env:
23+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
24+
# this speeds up coverage with Python 3.12: https://github.com/nedbat/coveragepy/issues/1665
25+
COVERAGE_CORE: sysmon
26+
CURRENT_CLIENT_LIBS_TEST_STACK_IMAGE_TAG: 'rs-7.4.0-v2'
27+
CURRENT_REDIS_VERSION: '7.4.2'
28+
29+
jobs:
30+
redis_version:
31+
runs-on: ubuntu-latest
32+
outputs:
33+
CURRENT: ${{ env.CURRENT_REDIS_VERSION }}
34+
steps:
35+
- name: Compute outputs
36+
run: |
37+
echo "CURRENT=${{ env.CURRENT_REDIS_VERSION }}" >> $GITHUB_OUTPUT
38+
39+
hiredis-tests:
40+
runs-on: ubuntu-latest
41+
needs: [redis_version]
42+
timeout-minutes: 60
43+
strategy:
44+
max-parallel: 15
45+
fail-fast: false
46+
matrix:
47+
redis-version: [ '${{ needs.redis_version.outputs.CURRENT }}' ]
48+
python-version: [ '3.8', '3.13']
49+
parser-backend: [ 'hiredis' ]
50+
hiredis-version: [ 'unstable' ]
51+
event-loop: [ 'asyncio' ]
52+
env:
53+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
54+
name: Redis ${{ matrix.redis-version }}; Python ${{ matrix.python-version }}; RESP Parser:${{matrix.parser-backend}} (${{ matrix.hiredis-version }}); EL:${{matrix.event-loop}}
55+
steps:
56+
- uses: actions/checkout@v4
57+
with:
58+
ref: ${{ inputs.redis-py-branch }}
59+
- name: Run tests
60+
uses: ./.github/actions/run-tests
61+
with:
62+
python-version: ${{ matrix.python-version }}
63+
parser-backend: ${{ matrix.parser-backend }}
64+
redis-version: ${{ matrix.redis-version }}
65+
hiredis-version: ${{ matrix.hiredis-version }}
66+
hiredis-branch: ${{ inputs.hiredis-branch }}

.github/workflows/integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
max-parallel: 15
7575
fail-fast: false
7676
matrix:
77-
redis-version: ['8.0-RC2-pre', '${{ needs.redis_version.outputs.CURRENT }}', '7.2.7', '6.2.17']
77+
redis-version: ['8.0.1-pre', '${{ needs.redis_version.outputs.CURRENT }}', '7.2.7', '6.2.17']
7878
python-version: ['3.8', '3.13']
7979
parser-backend: ['plain']
8080
event-loop: ['asyncio']

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ vagrant/.vagrant
99
.cache
1010
.eggs
1111
.idea
12+
.vscode
1213
.coverage
1314
env
1415
venv

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* Add AnyIO based async client (and by extension, add support for Trio)
2+
* Support transactions in ClusterPipeline
23
* Removing support for RedisGraph module. RedisGraph support is deprecated since Redis Stack 7.2 (https://redis.com/blog/redisgraph-eol/)
34
* Fix lock.extend() typedef to accept float TTL extension
45
* Update URL in the readme linking to Redis University
@@ -71,6 +72,8 @@
7172
* Close Unix sockets if the connection attempt fails. This prevents `ResourceWarning`s. (#3314)
7273
* Close SSL sockets if the connection attempt fails, or if validations fail. (#3317)
7374
* Eliminate mutable default arguments in the `redis.commands.core.Script` class. (#3332)
75+
* Fix SSL verification with `ssl_cert_reqs="none"` and `ssl_check_hostname=True` by automatically setting `check_hostname=False` when `verify_mode=ssl.CERT_NONE` (#3635)
76+
* Allow newer versions of PyJWT as dependency. (#3630)
7477

7578
* 4.1.3 (Feb 8, 2022)
7679
* Fix flushdb and flushall (#1926)
@@ -1147,3 +1150,4 @@ incompatible in code using*SCAN commands loops such as
11471150
* Implemented STRLEN
11481151
* Implemented PERSIST
11491152
* Implemented SETRANGE
1153+
* Changed type annotation of the `num` parameter in `zrange` from `int` to `Optional[int]

README.md

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ The Python interface to the Redis key-value store.
3131

3232
## Installation
3333

34-
Start a redis via docker:
34+
Start a redis via docker (for Redis versions >= 8.0):
3535

3636
``` bash
37-
docker run -p 6379:6379 -it redis/redis-stack:latest
37+
docker run -p 6379:6379 -it redis:latest
3838
```
3939

40+
Start a redis via docker (for Redis versions < 8.0):
41+
42+
``` bash
43+
docker run -p 6379:6379 -it redis/redis-stack:latest
44+
4045
To install redis-py, simply:
4146

4247
``` bash
@@ -54,15 +59,16 @@ Looking for a high-level library to handle object mapping? See [redis-om-python]
5459

5560
## Supported Redis Versions
5661

57-
The most recent version of this library supports redis version [5.0](https://github.com/redis/redis/blob/5.0/00-RELEASENOTES), [6.0](https://github.com/redis/redis/blob/6.0/00-RELEASENOTES), [6.2](https://github.com/redis/redis/blob/6.2/00-RELEASENOTES), [7.0](https://github.com/redis/redis/blob/7.0/00-RELEASENOTES), [7.2](https://github.com/redis/redis/blob/7.2/00-RELEASENOTES) and [7.4](https://github.com/redis/redis/blob/7.4/00-RELEASENOTES).
62+
The most recent version of this library supports Redis version [7.2](https://github.com/redis/redis/blob/7.2/00-RELEASENOTES), [7.4](https://github.com/redis/redis/blob/7.4/00-RELEASENOTES) and [8.0](https://github.com/redis/redis/blob/8.0/00-RELEASENOTES).
5863

5964
The table below highlights version compatibility of the most-recent library versions and redis versions.
6065

6166
| Library version | Supported redis versions |
6267
|-----------------|-------------------|
6368
| 3.5.3 | <= 6.2 Family of releases |
6469
| >= 4.5.0 | Version 5.0 to 7.0 |
65-
| >= 5.0.0 | Version 5.0 to current |
70+
| >= 5.0.0 | Version 5.0 to 7.4 |
71+
| >= 6.0.0 | Version 7.2 to current |
6672

6773

6874
## Usage
@@ -152,8 +158,42 @@ The following example shows how to utilize [Redis Pub/Sub](https://redis.io/docs
152158
{'pattern': None, 'type': 'subscribe', 'channel': b'my-second-channel', 'data': 1}
153159
```
154160

161+
### Redis’ search and query capabilities default dialect
162+
163+
Release 6.0.0 introduces a client-side default dialect for Redis’ search and query capabilities.
164+
By default, the client now overrides the server-side dialect with version 2, automatically appending *DIALECT 2* to commands like *FT.AGGREGATE* and *FT.SEARCH*.
155165

156-
--------------------------
166+
**Important**: Be aware that the query dialect may impact the results returned. If needed, you can revert to a different dialect version by configuring the client accordingly.
167+
168+
``` python
169+
>>> from redis.commands.search.field import TextField
170+
>>> from redis.commands.search.query import Query
171+
>>> from redis.commands.search.index_definition import IndexDefinition
172+
>>> import redis
173+
174+
>>> r = redis.Redis(host='localhost', port=6379, db=0)
175+
>>> r.ft().create_index(
176+
>>> (TextField("name"), TextField("lastname")),
177+
>>> definition=IndexDefinition(prefix=["test:"]),
178+
>>> )
179+
180+
>>> r.hset("test:1", "name", "James")
181+
>>> r.hset("test:1", "lastname", "Brown")
182+
183+
>>> # Query with default DIALECT 2
184+
>>> query = "@name: James Brown"
185+
>>> q = Query(query)
186+
>>> res = r.ft().search(q)
187+
188+
>>> # Query with explicit DIALECT 1
189+
>>> query = "@name: James Brown"
190+
>>> q = Query(query).dialect(1)
191+
>>> res = r.ft().search(q)
192+
```
193+
194+
You can find further details in the [query dialect documentation](https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/dialects/).
195+
196+
---------------------------------------------
157197

158198
### Author
159199

@@ -169,4 +209,4 @@ Special thanks to:
169209
system.
170210
- Paul Hubbard for initial packaging support.
171211

172-
[![Redis](./docs/_static/logo-redis.svg)](https://redis.io)
212+
[![Redis](./docs/_static/logo-redis.svg)](https://redis.io)

docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2+
# image tag 8.0-RC2-pre is the one matching the 8.0 GA release
23
x-client-libs-stack-image: &client-libs-stack-image
3-
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_STACK_IMAGE_TAG:-rs-7.4.0-v2}"
4+
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_STACK_IMAGE_TAG:-8.0-RC2-pre}"
45

56
x-client-libs-image: &client-libs-image
6-
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_IMAGE_TAG:-7.4.2}"
7+
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_IMAGE_TAG:-8.0-RC2-pre}"
78

89
services:
910

0 commit comments

Comments
 (0)