Skip to content

Commit

Permalink
Test all Python versions (valkey-io#1758)
Browse files Browse the repository at this point in the history
* Fixed Supported Engine Versions in all readmes

* Python lint: Exclude submodules folder from mypy

* Python CI: Added tests to all supported python versions and fixed tests accordingly

* Removed flakey "wait" test from transaction, changes ints to doubles

* Exclude pubsub tests as a temp solution
  • Loading branch information
barshaul authored Jul 2, 2024
1 parent 905a17b commit 07dd198
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 70 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,22 @@ jobs:
fail-fast: false
matrix:
engine: ${{ fromJson(needs.load-engine-matrix.outputs.matrix) }}
python:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: ${{ matrix.python }}

- name: Install dependencies
working-directory: ./python
Expand Down
4 changes: 2 additions & 2 deletions csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ The C# wrapper is currently not in a usable state.
General Language Independent Driver for the Enterprise (GLIDE) for Redis, is an AWS-sponsored, open-source Redis client. GLIDE for Redis works with any Redis distribution that adheres to the Redis Serialization Protocol (RESP) specification, including open-source Redis, Amazon ElastiCache for Redis, and Amazon MemoryDB for Redis.
Strategic, mission-critical Redis-based applications have requirements for security, optimized performance, minimal downtime, and observability. GLIDE for Redis is designed to provide a client experience that helps meet these objectives. It is sponsored and supported by AWS, and comes pre-configured with best practices learned from over a decade of operating Redis-compatible services used by hundreds of thousands of customers. To help ensure consistency in development and operations, GLIDE for Redis is implemented using a core driver framework, written in Rust, with extensions made available for each supported programming language. This design ensures that updates easily propagate to each language and reduces overall complexity.

## Supported Redis Versions
## Supported Engine Versions

GLIDE for Redis is API-compatible with open source Redis version 6 and 7.
Refer to the [Supported Engine Versions table](https://github.com/aws/glide-for-redis/blob/main/README.md#supported-engine-versions) for details.

## Current Status

Expand Down
4 changes: 4 additions & 0 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ The Java client contains the following parts:
3. `benchmark`: A dedicated benchmarking tool designed to evaluate and compare the performance of GLIDE for Redis and other Java clients.
4. `integTest`: An integration test sub-project for API and E2E testing

## Supported Engine Versions

Refer to the [Supported Engine Versions table](https://github.com/aws/glide-for-redis/blob/main/README.md#supported-engine-versions) for details.

## Installation and Setup

### Install from Gradle
Expand Down
4 changes: 2 additions & 2 deletions node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
General Language Independent Driver for the Enterprise (GLIDE) for Redis, is an AWS-sponsored, open-source Redis client. GLIDE for Redis works with any Redis distribution that adheres to the Redis Serialization Protocol (RESP) specification, including open-source Redis, Amazon ElastiCache for Redis, and Amazon MemoryDB for Redis.
Strategic, mission-critical Redis-based applications have requirements for security, optimized performance, minimal downtime, and observability. GLIDE for Redis is designed to provide a client experience that helps meet these objectives. It is sponsored and supported by AWS, and comes pre-configured with best practices learned from over a decade of operating Redis-compatible services used by hundreds of thousands of customers. To help ensure consistency in development and operations, GLIDE for Redis is implemented using a core driver framework, written in Rust, with extensions made available for each supported programming language. This design ensures that updates easily propagate to each language and reduces overall complexity. In this Preview release, GLIDE for Redis is available for Python and Javascript (Node.js), with support for Java actively under development.

## Supported Redis Versions
## Supported Engine Versions

GLIDE for Redis is API-compatible with open source Redis version 6 and 7.
Refer to the [Supported Engine Versions table](https://github.com/aws/glide-for-redis/blob/main/README.md#supported-engine-versions) for details.

## Current Status

Expand Down
14 changes: 10 additions & 4 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
General Language Independent Driver for the Enterprise (GLIDE) for Redis, is an AWS-sponsored, open-source Redis client. GLIDE for Redis works with any Redis distribution that adheres to the Redis Serialization Protocol (RESP) specification, including open-source Redis, Amazon ElastiCache for Redis, and Amazon MemoryDB for Redis.
Strategic, mission-critical Redis-based applications have requirements for security, optimized performance, minimal downtime, and observability. GLIDE for Redis is designed to provide a client experience that helps meet these objectives. It is sponsored and supported by AWS, and comes pre-configured with best practices learned from over a decade of operating Redis-compatible services used by hundreds of thousands of customers. To help ensure consistency in development and operations, GLIDE for Redis is implemented using a core driver framework, written in Rust, with extensions made available for each supported programming language. This design ensures that updates easily propagate to each language and reduces overall complexity. In this Preview release, GLIDE for Redis is available for Python and Javascript (Node.js), with support for Java actively under development.

## Supported Redis Versions
## Supported Engine Versions

GLIDE for Redis is API-compatible with open source Redis version 6 and 7.
Refer to the [Supported Engine Versions table](https://github.com/aws/glide-for-redis/blob/main/README.md#supported-engine-versions) for details.

## Current Status

Expand All @@ -18,9 +18,15 @@ This preview release is recommended for testing purposes only.

The beta release of GLIDE for Redis was tested on Intel x86_64 using Ubuntu 22.04.1, Amazon Linux 2023 (AL2023), and macOS 12.7.

## Python supported version
## Python Supported Versions

Python 3.8 or higher.
| Python Version |
|----------------|
| 3.8 |
| 3.9 |
| 3.10 |
| 3.11 |
| 3.12 |

## Installation and Setup

Expand Down
3 changes: 3 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ extend-ignore = ['E203']

[tool.black]
target-version = ['py38', 'py39', 'py310', 'py311', 'py312']

[tool.mypy]
exclude = [ 'submodules' ]
3 changes: 2 additions & 1 deletion python/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[pytest]
markers =
smoke_test: mark a test as a build verification testing.
addopts = -k "not redis_modules"
# TODO: Remove pubsub exclusion after the flakey tests are fixed
addopts = -k "not redis_modules and not pubsub"
12 changes: 6 additions & 6 deletions python/python/glide/async_commands/core.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
from collections.abc import Mapping
from dataclasses import dataclass
from datetime import datetime, timedelta
from enum import Enum
from typing import (
Dict,
List,
Mapping,
Optional,
Protocol,
Set,
Expand Down Expand Up @@ -6049,7 +6049,7 @@ async def lcs_idx(
key2: TEncodable,
min_match_len: Optional[int] = None,
with_match_len: Optional[bool] = False,
) -> Mapping[bytes, Union[list[list[Union[list[int], int]]], int]]:
) -> Mapping[bytes, Union[List[List[Union[List[int], int]]], int]]:
"""
Returns the indices and length of the longest common subsequence between strings stored at key1 and key2.
Expand Down Expand Up @@ -6132,7 +6132,7 @@ async def lcs_idx(
args.append("WITHMATCHLEN")

return cast(
Mapping[bytes, Union[list[list[Union[list[int], int]]], int]],
Mapping[bytes, Union[List[List[Union[List[int], int]]], int]],
await self._execute_command(RequestType.LCS, args),
)

Expand All @@ -6143,7 +6143,7 @@ async def lpos(
rank: Optional[int] = None,
count: Optional[int] = None,
max_len: Optional[int] = None,
) -> Union[int, list[int], None]:
) -> Union[int, List[int], None]:
"""
Returns the index or indexes of element(s) matching `element` in the `key` list. If no match is found,
None is returned.
Expand All @@ -6159,7 +6159,7 @@ async def lpos(
in the list. A `max_len` of 0 means unlimited amount of comparisons.
Returns:
Union[int, list[int], None]: The index of the first occurrence of `element`,
Union[int, List[int], None]: The index of the first occurrence of `element`,
or None if `element` is not in the list.
With the `count` option, a list of indices of matching elements will be returned.
Expand Down Expand Up @@ -6190,6 +6190,6 @@ async def lpos(
args.extend(["MAXLEN", str(max_len)])

return cast(
Union[int, list[int], None],
Union[int, List[int], None],
await self._execute_command(RequestType.LPos, args),
)
2 changes: 1 addition & 1 deletion python/python/glide/async_commands/sorted_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _create_geosearch_args(
store_dist: bool = False,
) -> List[TEncodable]:
args: List[TEncodable] = keys
if isinstance(search_from, str | bytes):
if isinstance(search_from, (str, bytes)):
args.extend(["FROMMEMBER", search_from])
else:
args.extend(
Expand Down
2 changes: 1 addition & 1 deletion python/python/glide/async_commands/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4492,7 +4492,7 @@ def lpos(
in the list. A `max_len` of 0 means unlimited amount of comparisons.
Command Response:
Union[int, list[int], None]: The index of the first occurrence of `element`,
Union[int, List[int], None]: The index of the first occurrence of `element`,
or None if `element` is not in the list.
With the `count` option, a list of indices of matching elements will be returned.
Expand Down
2 changes: 1 addition & 1 deletion python/python/glide/glide_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, config: BaseClientConfiguration):
To create a new client, use the `create` classmethod
"""
self.config: BaseClientConfiguration = config
self._available_futures: dict[int, asyncio.Future] = {}
self._available_futures: Dict[int, asyncio.Future] = {}
self._available_callback_indexes: List[int] = list()
self._buffered_requests: List[TRequest] = list()
self._writer_lock = threading.Lock()
Expand Down
15 changes: 8 additions & 7 deletions python/python/tests/test_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import copy
import math
import time
from collections.abc import Mapping
from datetime import date, datetime, timedelta, timezone
from typing import Any, Dict, List, Tuple, Union, cast
from typing import Any, Dict, List, Mapping, Tuple, Union, cast

import pytest
from glide import ClosingError, RequestError, Script
Expand Down Expand Up @@ -8327,7 +8326,7 @@ class TestMultiKeyCommandCrossSlot:
async def test_multi_key_command_returns_cross_slot_error(
self, redis_client: GlideClusterClient
):
promises: list[Any] = [
promises: List[Any] = [
redis_client.blpop(["abc", "zxy", "lkn"], 0.1),
redis_client.brpop(["abc", "zxy", "lkn"], 0.1),
redis_client.rename("abc", "zxy"),
Expand Down Expand Up @@ -8866,7 +8865,7 @@ async def test_zscan(self, redis_client: GlideClusterClient):
),
)
result_cursor = str(result[result_cursor_index])
result_iteration_collection: dict[str, str] = convert_list_to_dict(
result_iteration_collection: Dict[str, str] = convert_list_to_dict(
result[result_collection_index]
)
full_result_map.update(result_iteration_collection)
Expand All @@ -8890,7 +8889,8 @@ async def test_zscan(self, redis_client: GlideClusterClient):
full_result_map.update(next_result_collection)
result_iteration_collection = next_result_collection
result_cursor = next_result_cursor
assert (num_map_with_str_scores | char_map_with_str_scores) == full_result_map
num_map_with_str_scores.update(char_map_with_str_scores)
assert num_map_with_str_scores == full_result_map

# Test match pattern
result = await redis_client.zscan(key1, initial_cursor, match="*")
Expand Down Expand Up @@ -8978,7 +8978,7 @@ async def test_hscan(self, redis_client: GlideClusterClient):
),
)
result_cursor = str(result[result_cursor_index])
result_iteration_collection: dict[str, str] = convert_list_to_dict(
result_iteration_collection: Dict[str, str] = convert_list_to_dict(
result[result_collection_index]
)
full_result_map.update(result_iteration_collection)
Expand All @@ -9002,7 +9002,8 @@ async def test_hscan(self, redis_client: GlideClusterClient):
full_result_map.update(next_result_collection)
result_iteration_collection = next_result_collection
result_cursor = next_result_cursor
assert (num_map | char_map) == full_result_map
num_map.update(char_map)
assert num_map == full_result_map

# Test match pattern
result = await redis_client.hscan(key1, initial_cursor, match="*")
Expand Down
Loading

0 comments on commit 07dd198

Please sign in to comment.