valkey-glide 2.0.1__cp310-cp310-macosx_11_0_arm64.whl → 2.1.0rc1__cp310-cp310-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of valkey-glide might be problematic. Click here for more details.

Files changed (43) hide show
  1. glide/__init__.py +95 -119
  2. glide/async_commands/cluster_commands.py +11 -11
  3. glide/async_commands/core.py +537 -414
  4. glide/async_commands/{server_modules/ft.py → ft.py} +8 -7
  5. glide/async_commands/{server_modules/glide_json.py → glide_json.py} +15 -92
  6. glide/async_commands/standalone_commands.py +9 -11
  7. glide/glide.cpython-310-darwin.so +0 -0
  8. glide/glide.pyi +1 -1
  9. glide/glide_client.py +39 -46
  10. glide/logger.py +3 -3
  11. glide/opentelemetry.py +8 -4
  12. glide_shared/__init__.py +326 -0
  13. {glide/async_commands → glide_shared/commands}/batch.py +396 -10
  14. {glide/async_commands → glide_shared/commands}/batch_options.py +1 -1
  15. glide_shared/commands/core_options.py +407 -0
  16. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_aggregate_options.py +3 -3
  17. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_create_options.py +4 -2
  18. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_profile_options.py +4 -4
  19. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_search_options.py +4 -2
  20. {glide/async_commands → glide_shared/commands}/server_modules/json_batch.py +4 -4
  21. glide_shared/commands/server_modules/json_options.py +93 -0
  22. {glide/async_commands → glide_shared/commands}/sorted_set.py +2 -2
  23. {glide/async_commands → glide_shared/commands}/stream.py +1 -1
  24. {glide → glide_shared}/config.py +28 -21
  25. {glide → glide_shared}/constants.py +3 -3
  26. {glide → glide_shared}/exceptions.py +27 -1
  27. glide_shared/protobuf/command_request_pb2.py +54 -0
  28. {glide → glide_shared}/routes.py +29 -15
  29. {valkey_glide-2.0.1.dist-info → valkey_glide-2.1.0rc1.dist-info}/METADATA +119 -58
  30. valkey_glide-2.1.0rc1.dist-info/RECORD +39 -0
  31. glide/protobuf/command_request_pb2.py +0 -54
  32. glide/protobuf/command_request_pb2.pyi +0 -1193
  33. glide/protobuf/connection_request_pb2.pyi +0 -299
  34. glide/protobuf/response_pb2.pyi +0 -106
  35. valkey_glide-2.0.1.dist-info/RECORD +0 -39
  36. /glide/py.typed → /glide_shared/commands/__init__.py +0 -0
  37. {glide/async_commands → glide_shared/commands}/bitmap.py +0 -0
  38. {glide/async_commands → glide_shared/commands}/command_args.py +0 -0
  39. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
  40. {glide → glide_shared}/protobuf/connection_request_pb2.py +0 -0
  41. {glide → glide_shared}/protobuf/response_pb2.py +0 -0
  42. {glide → glide_shared}/protobuf_codec.py +0 -0
  43. {valkey_glide-2.0.1.dist-info → valkey_glide-2.1.0rc1.dist-info}/WHEEL +0 -0
@@ -5,24 +5,24 @@ module for `vector search` commands.
5
5
 
6
6
  from typing import List, Mapping, Optional, cast
7
7
 
