Skip to content

Commit 4d21842

Browse files
author
Himanshu Singh
committed
fix: apply ruff format and fix pre-commit secret/linting issues
Signed-off-by: Himanshu Singh <himanshu.singh@walmart.com>
1 parent d5947e9 commit 4d21842

2 files changed

Lines changed: 16 additions & 48 deletions

File tree

sdk/python/feast/infra/online_stores/cassandra_online_store/cassandra_online_store.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,7 @@ def _get_session(self, config: RepoConfig):
360360
raise CassandraInvalidConfig(E_CASSANDRA_DC_CONFIG_EMPTY)
361361

362362
# Validate: mutually exclusive with hosts / secure_bundle_path
363-
if (
364-
online_store_config.hosts
365-
or online_store_config.secure_bundle_path
366-
):
363+
if online_store_config.hosts or online_store_config.secure_bundle_path:
367364
raise CassandraInvalidConfig(E_CASSANDRA_DC_CONFIG_CONFLICT)
368365

369366
port = online_store_config.port or 9042
@@ -437,9 +434,7 @@ def _get_session(self, config: RepoConfig):
437434
if (read_dc and read_dc not in dc_names) or (
438435
write_dc and write_dc not in dc_names
439436
):
440-
raise CassandraInvalidConfig(
441-
E_CASSANDRA_DC_ROUTING_INVALID
442-
)
437+
raise CassandraInvalidConfig(E_CASSANDRA_DC_ROUTING_INVALID)
443438
self._read_execution_profile = read_dc or default_dc
444439
self._write_execution_profile = write_dc or default_dc
445440
else:
@@ -493,9 +488,7 @@ def _get_session(self, config: RepoConfig):
493488
if online_store_config.load_balancing:
494489
# construct a proper execution profile embedding
495490
# the configured LB policy
496-
_lbp_name = (
497-
online_store_config.load_balancing.load_balancing_policy
498-
)
491+
_lbp_name = online_store_config.load_balancing.load_balancing_policy
499492
if _lbp_name == "DCAwareRoundRobinPolicy":
500493
lb_policy = DCAwareRoundRobinPolicy(
501494
local_dc=online_store_config.load_balancing.local_dc,

sdk/python/tests/unit/infra/online_store/test_cassandra_online_store.py

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from feast.infra.online_stores.cassandra_online_store import ( # noqa: E402
1111
cassandra_online_store as _cos,
1212
)
13-
from feast.repo_config import RepoConfig # noqa: E402
13+
from feast.repo_config import RepoConfig # noqa: E402
1414

1515
CassandraInvalidConfig = _cos.CassandraInvalidConfig
1616
CassandraOnlineStore = _cos.CassandraOnlineStore
@@ -27,9 +27,7 @@
2727

2828
# Path to patch so tests never open a real Cassandra connection
2929
_CLUSTER_PATH = (
30-
"feast.infra.online_stores"
31-
".cassandra_online_store"
32-
".cassandra_online_store.Cluster"
30+
"feast.infra.online_stores.cassandra_online_store.cassandra_online_store.Cluster"
3331
)
3432

3533

@@ -118,10 +116,7 @@ def test_datacenter_replication_fields_parse(self):
118116
],
119117
)
120118
assert cfg.datacenters[0].replication_factor == 3
121-
assert (
122-
cfg.datacenters[0].replication_strategy
123-
== "NetworkTopologyStrategy"
124-
)
119+
assert cfg.datacenters[0].replication_strategy == "NetworkTopologyStrategy"
125120

