Skip to content

Commit

Permalink
Migrate from redis-py-cluster to redis-py (#292)
Browse files Browse the repository at this point in the history
Migrate from redis-py-cluster to redis-py for cluster
status check.

[ committed by @mellis13 ]
[ reviewed by @MattToast ]
  • Loading branch information
mellis13 authored Jun 1, 2023
1 parent 99958a0 commit 5817084
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
3 changes: 3 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Description

A full list of changes and detailed notes can be found below:

- Migrate from redis-py-cluster to redis-py
- Update full test suite to not require a TF wheel at test time
- Update doc strings
- Remove deprecated code
Expand All @@ -34,6 +35,7 @@ A full list of changes and detailed notes can be found below:

Detailed notes

- Migrate from redis-py-cluster to redis-py for cluster status checks (PR292_)
- Update full test suite to no longer require a tensorflow wheel to be available
at test time. (PR291_)
- Correct spelling of colocated in doc strings (PR290_)
Expand All @@ -47,6 +49,7 @@ codes. These have now all been updated. (PR284_)
- Orchestrator and Colocated DB now accept a list of interfaces to bind to. The
argument name is still `interface` for backward compatibility reasons. (PR281_)

.. _PR292: https://github.com/CrayLabs/SmartSim/pull/292
.. _PR291: https://github.com/CrayLabs/SmartSim/pull/291
.. _PR290: https://github.com/CrayLabs/SmartSim/pull/290
.. _PR289: https://github.com/CrayLabs/SmartSim/pull/289
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ psutil>=5.7.2
coloredlogs>=10.0
tabulate>=0.8.9
smartredis>=0.4.0
redis==3.5.3
redis-py-cluster==2.1.3
redis>=4.5
tqdm>=4.50.2
filelock>=3.4.2
protobuf~=3.20
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ def has_ext_modules(_placeholder):
"psutil>=5.7.2",
"coloredlogs>=10.0",
"tabulate>=0.8.9",
"redis-py-cluster==2.1.3",
"redis==3.5.3",
"redis>=4.5",
"tqdm>=4.50.2",
"filelock>=3.4.2",
"protobuf~=3.20",
Expand Down
19 changes: 9 additions & 10 deletions smartsim/_core/utils/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@

import logging
import time
from itertools import product

import redis
from rediscluster import RedisCluster
from rediscluster.exceptions import ClusterDownError, RedisClusterException
from redis.cluster import RedisCluster, ClusterNode
from redis.exceptions import ClusterDownError, RedisClusterException
from smartredis import Client
from smartredis.error import RedisReplyError

Expand Down Expand Up @@ -90,20 +91,18 @@ def check_cluster_status(hosts, ports, trials=10): # cov-wlm
:raises SmartSimError: If cluster status cannot be verified
"""
host_list = []
for host in hosts:
for port in ports:
host_dict = dict()
host_dict["host"] = get_ip_from_host(host)
host_dict["port"] = port
host_list.append(host_dict)
cluster_nodes = [ClusterNode(get_ip_from_host(host), port)
for host, port in product(hosts, ports)]

if not cluster_nodes:
raise SSInternalError("No cluster nodes have been set for database status check.")

logger.debug("Beginning database cluster status check...")
while trials > 0:
# wait for cluster to spin up
time.sleep(5)
try:
redis_tester = RedisCluster(startup_nodes=host_list)
redis_tester = RedisCluster(startup_nodes=cluster_nodes)
redis_tester.set("__test__", "__test__")
redis_tester.delete("__test__")
logger.debug("Cluster status verified")
Expand Down

0 comments on commit 5817084

Please sign in to comment.