Skip to content

Commit ba7af10

Browse files
Python: Replace instances of Redis with Valkey (#2266)
* Replace instances of Redis with Valkey Signed-off-by: Jonathan Louie <jonathanl@bitquilltech.com> * Update CHANGELOG.md Signed-off-by: Jonathan Louie <jonathanl@bitquilltech.com> * Revert doc change for lolwut Signed-off-by: Jonathan Louie <jonathanl@bitquilltech.com> --------- Signed-off-by: Jonathan Louie <jonathanl@bitquilltech.com> Signed-off-by: jonathanl-bq <72158117+jonathanl-bq@users.noreply.github.com> Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com> Co-authored-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
1 parent 87b5848 commit ba7af10

File tree

8 files changed

+36
-35
lines changed

8 files changed

+36
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#### Changes
2+
* Python: Replace instances of Redis with Valkey ([#2266](https://github.com/valkey-io/valkey-glide/pull/2266))
23
* Java: Replace instances of Redis with Valkey ([#2268](https://github.com/valkey-io/valkey-glide/pull/2268))
34
* Node: Replace instances of Redis with Valkey ([#2260](https://github.com/valkey-io/valkey-glide/pull/2260))
45
* Java: Fetch server version using info command ([#2258](https://github.com/valkey-io/valkey-glide/pull/2258))

python/DEVELOPER.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ Before starting this step, make sure you've installed all software requirments.
117117
```
118118
> **Note:** To build the wrapper binary with debug symbols remove the --strip flag.
119119
8. Run tests:
120-
1. Ensure that you have installed redis-server and redis-cli on your host. You can find the Redis installation guide at the following link: [Redis Installation Guide](https://redis.io/docs/install/install-redis/install-redis-on-linux/).
120+
1. Ensure that you have installed redis-server or valkey-server and redis-cli or valkey-cli on your host. You can find the Redis installation guide at the following link: [Redis Installation Guide](https://redis.io/docs/install/install-redis/install-redis-on-linux/). You can get Valkey from the following link: [Valkey Download](https://valkey.io/download/).
121121
2. Validate the activation of the virtual environment from step 4 by ensuring its name (`.env`) is displayed next to your command prompt.
122122
3. Execute the following command from the python folder:
123123
```bash
124124
pytest --asyncio-mode=auto
125125
```
126-
> **Note:** To run redis modules tests, add -k "test_server_modules.py".
126+
> **Note:** To run Valkey modules tests, add -k "test_server_modules.py".
127127

128128
- Install Python development requirements with:
129129

python/python/glide/glide_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ class GlideClient(BaseClient, StandaloneCommands):
570570
"""
571571
Client used for connection to standalone servers.
572572
For full documentation, see
573-
https://github.com/valkey-io/valkey-glide/wiki/Python-wrapper#redis-standalone
573+
https://github.com/valkey-io/valkey-glide/wiki/Python-wrapper#standalone
574574
"""
575575

576576

python/python/tests/conftest.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from glide.glide_client import GlideClient, GlideClusterClient, TGlideClient
1515
from glide.logger import Level as logLevel
1616
from glide.logger import Logger
17-
from tests.utils.cluster import RedisCluster
17+
from tests.utils.cluster import ValkeyCluster
1818

1919
DEFAULT_HOST = "localhost"
2020
DEFAULT_PORT = 6379
@@ -55,7 +55,7 @@ def pytest_addoption(parser):
5555
parser.addoption(
5656
"--load-module",
5757
action="append",
58-
help="""Load additional Redis modules (provide full path for the module's shared library).
58+
help="""Load additional Valkey modules (provide full path for the module's shared library).
5959
Use multiple times for multiple modules.
6060
Example:
6161
pytest --load-module=/path/to/module1.so --load-module=/path/to/module2.so""",
@@ -110,27 +110,27 @@ def parse_endpoints(endpoints_str: str) -> List[List[str]]:
110110

111111
def create_clusters(tls, load_module, cluster_endpoints, standalone_endpoints):
112112
"""
113-
Create Redis clusters based on the provided options.
113+
Create Valkey clusters based on the provided options.
114114
"""
115115
if cluster_endpoints or standalone_endpoints:
116116
# Endpoints were passed by the caller, not creating clusters internally
117117
if cluster_endpoints:
118118
cluster_endpoints = parse_endpoints(cluster_endpoints)
119-
pytest.redis_cluster = RedisCluster(tls=tls, addresses=cluster_endpoints)
119+
pytest.valkey_cluster = ValkeyCluster(tls=tls, addresses=cluster_endpoints)
120120
if standalone_endpoints:
121121
standalone_endpoints = parse_endpoints(standalone_endpoints)
122-
pytest.standalone_cluster = RedisCluster(
122+
pytest.standalone_cluster = ValkeyCluster(
123123
tls=tls, addresses=standalone_endpoints
124124
)
125125
else:
126126
# No endpoints were provided, create new clusters
127-
pytest.redis_cluster = RedisCluster(
127+
pytest.valkey_cluster = ValkeyCluster(
128128
tls=tls,
129129
cluster_mode=True,
130130
load_module=load_module,
131131
addresses=cluster_endpoints,
132132
)
133-
pytest.standalone_cluster = RedisCluster(
133+
pytest.standalone_cluster = ValkeyCluster(
134134
tls=tls,
135135
cluster_mode=False,
136136
shard_count=1,
@@ -160,9 +160,9 @@ def pytest_sessionfinish(session, exitstatus):
160160
returning the exit status to the system.
161161
"""
162162
try:
163-
del pytest.redis_cluster
163+
del pytest.valkey_cluster
164164
except AttributeError:
165-
# redis_cluster was not set, skip deletion
165+
# valkey_cluster was not set, skip deletion
166166
pass
167167

168168
try:
@@ -233,10 +233,10 @@ async def create_client(
233233
# Create async socket client
234234
use_tls = request.config.getoption("--tls")
235235
if cluster_mode:
236-
assert type(pytest.redis_cluster) is RedisCluster
236+
assert type(pytest.valkey_cluster) is ValkeyCluster
237237
assert database_id == 0
238-
k = min(3, len(pytest.redis_cluster.nodes_addr))
239-
seed_nodes = random.sample(pytest.redis_cluster.nodes_addr, k=k)
238+
k = min(3, len(pytest.valkey_cluster.nodes_addr))
239+
seed_nodes = random.sample(pytest.valkey_cluster.nodes_addr, k=k)
240240
cluster_config = GlideClusterClientConfiguration(
241241
addresses=seed_nodes if addresses is None else addresses,
242242
use_tls=use_tls,
@@ -248,7 +248,7 @@ async def create_client(
248248
)
249249
return await GlideClusterClient.create(cluster_config)
250250
else:
251-
assert type(pytest.standalone_cluster) is RedisCluster
251+
assert type(pytest.standalone_cluster) is ValkeyCluster
252252
config = GlideClientConfiguration(
253253
addresses=(
254254
pytest.standalone_cluster.nodes_addr if addresses is None else addresses

python/python/tests/test_async_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ async def test_config_rewrite(self, glide_client: TGlideClient):
578578
if len(info_server["config_file"]) > 0:
579579
assert await glide_client.config_rewrite() == OK
580580
else:
581-
# We expect Redis to return an error since the test cluster doesn't use redis.conf file
581+
# We expect Valkey to return an error since the test cluster doesn't use valkey.conf file
582582
with pytest.raises(RequestError) as e:
583583
await glide_client.config_rewrite()
584584
assert "The server is running without a config file" in str(e)
@@ -6951,7 +6951,7 @@ async def test_xgroup_set_id(
69516951
)
69526952

69536953
# reset the last delivered ID for the consumer group to "1-1"
6954-
# ENTRIESREAD is only supported in Redis version 7.0.0 and above
6954+
# ENTRIESREAD is only supported in Valkey version 7.0.0 and above
69556955
if await check_if_server_version_lt(glide_client, "7.0.0"):
69566956
assert await glide_client.xgroup_set_id(key, group_name, stream_id1_1) == OK
69576957
else:
@@ -8206,7 +8206,7 @@ async def test_function_delete_with_routing(
82068206
async def test_function_stats(self, glide_client: TGlideClient):
82078207
min_version = "7.0.0"
82088208
if await check_if_server_version_lt(glide_client, min_version):
8209-
return pytest.mark.skip(reason=f"Redis version required >= {min_version}")
8209+
return pytest.mark.skip(reason=f"Valkey version required >= {min_version}")
82108210

82118211
lib_name = "functionStats_without_route"
82128212
func_name = lib_name
@@ -8252,7 +8252,7 @@ async def test_function_stats_running_script(
82528252
):
82538253
min_version = "7.0.0"
82548254
if await check_if_server_version_lt(glide_client, min_version):
8255-
return pytest.mark.skip(reason=f"Redis version required >= {min_version}")
8255+
return pytest.mark.skip(reason=f"Valkey version required >= {min_version}")
82568256

82578257
lib_name = f"mylib1C{get_random_string(5)}"
82588258
func_name = f"myfunc1c{get_random_string(5)}"
@@ -8309,7 +8309,7 @@ async def test_function_stats_with_routing(
83098309
):
83108310
min_version = "7.0.0"
83118311
if await check_if_server_version_lt(glide_client, min_version):
8312-
return pytest.mark.skip(reason=f"Redis version required >= {min_version}")
8312+
return pytest.mark.skip(reason=f"Valkey version required >= {min_version}")
83138313

83148314
route = (
83158315
SlotKeyRoute(SlotType.PRIMARY, get_random_string(10))
@@ -8376,7 +8376,7 @@ async def test_function_kill_no_write(
83768376
):
83778377
min_version = "7.0.0"
83788378
if await check_if_server_version_lt(glide_client, min_version):
8379-
return pytest.mark.skip(reason=f"Redis version required >= {min_version}")
8379+
return pytest.mark.skip(reason=f"Valkey version required >= {min_version}")
83808380

83818381
lib_name = f"mylib1C{get_random_string(5)}"
83828382
func_name = f"myfunc1c{get_random_string(5)}"
@@ -8435,7 +8435,7 @@ async def test_function_kill_write_is_unkillable(
84358435
):
84368436
min_version = "7.0.0"
84378437
if await check_if_server_version_lt(glide_client, min_version):
8438-
return pytest.mark.skip(reason=f"Redis version required >= {min_version}")
8438+
return pytest.mark.skip(reason=f"Valkey version required >= {min_version}")
84398439

84408440
lib_name = f"mylib1C{get_random_string(5)}"
84418441
func_name = f"myfunc1c{get_random_string(5)}"

python/python/tests/test_pubsub.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ async def test_sharded_pubsub_many_channels(
658658

659659
min_version = "7.0.0"
660660
if await check_if_server_version_lt(publishing_client, min_version):
661-
pytest.skip(reason=f"Redis version required >= {min_version}")
661+
pytest.skip(reason=f"Valkey version required >= {min_version}")
662662

663663
# Publish messages to each channel
664664
for channel, message in channels_and_messages.items():
@@ -1247,9 +1247,9 @@ async def test_pubsub_combined_exact_pattern_and_sharded_one_client(
12471247
pub_sub_exact,
12481248
)
12491249

1250-
# Setup PUBSUB for sharded channels (Redis version > 7)
1250+
# Setup PUBSUB for sharded channels (Valkey version > 7)
12511251
if await check_if_server_version_lt(publishing_client, "7.0.0"):
1252-
pytest.skip("Redis version required >= 7.0.0")
1252+
pytest.skip("Valkey version required >= 7.0.0")
12531253

12541254
# Publish messages to all channels
12551255
for channel, message in {
@@ -2062,9 +2062,9 @@ async def test_pubsub_sharded_max_size_message(self, request, cluster_mode: bool
20622062
timeout=10000,
20632063
)
20642064

2065-
# (Redis version > 7)
2065+
# (Valkey version > 7)
20662066
if await check_if_server_version_lt(publishing_client, "7.0.0"):
2067-
pytest.skip("Redis version required >= 7.0.0")
2067+
pytest.skip("Valkey version required >= 7.0.0")
20682068

20692069
assert (
20702070
await cast(GlideClusterClient, publishing_client).publish(

python/python/tests/utils/cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
SCRIPT_FILE = os.path.abspath(f"{__file__}/../../../../../utils/cluster_manager.py")
1111

1212

13-
class RedisCluster:
13+
class ValkeyCluster:
1414
def __init__(
1515
self,
1616
tls,

python/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ fn glide(_py: Python, m: &PyModule) -> PyResult<()> {
150150
let len = iterator.len();
151151

152152
iterator.try_fold(Vec::with_capacity(len), |mut acc, val| {
153-
acc.push(redis_value_to_py(py, val)?);
153+
acc.push(resp_value_to_py(py, val)?);
154154
Ok(acc)
155155
})
156156
}
157157

158-
fn redis_value_to_py(py: Python, val: Value) -> PyResult<PyObject> {
158+
fn resp_value_to_py(py: Python, val: Value) -> PyResult<PyObject> {
159159
match val {
160160
Value::Nil => Ok(py.None()),
161161
Value::SimpleString(str) => {
@@ -175,14 +175,14 @@ fn glide(_py: Python, m: &PyModule) -> PyResult<()> {
175175
Value::Map(map) => {
176176
let dict = PyDict::new(py);
177177
for (key, value) in map {
178-
dict.set_item(redis_value_to_py(py, key)?, redis_value_to_py(py, value)?)?;
178+
dict.set_item(resp_value_to_py(py, key)?, resp_value_to_py(py, value)?)?;
179179
}
180180
Ok(dict.into_py(py))
181181
}
182182
Value::Attribute { data, attributes } => {
183183
let dict = PyDict::new(py);
184-
let value = redis_value_to_py(py, *data)?;
185-
let attributes = redis_value_to_py(py, Value::Map(attributes))?;
184+
let value = resp_value_to_py(py, *data)?;
185+
let attributes = resp_value_to_py(py, Value::Map(attributes))?;
186186
dict.set_item("value", value)?;
187187
dict.set_item("attributes", attributes)?;
188188
Ok(dict.into_py(py))
@@ -213,7 +213,7 @@ fn glide(_py: Python, m: &PyModule) -> PyResult<()> {
213213
#[pyfn(m)]
214214
pub fn value_from_pointer(py: Python, pointer: u64) -> PyResult<PyObject> {
215215
let value = unsafe { Box::from_raw(pointer as *mut Value) };
216-
redis_value_to_py(py, *value)
216+
resp_value_to_py(py, *value)
217217
}
218218

219219
#[pyfn(m)]

0 commit comments

Comments
 (0)