126121
def test_datacenter_replication_fields_default_to_none(self):
127122
cfg = CassandraOnlineStoreConfig(
@@ -172,9 +167,7 @@ class TestCassandraMultiDCValidation:
172167
Validation errors that _get_session raises before touching the driver.
173168
"""
174169

175-
def test_datacenters_and_hosts_are_mutually_exclusive(
176-
self, mock_cluster
177-
):
170+
def test_datacenters_and_hosts_are_mutually_exclusive(self, mock_cluster):
178171
store = CassandraOnlineStore()
179172
cfg = _repo_config(
180173
CassandraOnlineStoreConfig(
@@ -188,9 +181,7 @@ def test_datacenters_and_hosts_are_mutually_exclusive(
188181
):
189182
store._get_session(cfg)
190183

191-
def test_datacenters_and_secure_bundle_are_mutually_exclusive(
192-
self, mock_cluster
193-
):
184+
def test_datacenters_and_secure_bundle_are_mutually_exclusive(self, mock_cluster):
194185
store = CassandraOnlineStore()
195186
cfg = _repo_config(
196187
CassandraOnlineStoreConfig(
@@ -206,17 +197,11 @@ def test_datacenters_and_secure_bundle_are_mutually_exclusive(
206197

207198
def test_empty_datacenters_list_raises(self, mock_cluster):
208199
store = CassandraOnlineStore()
209-
cfg = _repo_config(
210-
CassandraOnlineStoreConfig(keyspace="ks", datacenters=[])
211-
)
212-
with pytest.raises(
213-
CassandraInvalidConfig, match=E_CASSANDRA_DC_CONFIG_EMPTY
214-
):
200+
cfg = _repo_config(CassandraOnlineStoreConfig(keyspace="ks", datacenters=[]))
201+
with pytest.raises(CassandraInvalidConfig, match=E_CASSANDRA_DC_CONFIG_EMPTY):
215202
store._get_session(cfg)
216203

217-
def test_load_balancing_local_dc_not_in_datacenters_raises(
218-
self, mock_cluster
219-
):
204+
def test_load_balancing_local_dc_not_in_datacenters_raises(self, mock_cluster):
220205
store = CassandraOnlineStore()
221206
cfg = _repo_config(
222207
CassandraOnlineStoreConfig(
@@ -346,9 +331,7 @@ def test_default_dc_fallback_to_first_entry_when_no_load_balancing(
346331
profiles = mock_cls.call_args.kwargs["execution_profiles"]
347332
assert profiles[EXEC_PROFILE_DEFAULT] is profiles["dc1"]
348333

349-
def test_all_dc_hosts_merged_into_cluster_contact_points(
350-
self, mock_cluster
351-
):
334+
def test_all_dc_hosts_merged_into_cluster_contact_points(self, mock_cluster):
352335
"""
353336
Cluster() must receive the union of all DC hosts as contact points.
354337
"""
@@ -390,9 +373,7 @@ def test_routing_read_dc_sets_read_execution_profile(self, mock_cluster):
390373
store._get_session(cfg)
391374
assert store._read_execution_profile == "dc2"
392375

393-
def test_routing_write_dc_sets_write_execution_profile(
394-
self, mock_cluster
395-
):
376+
def test_routing_write_dc_sets_write_execution_profile(self, mock_cluster):
396377
mock_cls, mock_session = mock_cluster
397378
store = CassandraOnlineStore()
398379
cfg = _repo_config(
@@ -409,9 +390,7 @@ def test_routing_write_dc_sets_write_execution_profile(
409390
store._get_session(cfg)
410391
assert store._write_execution_profile == "dc1"
411392

412-
def test_no_routing_block_uses_default_dc_for_both_ops(
413-
self, mock_cluster
414-
):
393+
def test_no_routing_block_uses_default_dc_for_both_ops(self, mock_cluster):
415394
"""Without a routing block, both read and write use the default DC."""
416395
mock_cls, mock_session = mock_cluster
417396
store = CassandraOnlineStore()
@@ -429,9 +408,7 @@ def test_no_routing_block_uses_default_dc_for_both_ops(
429408
assert store._read_execution_profile == "dc1"
430409
assert store._write_execution_profile == "dc1"
431410

432-
def test_partial_routing_missing_read_dc_falls_back_to_default(
433-
self, mock_cluster
434-
):
411+
def test_partial_routing_missing_read_dc_falls_back_to_default(self, mock_cluster):
435412
"""routing.read_dc omitted → reads use default DC."""
436413
mock_cls, mock_session = mock_cluster
437414
store = CassandraOnlineStore()
@@ -497,9 +474,7 @@ def test_branch_a_hosts_creates_session(self, mock_cluster):
497474
mock_cls, mock_session = mock_cluster
498475
store = CassandraOnlineStore()
499476
cfg = _repo_config(
500-
CassandraOnlineStoreConfig(
501-
hosts=["127.0.0.1"], port=9042, keyspace="ks"
502-
)
477+
CassandraOnlineStoreConfig(hosts=["127.0.0.1"], port=9042, keyspace="ks")
503478
)
504479
session = store._get_session(cfg)
505480

0 commit comments

Comments
 (0)