8
- from glide.async_commands.server_modules.ft_options.ft_aggregate_options import (
8
+ from glide_shared.commands.server_modules.ft_options.ft_aggregate_options import (
9
9
  FtAggregateOptions,
10
10
  )
11
- from glide.async_commands.server_modules.ft_options.ft_constants import (
11
+ from glide_shared.commands.server_modules.ft_options.ft_constants import (
12
12
  CommandNames,
13
13
  FtCreateKeywords,
14
14
  )
15
- from glide.async_commands.server_modules.ft_options.ft_create_options import (
15
+ from glide_shared.commands.server_modules.ft_options.ft_create_options import (
16
16
  Field,
17
17
  FtCreateOptions,
18
18
  )
19
- from glide.async_commands.server_modules.ft_options.ft_profile_options import (
19
+ from glide_shared.commands.server_modules.ft_options.ft_profile_options import (
20
20
  FtProfileOptions,
21
21
  )
22
- from glide.async_commands.server_modules.ft_options.ft_search_options import (
22
+ from glide_shared.commands.server_modules.ft_options.ft_search_options import (
23
23
  FtSearchOptions,
24
24
  )
25
- from glide.constants import (
25
+ from glide_shared.constants import (
26
26
  TOK,
27
27
  FtAggregateResponse,
28
28
  FtInfoResponse,
@@ -30,7 +30,8 @@ from glide.constants import (
30
30
  FtSearchResponse,
31
31
  TEncodable,
32
32
  )
33
- from glide.glide_client import TGlideClient
33
+
34
+ from ..glide_client import TGlideClient
34
35
 
35
36
 
36
37
  async def create(
@@ -7,7 +7,7 @@ Examples:
7
7
  >>> import json
8
8
  >>> value = {'a': 1.0, 'b': 2}
9
9
  >>> json_str = json.dumps(value) # Convert Python dictionary to JSON string using json.dumps()
10
- >>> await json.set(client, "doc", "$", json_str)
10
+ >>> await glide_json.set(client, "doc", "$", json_str)
11
11
  'OK' # Indicates successful setting of the value at path '$' in the key stored at `doc`.
12
12
  >>> json_get = await glide_json.get(client, "doc", "$") # Returns the value at path '$' in the JSON document stored at
13
13
  # `doc` as JSON string.
@@ -19,97 +19,20 @@ Examples:
19
19
  """
20
20
  from typing import List, Optional, Union, cast
21
21
 
22
- from glide.async_commands.core import ConditionalChange
23
- from glide.constants import TOK, TEncodable, TJsonResponse, TJsonUniversalResponse
24
- from glide.glide_client import TGlideClient
25
-
26
-
27
- class JsonGetOptions:
28
- """
29
- Represents options for formatting JSON data, to be used in the [JSON.GET](https://valkey.io/commands/json.get/) command.
30
-
31
- Args:
32
- indent (Optional[str]): Sets an indentation string for nested levels. Defaults to None.
33
- newline (Optional[str]): Sets a string that's printed at the end of each line. Defaults to None.
34
- space (Optional[str]): Sets a string that's put between a key and a value. Defaults to None.
35
- """
36
-
37
- def __init__(
38
- self,
39
- indent: Optional[str] = None,
40
- newline: Optional[str] = None,
41
- space: Optional[str] = None,
42
- ):
43
- self.indent = indent
44
- self.new_line = newline
45
- self.space = space
46
-
47
- def get_options(self) -> List[str]:
48
- args = []
49
- if self.indent:
50
- args.extend(["INDENT", self.indent])
51
- if self.new_line:
52
- args.extend(["NEWLINE", self.new_line])
53
- if self.space:
54
- args.extend(["SPACE", self.space])
55
- return args
56
-
57
-
58
- class JsonArrIndexOptions:
59
- """
60
- Options for the `JSON.ARRINDEX` command.
61
-
62
- Args:
63
- start (int): The inclusive start index from which the search begins. Defaults to None.
64
- end (Optional[int]): The exclusive end index where the search stops. Defaults to None.
65
-
66
- Note:
67
- - If `start` is greater than `end`, the command returns `-1` to indicate that the value was not found.
68
- - Indices that exceed the array bounds are automatically adjusted to the nearest valid position.
69
- """
70
-
71
- def __init__(self, start: int, end: Optional[int] = None):
72
- self.start = start
73
- self.end = end
74
-
75
- def to_args(self) -> List[str]:
76
- """
77
- Get the options as a list of arguments for the JSON.ARRINDEX command.
78
-
79
- Returns:
80
- List[str]: A list containing the start and end indices if specified.
81
- """
82
- args = [str(self.start)]
83
- if self.end is not None:
84
- args.append(str(self.end))
85
- return args
86
-
87
-
88
- class JsonArrPopOptions:
89
- """
90
- Options for the JSON.ARRPOP command.
91
-
92
- Args:
93
- path (TEncodable): The path within the JSON document.
94
- index (Optional[int]): The index of the element to pop. If not specified, will pop the last element.
95
- Out of boundary indexes are rounded to their respective array boundaries. Defaults to None.
96
- """
97
-
98
- def __init__(self, path: TEncodable, index: Optional[int] = None):
99
- self.path = path
100
- self.index = index
101
-
102
- def to_args(self) -> List[TEncodable]:
103
- """
104
- Get the options as a list of arguments for the `JSON.ARRPOP` command.
105
-
106
- Returns:
107
- List[TEncodable]: A list containing the path and, if specified, the index.
108
- """
109
- args = [self.path]
110
- if self.index is not None:
111
- args.append(str(self.index))
112
- return args
22
+ from glide_shared.commands.core_options import ConditionalChange
23
+ from glide_shared.commands.server_modules.json_options import (
24
+ JsonArrIndexOptions,
25
+ JsonArrPopOptions,
26
+ JsonGetOptions,
27
+ )
28
+ from glide_shared.constants import (
29
+ TOK,
30
+ TEncodable,
31
+ TJsonResponse,
32
+ TJsonUniversalResponse,
33
+ )
34
+
35
+ from ..glide_client import TGlideClient
113
36
 
114
37
 
115
38
  async def set(
@@ -4,25 +4,25 @@ from __future__ import annotations
4
4
 
5
5
  from typing import Dict, List, Mapping, Optional, Union, cast
6
6
 
7
- from glide.async_commands.batch import Batch
8
- from glide.async_commands.batch_options import BatchOptions
9
- from glide.async_commands.command_args import ObjectType
10
- from glide.async_commands.core import (
11
- CoreCommands,
7
+ from glide.glide import Script
8
+ from glide_shared.commands.batch import Batch
9
+ from glide_shared.commands.batch_options import BatchOptions
10
+ from glide_shared.commands.command_args import ObjectType
11
+ from glide_shared.commands.core_options import (
12
12
  FlushMode,
13
13
  FunctionRestorePolicy,
14
14
  InfoSection,
15
15
  )
16
- from glide.constants import (
16
+ from glide_shared.constants import (
17
17
  TOK,
18
18
  TEncodable,
19
19
  TFunctionListResponse,
20
20
  TFunctionStatsFullResponse,
21
21
  TResult,
22
22
  )
23
- from glide.protobuf.command_request_pb2 import RequestType
23
+ from glide_shared.protobuf.command_request_pb2 import RequestType
24
24
 
25
- from ..glide import Script
25
+ from .core import CoreCommands
26
26
 
27
27
 
28
28
  class StandaloneCommands(CoreCommands):
@@ -871,8 +871,6 @@ class StandaloneCommands(CoreCommands):
871
871
  TOK: A simple "OK" response.
872
872
 
873
873
  Examples:
874
- >>> await client.watch("sampleKey")
875
- 'OK'
876
874
  >>> await client.unwatch()
877
875
  'OK'
878
876
  """
@@ -1036,7 +1034,7 @@ class StandaloneCommands(CoreCommands):
1036
1034
 
1037
1035
  Examples:
1038
1036
  >>> lua_script = Script("return { KEYS[1], ARGV[1] }")
1039
- >>> await client.invoke_script(lua_script, keys=["foo"], args=["bar"] );
1037
+ >>> await client.invoke_script(lua_script, keys=["foo"], args=["bar"])
1040
1038
  [b"foo", b"bar"]
1041
1039
  """
1042
1040
  return await self._execute_script(script.get_hash(), keys, args)
Binary file
glide/glide.pyi CHANGED
@@ -2,7 +2,7 @@ from collections.abc import Callable
2
2
  from enum import Enum
3
3
  from typing import List, Optional, Union
4
4
 
5
- from glide.constants import TResult
5
+ from glide_shared.constants import TResult
6
6
 
7
7
  DEFAULT_TIMEOUT_IN_MILLISECONDS: int = ...
8
8
  MAX_REQUEST_ARGS_LEN: int = ...
glide/glide_client.py CHANGED
@@ -11,7 +11,6 @@ from typing import (
11
11
  Optional,
12
12
  Set,
13
13
  Tuple,
14
- Type,
15
14
  Union,
16
15
  cast,
17
16
  )
@@ -19,31 +18,7 @@ from typing import (
19
18
  import anyio
20
19
  import sniffio
21
20
  from anyio import to_thread
22
-
23
- from glide.async_commands.cluster_commands import ClusterCommands
24
- from glide.async_commands.command_args import ObjectType
25
- from glide.async_commands.core import CoreCommands
26
- from glide.async_commands.standalone_commands import StandaloneCommands
27
- from glide.config import BaseClientConfiguration, ServerCredentials
28
- from glide.constants import DEFAULT_READ_BYTES_SIZE, OK, TEncodable, TRequest, TResult
29
- from glide.exceptions import (
30
- ClosingError,
31
- ConfigurationError,
32
- ConnectionError,
33
- ExecAbortError,
34
- RequestError,
35
- TimeoutError,
36
- )
37
- from glide.logger import Level as LogLevel
38
- from glide.logger import Logger as ClientLogger
39
- from glide.opentelemetry import OpenTelemetry
40
- from glide.protobuf.command_request_pb2 import Command, CommandRequest, RequestType
41
- from glide.protobuf.connection_request_pb2 import ConnectionRequest
42
- from glide.protobuf.response_pb2 import RequestErrorType, Response
43
- from glide.protobuf_codec import PartialMessageException, ProtobufCodec
44
- from glide.routes import Route, set_protobuf_route
45
-
46
- from .glide import (
21
+ from glide.glide import (
47
22
  DEFAULT_TIMEOUT_IN_MILLISECONDS,
48
23
  MAX_REQUEST_ARGS_LEN,
49
24
  ClusterScanCursor,
@@ -54,6 +29,38 @@ from .glide import (
54
29
  start_socket_listener_external,
55
30
  value_from_pointer,
56
31
  )
32
+ from glide_shared.commands.command_args import ObjectType
33
+ from glide_shared.commands.core_options import PubSubMsg
34
+ from glide_shared.config import BaseClientConfiguration, ServerCredentials
35
+ from glide_shared.constants import (
36
+ DEFAULT_READ_BYTES_SIZE,
37
+ OK,
38
+ TEncodable,
39
+ TRequest,
40
+ TResult,
41
+ )
42
+ from glide_shared.exceptions import (
43
+ ClosingError,
44
+ ConfigurationError,
45
+ ConnectionError,
46
+ get_request_error_class,
47
+ )
48
+ from glide_shared.protobuf.command_request_pb2 import (
49
+ Command,
50
+ CommandRequest,
51
+ RequestType,
52
+ )
53
+ from glide_shared.protobuf.connection_request_pb2 import ConnectionRequest
54
+ from glide_shared.protobuf.response_pb2 import Response
55
+ from glide_shared.protobuf_codec import PartialMessageException, ProtobufCodec
56
+ from glide_shared.routes import Route, set_protobuf_route
57
+
58
+ from .async_commands.cluster_commands import ClusterCommands
59
+ from .async_commands.core import CoreCommands
60
+ from .async_commands.standalone_commands import StandaloneCommands
61
+ from .logger import Level as LogLevel
62
+ from .logger import Logger as ClientLogger
63
+ from .opentelemetry import OpenTelemetry
57
64
 
58
65
  if sys.version_info >= (3, 11):
59
66
  from typing import Self
@@ -69,20 +76,6 @@ if TYPE_CHECKING:
69
76
  TFuture = Union[asyncio.Future[Any], "_CompatFuture"]
70
77
 
71
78
 
72
- def get_request_error_class(
73
- error_type: Optional[RequestErrorType.ValueType],
74
- ) -> Type[RequestError]:
75
- if error_type == RequestErrorType.Disconnect:
76
- return ConnectionError
77
- if error_type == RequestErrorType.ExecAbort:
78
- return ExecAbortError
79
- if error_type == RequestErrorType.Timeout:
80
- return TimeoutError
81
- if error_type == RequestErrorType.Unspecified:
82
- return RequestError
83
- return RequestError
84
-
85
-
86
79
  class _CompatFuture:
87
80
  """anyio shim for asyncio.Future-like functionality"""
88
81
 
@@ -524,7 +517,7 @@ class BaseClient(CoreCommands):
524
517
  set_protobuf_route(request, route)
525
518
  return await self._write_request_await_response(request)
526
519
 
527
- async def get_pubsub_message(self) -> CoreCommands.PubSubMsg:
520
+ async def get_pubsub_message(self) -> PubSubMsg:
528
521
  if self._is_closed:
529
522
  raise ClosingError(
530
523
  "Unable to execute requests; the client is closed. Please create a new client."
@@ -551,7 +544,7 @@ class BaseClient(CoreCommands):
551
544
  await response_future
552
545
  return response_future.result()
553
546
 
554
- def try_get_pubsub_message(self) -> Optional[CoreCommands.PubSubMsg]:
547
+ def try_get_pubsub_message(self) -> Optional[PubSubMsg]:
555
548
  if self._is_closed:
556
549
  raise ClosingError(
557
550
  "Unable to execute requests; the client is closed. Please create a new client."
@@ -568,7 +561,7 @@ class BaseClient(CoreCommands):
568
561
  )
569
562
 
570
563
  # locking might not be required
571
- msg: Optional[CoreCommands.PubSubMsg] = None
564
+ msg: Optional[PubSubMsg] = None
572
565
  try:
573
566
  self._pubsub_lock.acquire()
574
567
  self._complete_pubsub_futures_safe()
@@ -586,7 +579,7 @@ class BaseClient(CoreCommands):
586
579
 
587
580
  def _notification_to_pubsub_message_safe(
588
581
  self, response: Response
589
- ) -> Optional[CoreCommands.PubSubMsg]:
582
+ ) -> Optional[PubSubMsg]:
590
583
  pubsub_message = None
591
584
  push_notification = cast(
592
585
  Dict[str, Any], value_from_pointer(response.resp_pointer)
@@ -605,11 +598,11 @@ class BaseClient(CoreCommands):
605
598
  ):
606
599
  values: List = push_notification["values"]
607
600
  if message_kind == "PMessage":
608
- pubsub_message = BaseClient.PubSubMsg(
601
+ pubsub_message = PubSubMsg(
609
602
  message=values[2], channel=values[1], pattern=values[0]
610
603
  )
611
604
  else:
612
- pubsub_message = BaseClient.PubSubMsg(
605
+ pubsub_message = PubSubMsg(
613
606
  message=values[1], channel=values[0], pattern=None
614
607
  )
615
608
  elif (
glide/logger.py CHANGED
@@ -6,8 +6,8 @@ import traceback
6
6
  from enum import Enum
7
7
  from typing import Optional
8
8
 
9
- from .glide import Level as internalLevel
10
- from .glide import py_init, py_log
9
+ from glide.glide import Level as internalLevel
10
+ from glide.glide import py_init, py_log
11
11
 
12
12
 
13
13
  class Level(Enum):
@@ -40,7 +40,7 @@ class Logger:
40
40
  def init(cls, level: Optional[Level] = None, file_name: Optional[str] = None):
41
41
  """
42
42
  Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to
43
- replace an existing logger.
43
+ replace an existing logger. Otherwise, use `set_logger_config` for overriding the existing logger configs.
44
44
  The logger will filter all logs with a level lower than the given level.
45
45
  If given a file_name argument, will write the logs to files postfixed with file_name. If file_name isn't provided,
46
46
  the logs will be written to the console.
glide/opentelemetry.py CHANGED
@@ -37,10 +37,14 @@ If you need to change configuration, restart the process with new settings.
37
37
  import random
38
38
  from typing import Optional
39
39
 
40
- from glide.exceptions import ConfigurationError
41
- from glide.logger import Level, Logger
42
-
43
- from .glide import OpenTelemetryConfig, OpenTelemetryTracesConfig, init_opentelemetry
40
+ from glide.glide import (
41
+ OpenTelemetryConfig,
42
+ OpenTelemetryTracesConfig,
43
+ init_opentelemetry,
44
+ )
45
+ from glide_shared.exceptions import ConfigurationError
46
+
47
+ from .logger import Level, Logger
44
48
 
45
49
 
46
50
  class OpenTelemetry: