valkey-glide 1.3.5__cp39-cp39-macosx_11_0_arm64.whl → 2.2.2__cp39-cp39-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.
Files changed (47) hide show
  1. glide/__init__.py +165 -107
  2. glide/async_commands/cluster_commands.py +318 -136
  3. glide/async_commands/core.py +1770 -992
  4. glide/async_commands/{server_modules/ft.py → ft.py} +91 -21
  5. glide/async_commands/{server_modules/glide_json.py → glide_json.py} +148 -134
  6. glide/async_commands/standalone_commands.py +203 -137
  7. glide/glide.cpython-39-darwin.so +0 -0
  8. glide/glide.pyi +26 -1
  9. glide/glide_client.py +352 -135
  10. glide/logger.py +34 -22
  11. glide/opentelemetry.py +185 -0
  12. glide_shared/__init__.py +330 -0
  13. glide_shared/commands/__init__.py +0 -0
  14. glide/async_commands/transaction.py → glide_shared/commands/batch.py +1839 -1017
  15. glide_shared/commands/batch_options.py +261 -0
  16. {glide/async_commands → glide_shared/commands}/bitmap.py +94 -85
  17. {glide/async_commands → glide_shared/commands}/command_args.py +7 -6
  18. glide_shared/commands/core_options.py +407 -0
  19. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_aggregate_options.py +18 -11
  20. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_create_options.py +27 -13
  21. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_profile_options.py +16 -11
  22. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_search_options.py +16 -8
  23. {glide/async_commands → glide_shared/commands}/server_modules/json_batch.py +160 -130
  24. glide_shared/commands/server_modules/json_options.py +93 -0
  25. {glide/async_commands → glide_shared/commands}/sorted_set.py +41 -31
  26. {glide/async_commands → glide_shared/commands}/stream.py +95 -88
  27. glide_shared/config.py +975 -0
  28. {glide → glide_shared}/constants.py +11 -7
  29. {glide → glide_shared}/exceptions.py +27 -1
  30. glide_shared/protobuf/command_request_pb2.py +56 -0
  31. glide_shared/protobuf/connection_request_pb2.py +56 -0
  32. {glide → glide_shared}/protobuf/response_pb2.py +6 -6
  33. {glide → glide_shared}/protobuf_codec.py +7 -6
  34. glide_shared/routes.py +161 -0
  35. valkey_glide-2.2.2.dist-info/METADATA +211 -0
  36. valkey_glide-2.2.2.dist-info/RECORD +40 -0
  37. glide/config.py +0 -590
  38. glide/protobuf/command_request_pb2.py +0 -54
  39. glide/protobuf/command_request_pb2.pyi +0 -1164
  40. glide/protobuf/connection_request_pb2.py +0 -52
  41. glide/protobuf/connection_request_pb2.pyi +0 -292
  42. glide/protobuf/response_pb2.pyi +0 -101
  43. glide/routes.py +0 -114
  44. valkey_glide-1.3.5.dist-info/METADATA +0 -125
  45. valkey_glide-1.3.5.dist-info/RECORD +0 -37
  46. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
  47. {valkey_glide-1.3.5.dist-info → valkey_glide-2.2.2.dist-info}/WHEEL +0 -0
@@ -0,0 +1,407 @@
1
+ # Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
2
+ from dataclasses import dataclass
3
+ from datetime import datetime, timedelta
4
+ from enum import Enum
5
+ from typing import List, Optional, Type, Union, get_args
6
+
7
+ from glide_shared.commands.command_args import Limit, OrderBy
8
+ from glide_shared.constants import TEncodable
9
+
10
+
11
+ @dataclass
12
+ class PubSubMsg:
13
+ """
14
+ Describes the incoming pubsub message
15
+
16
+ Attributes:
17
+ message (TEncodable): Incoming message.
18
+ channel (TEncodable): Name of an channel that triggered the message.
19
+ pattern (Optional[TEncodable]): Pattern that triggered the message.
20
+ """
21
+
22
+ message: TEncodable
23
+ channel: TEncodable
24
+ pattern: Optional[TEncodable]
25
+
26
+
27
+ class ConditionalChange(Enum):
28
+ """
29
+ A condition to the `SET`, `ZADD` and `GEOADD` commands.
30
+ """
31
+
32
+ ONLY_IF_EXISTS = "XX"
33
+ """ Only update key / elements that already exist. Equivalent to `XX` in the Valkey API. """
34
+
35
+ ONLY_IF_DOES_NOT_EXIST = "NX"
36
+ """ Only set key / add elements that does not already exist. Equivalent to `NX` in the Valkey API. """
37
+
38
+
39
+ class HashFieldConditionalChange(Enum):
40
+ """
41
+ Field conditional change options for HSETEX command.
42
+ """
43
+
44
+ ONLY_IF_ALL_EXIST = "FXX"
45
+ """ Only set fields if all of them already exist. Equivalent to `FXX` in the Valkey API. """
46
+
47
+ ONLY_IF_NONE_EXIST = "FNX"
48
+ """ Only set fields if none of them already exist. Equivalent to `FNX` in the Valkey API. """
49
+
50
+
51
+ @dataclass
52
+ class OnlyIfEqual:
53
+ """
54
+ Change condition to the `SET` command,
55
+ For additional conditonal options see ConditionalChange
56
+
57
+ - comparison_value - value to compare to the current value of a key.
58
+
59
+ If comparison_value is equal to the key, it will overwrite the value of key to the new provided value
60
+ Equivalent to the IFEQ comparison-value in the Valkey API
61
+ """
62
+
63
+ comparison_value: TEncodable
64
+
65
+
66
+ class ExpiryType(Enum):
67
+ """
68
+ SET option: The type of the expiry.
69
+ """
70
+
71
+ SEC = 0, Union[int, timedelta]
72
+ """
73
+ Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API.
74
+ """
75
+
76
+ MILLSEC = 1, Union[int, timedelta]
77
+ """
78
+ Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API.
79
+ """
80
+
81
+ UNIX_SEC = 2, Union[int, datetime]
82
+ """
83
+ Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API.
84
+ """
85
+
86
+ UNIX_MILLSEC = 3, Union[int, datetime]
87
+ """
88
+ Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the Valkey API.
89
+ """
90
+
91
+ KEEP_TTL = 4, Type[None]
92
+ """
93
+ Retain the time to live associated with the key. Equivalent to `KEEPTTL` in the Valkey API.
94
+ """
95
+
96
+
97
+ class ExpiryTypeGetEx(Enum):
98
+ """
99
+ GetEx option: The type of the expiry.
100
+ """
101
+
102
+ SEC = 0, Union[int, timedelta]
103
+ """ Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API. """
104
+
105
+ MILLSEC = 1, Union[int, timedelta]
106
+ """ Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API. """
107
+
108
+ UNIX_SEC = 2, Union[int, datetime]
109
+ """ Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API. """
110
+
111
+ UNIX_MILLSEC = 3, Union[int, datetime]
112
+ """ Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the Valkey API. """
113
+
114
+ PERSIST = 4, Type[None]
115
+ """ Remove the time to live associated with the key. Equivalent to `PERSIST` in the Valkey API. """
116
+
117
+
118
+ class InfoSection(Enum):
119
+ """
120
+ INFO option: a specific section of information:
121
+
122
+ When no parameter is provided, the default option is assumed.
123
+ """
124
+
125
+ SERVER = "server"
126
+ """ General information about the server """
127
+
128
+ CLIENTS = "clients"
129
+ """ Client connections section """
130
+
131
+ MEMORY = "memory"
132
+ """ Memory consumption related information """
133
+
134
+ PERSISTENCE = "persistence"
135
+ """ RDB and AOF related information """
136
+
137
+ STATS = "stats"
138
+ """ General statistics """
139
+
140
+ REPLICATION = "replication"
141
+ """ Master/replica replication information """
142
+
143
+ CPU = "cpu"
144
+ """ CPU consumption statistics """
145
+
146
+ COMMAND_STATS = "commandstats"
147
+ """ Valkey command statistics """
148
+
149
+ LATENCY_STATS = "latencystats"
150
+ """ Valkey command latency percentile distribution statistics """
151
+
152
+ SENTINEL = "sentinel"
153
+ """ Valkey Sentinel section (only applicable to Sentinel instances) """
154
+
155
+ CLUSTER = "cluster"
156
+ """ Valkey Cluster section """
157
+
158
+ MODULES = "modules"
159
+ """ Modules section """
160
+
161
+ KEYSPACE = "keyspace"
162
+ """ Database related statistics """
163
+
164
+ ERROR_STATS = "errorstats"
165
+ """ Valkey error statistics """
166
+
167
+ ALL = "all"
168
+ """ Return all sections (excluding module generated ones) """
169
+
170
+ DEFAULT = "default"
171
+ """ Return only the default set of sections """
172
+
173
+ EVERYTHING = "everything"
174
+ """ Includes all and modules """
175
+
176
+
177
+ class ExpireOptions(Enum):
178
+ """
179
+ EXPIRE option: options for setting key expiry.
180
+ """
181
+
182
+ HasNoExpiry = "NX"
183
+ """ Set expiry only when the key has no expiry (Equivalent to "NX" in Valkey). """
184
+
185
+ HasExistingExpiry = "XX"
186
+ """ Set expiry only when the key has an existing expiry (Equivalent to "XX" in Valkey). """
187
+
188
+ NewExpiryGreaterThanCurrent = "GT"
189
+ """
190
+ Set expiry only when the new expiry is greater than the current one (Equivalent to "GT" in Valkey).
191
+ """
192
+
193
+ NewExpiryLessThanCurrent = "LT"
194
+ """
195
+ Set expiry only when the new expiry is less than the current one (Equivalent to "LT" in Valkey).
196
+ """
197
+
198
+
199
+ class UpdateOptions(Enum):
200
+ """
201
+ Options for updating elements of a sorted set key.
202
+ """
203
+
204
+ LESS_THAN = "LT"
205
+ """ Only update existing elements if the new score is less than the current score. """
206
+
207
+ GREATER_THAN = "GT"
208
+ """ Only update existing elements if the new score is greater than the current score. """
209
+
210
+
211
+ class ExpirySet:
212
+ """
213
+ SET option: Represents the expiry type and value to be executed with "SET" command.
214
+
215
+ Attributes:
216
+ cmd_arg (str): The expiry type.
217
+ value (str): The value for the expiry type.
218
+ """
219
+
220
+ def __init__(
221
+ self,
222
+ expiry_type: ExpiryType,
223
+ value: Optional[Union[int, datetime, timedelta]],
224
+ ) -> None:
225
+ self.set_expiry_type_and_value(expiry_type, value)
226
+
227
+ def __eq__(self, other: "object") -> bool:
228
+ if not isinstance(other, ExpirySet):
229
+ return NotImplemented
230
+ return self.expiry_type == other.expiry_type and self.value == other.value
231
+
232
+ def set_expiry_type_and_value(
233
+ self, expiry_type: ExpiryType, value: Optional[Union[int, datetime, timedelta]]
234
+ ):
235
+ """
236
+ Args:
237
+ expiry_type (ExpiryType): The expiry type.
238
+ value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
239
+ determines the type of expiration value:
240
+
241
+ - SEC: Union[int, timedelta]
242
+ - MILLSEC: Union[int, timedelta]
243
+ - UNIX_SEC: Union[int, datetime]
244
+ - UNIX_MILLSEC: Union[int, datetime]
245
+ - KEEP_TTL: Type[None]
246
+ """
247
+ if not isinstance(value, get_args(expiry_type.value[1])):
248
+ raise ValueError(
249
+ f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
250
+ )
251
+ self.expiry_type = expiry_type
252
+ if self.expiry_type == ExpiryType.SEC:
253
+ self.cmd_arg = "EX"
254
+ if isinstance(value, timedelta):
255
+ value = int(value.total_seconds())
256
+ elif self.expiry_type == ExpiryType.MILLSEC:
257
+ self.cmd_arg = "PX"
258
+ if isinstance(value, timedelta):
259
+ value = int(value.total_seconds() * 1000)
260
+ elif self.expiry_type == ExpiryType.UNIX_SEC:
261
+ self.cmd_arg = "EXAT"
262
+ if isinstance(value, datetime):
263
+ value = int(value.timestamp())
264
+ elif self.expiry_type == ExpiryType.UNIX_MILLSEC:
265
+ self.cmd_arg = "PXAT"
266
+ if isinstance(value, datetime):
267
+ value = int(value.timestamp() * 1000)
268
+ elif self.expiry_type == ExpiryType.KEEP_TTL:
269
+ self.cmd_arg = "KEEPTTL"
270
+ self.value = str(value) if value else None
271
+
272
+ def get_cmd_args(self) -> List[str]:
273
+ return [self.cmd_arg] if self.value is None else [self.cmd_arg, self.value]
274
+
275
+
276
+ class ExpiryGetEx:
277
+ """
278
+ GetEx option: Represents the expiry type and value to be executed with "GetEx" command.
279
+
280
+ Attributes:
281
+ cmd_arg (str): The expiry type.
282
+ value (str): The value for the expiry type.
283
+ """
284
+
285
+ def __init__(
286
+ self,
287
+ expiry_type: ExpiryTypeGetEx,
288
+ value: Optional[Union[int, datetime, timedelta]],
289
+ ) -> None:
290
+ self.set_expiry_type_and_value(expiry_type, value)
291
+
292
+ def set_expiry_type_and_value(
293
+ self,
294
+ expiry_type: ExpiryTypeGetEx,
295
+ value: Optional[Union[int, datetime, timedelta]],
296
+ ):
297
+ """
298
+ Args:
299
+ expiry_type (ExpiryType): The expiry type.
300
+ value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
301
+ determines the type of expiration value:
302
+
303
+ - SEC: Union[int, timedelta]
304
+ - MILLSEC: Union[int, timedelta]
305
+ - UNIX_SEC: Union[int, datetime]
306
+ - UNIX_MILLSEC: Union[int, datetime]
307
+ - PERSIST: Type[None]
308
+ """
309
+ if not isinstance(value, get_args(expiry_type.value[1])):
310
+ raise ValueError(
311
+ f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
312
+ )
313
+ self.expiry_type = expiry_type
314
+ if self.expiry_type == ExpiryTypeGetEx.SEC:
315
+ self.cmd_arg = "EX"
316
+ if isinstance(value, timedelta):
317
+ value = int(value.total_seconds())
318
+ elif self.expiry_type == ExpiryTypeGetEx.MILLSEC:
319
+ self.cmd_arg = "PX"
320
+ if isinstance(value, timedelta):
321
+ value = int(value.total_seconds() * 1000)
322
+ elif self.expiry_type == ExpiryTypeGetEx.UNIX_SEC:
323
+ self.cmd_arg = "EXAT"
324
+ if isinstance(value, datetime):
325
+ value = int(value.timestamp())
326
+ elif self.expiry_type == ExpiryTypeGetEx.UNIX_MILLSEC:
327
+ self.cmd_arg = "PXAT"
328
+ if isinstance(value, datetime):
329
+ value = int(value.timestamp() * 1000)
330
+ elif self.expiry_type == ExpiryTypeGetEx.PERSIST:
331
+ self.cmd_arg = "PERSIST"
332
+ self.value = str(value) if value else None
333
+
334
+ def get_cmd_args(self) -> List[str]:
335
+ return [self.cmd_arg] if self.value is None else [self.cmd_arg, self.value]
336
+
337
+
338
+ class InsertPosition(Enum):
339
+ BEFORE = "BEFORE"
340
+ AFTER = "AFTER"
341
+
342
+
343
+ class FlushMode(Enum):
344
+ """
345
+ Defines flushing mode for:
346
+
347
+ `FLUSHALL` command and `FUNCTION FLUSH` command.
348
+
349
+ See [FLUSHAL](https://valkey.io/commands/flushall/) and [FUNCTION-FLUSH](https://valkey.io/commands/function-flush/)
350
+ for details
351
+
352
+ SYNC was introduced in version 6.2.0.
353
+ """
354
+
355
+ ASYNC = "ASYNC"
356
+ SYNC = "SYNC"
357
+
358
+
359
+ class FunctionRestorePolicy(Enum):
360
+ """
361
+ Options for the FUNCTION RESTORE command.
362
+ """
363
+
364
+ APPEND = "APPEND"
365
+ """ Appends the restored libraries to the existing libraries and aborts on collision. This is the default policy. """
366
+
367
+ FLUSH = "FLUSH"
368
+ """ Deletes all existing libraries before restoring the payload. """
369
+
370
+ REPLACE = "REPLACE"
371
+ """
372
+ Appends the restored libraries to the existing libraries, replacing any existing ones in case
373
+ of name collisions. Note that this policy doesn't prevent function name collisions, only libraries.
374
+ """
375
+
376
+
377
+ def _build_sort_args(
378
+ key: TEncodable,
379
+ by_pattern: Optional[TEncodable] = None,
380
+ limit: Optional[Limit] = None,
381
+ get_patterns: Optional[List[TEncodable]] = None,
382
+ order: Optional[OrderBy] = None,
383
+ alpha: Optional[bool] = None,
384
+ store: Optional[TEncodable] = None,
385
+ ) -> List[TEncodable]:
386
+ args = [key]
387
+
388
+ if by_pattern:
389
+ args.extend(["BY", by_pattern])
390
+
391
+ if limit:
392
+ args.extend(["LIMIT", str(limit.offset), str(limit.count)])
393
+
394
+ if get_patterns:
395
+ for pattern in get_patterns:
396
+ args.extend(["GET", pattern])
397
+
398
+ if order:
399
+ args.append(order.value)
400
+
401
+ if alpha:
402
+ args.append("ALPHA")
403
+
404
+ if store:
405
+ args.extend(["STORE", store])
406
+
407
+ return args
@@ -1,13 +1,12 @@
1
1
  # Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
2
2
  from abc import ABC, abstractmethod
3
- from enum import Enum
4
3
  from typing import List, Mapping, Optional
5
4
 
6
- from glide.async_commands.command_args import OrderBy
7
- from glide.async_commands.server_modules.ft_options.ft_constants import (
5
+ from glide_shared.commands.command_args import OrderBy
6
+ from glide_shared.commands.server_modules.ft_options.ft_constants import (
8
7
  FtAggregateKeywords,
9
8
  )
10
- from glide.constants import TEncodable
9
+ from glide_shared.constants import TEncodable
11
10
 
12
11
 
13
12
  class FtAggregateClause(ABC):
@@ -55,7 +54,8 @@ class FtAggregateLimit(FtAggregateClause):
55
54
 
56
55
  class FtAggregateFilter(FtAggregateClause):
57
56
  """
58
- A clause for filtering the results using predicate expression relating to values in each result. It is applied post query and relate to the current state of the pipeline.
57
+ A clause for filtering the results using predicate expression relating to values in each result. It is applied post query
58
+ and relate to the current state of the pipeline.
59
59
  """
60
60
 
61
61
  def __init__(self, expression: TEncodable):
@@ -79,7 +79,8 @@ class FtAggregateFilter(FtAggregateClause):
79
79
 
80
80
  class FtAggregateReducer:
81
81
  """
82
- A clause for reducing the matching results in each group using a reduction function. The matching results are reduced into a single record.
82
+ A clause for reducing the matching results in each group using a reduction function. The matching results are reduced into
83
+ a single record.
83
84
  """
84
85
 
85
86
  def __init__(
@@ -130,7 +131,8 @@ class FtAggregateGroupBy(FtAggregateClause):
130
131
 
131
132
  Args:
132
133
  properties (List[TEncodable]): The list of properties to be used for grouping the results in the pipeline.
133
- reducers (List[Reducer]): The list of functions that handles the group entries by performing multiple aggregate operations.
134
+ reducers (List[Reducer]): The list of functions that handles the group entries by performing multiple
135
+ aggregate operations.
134
136
  """
135
137
  self.properties = properties
136
138
  self.reducers = reducers
@@ -210,7 +212,8 @@ class FtAggregateSortBy(FtAggregateClause):
210
212
 
211
213
  class FtAggregateApply(FtAggregateClause):
212
214
  """
213
- A clause for applying a 1-to-1 transformation on one or more properties and stores the result as a new property down the pipeline or replaces any property using this transformation.
215
+ A clause for applying a 1-to-1 transformation on one or more properties and stores the result as a new property down the
216
+ pipeline or replaces any property using this transformation.
214
217
  """
215
218
 
216
219
  def __init__(self, expression: TEncodable, name: TEncodable):
@@ -219,7 +222,8 @@ class FtAggregateApply(FtAggregateClause):
219
222
 
220
223
  Args:
221
224
  expression (TEncodable): The expression to be transformed.
222
- name (TEncodable): The new property name to store the result of apply. This name can be referenced by further APPLY/SORTBY/GROUPBY/REDUCE operations down the pipeline.
225
+ name (TEncodable): The new property name to store the result of apply. This name can be referenced by further
226
+ APPLY/SORTBY/GROUPBY/REDUCE operations down the pipeline.
223
227
  """
224
228
  self.expression = expression
225
229
  self.name = name
@@ -259,8 +263,11 @@ class FtAggregateOptions:
259
263
  loadAll (Optional[bool]): An option to load all fields declared in the index.
260
264
  loadFields (Optional[List[TEncodable]]): An option to load only the fields passed in this list.
261
265
  timeout (Optional[int]): Overrides the timeout parameter of the module.
262
- params (Optional[Mapping[TEncodable, TEncodable]]): The key/value pairs can be referenced from within the query expression.
263
- clauses (Optional[List[FtAggregateClause]]): FILTER, LIMIT, GROUPBY, SORTBY and APPLY clauses, that can be repeated multiple times in any order and be freely intermixed. They are applied in the order specified, with the output of one clause feeding the input of the next clause.
266
+ params (Optional[Mapping[TEncodable, TEncodable]]): The key/value pairs can be referenced from within the
267
+ query expression.
268
+ clauses (Optional[List[FtAggregateClause]]): FILTER, LIMIT, GROUPBY, SORTBY and APPLY clauses, that can be
269
+ repeated multiple times in any order and be freely intermixed. They are applied in the order specified, with
270
+ the output of one clause feeding the input of the next clause.
264
271
  """
265
272
  self.loadAll = loadAll
266
273
  self.loadFields = loadFields
@@ -3,8 +3,10 @@ from abc import ABC, abstractmethod
3
3
  from enum import Enum
4
4
  from typing import List, Optional
5
5
 
6
- from glide.async_commands.server_modules.ft_options.ft_constants import FtCreateKeywords
7
- from glide.constants import TEncodable
6
+ from glide_shared.commands.server_modules.ft_options.ft_constants import (
7
+ FtCreateKeywords,
8
+ )
9
+ from glide_shared.constants import TEncodable
8
10
 
9
11
 
10
12
  class FieldType(Enum):
@@ -159,8 +161,10 @@ class TagField(Field):
159
161
  Args:
160
162
  name (TEncodable): The name of the tag field.
161
163
  alias (Optional[TEncodable]): An alias for the field.
162
- separator (Optional[TEncodable]): Specify how text in the attribute is split into individual tags. Must be a single character.
163
- case_sensitive (bool): Preserve the original letter cases of tags. If set to False, characters are converted to lowercase by default.
164
+ separator (Optional[TEncodable]): Specify how text in the attribute is split into individual tags. Must be a
165
+ single character.
166
+ case_sensitive (bool): Preserve the original letter cases of tags. If set to False, characters are converted to
167
+ lowercase by default.
164
168
  """
165
169
  super().__init__(name, FieldType.TAG, alias)
166
170
  self.separator = separator
@@ -209,7 +213,8 @@ class VectorFieldAttributes(ABC):
209
213
 
210
214
  Args:
211
215
  dimensions (int): Number of dimensions in the vector. Equivalent to `DIM` on the module API.
212
- distance_metric (DistanceMetricType): The distance metric used in vector type field. Can be one of `[L2 | IP | COSINE]`. Equivalent to `DISTANCE_METRIC` on the module API.
216
+ distance_metric (DistanceMetricType): The distance metric used in vector type field. Can be one of
217
+ `[L2 | IP | COSINE]`. Equivalent to `DISTANCE_METRIC` on the module API.
213
218
  type (VectorType): Vector type. The only supported type is `FLOAT32`. Equivalent to `TYPE` on the module API.
214
219
  """
215
220
  self.dimensions = dimensions
@@ -251,9 +256,11 @@ class VectorFieldAttributesFlat(VectorFieldAttributes):
251
256
 
252
257
  Args:
253
258
  dimensions (int): Number of dimensions in the vector. Equivalent to `DIM` on the module API.
254
- distance_metric (DistanceMetricType): The distance metric used in vector type field. Can be one of `[L2 | IP | COSINE]`. Equivalent to `DISTANCE_METRIC` on the module API.
259
+ distance_metric (DistanceMetricType): The distance metric used in vector type field. Can be one of
260
+ `[L2 | IP | COSINE]`. Equivalent to `DISTANCE_METRIC` on the module API.
255
261
  type (VectorType): Vector type. The only supported type is `FLOAT32`. Equivalent to `TYPE` on the module API.
256
- initial_cap (Optional[int]): Initial vector capacity in the index affecting memory allocation size of the index. Defaults to `1024`. Equivalent to `INITIAL_CAP` on the module API.
262
+ initial_cap (Optional[int]): Initial vector capacity in the index affecting memory allocation size of the index.
263
+ Defaults to `1024`. Equivalent to `INITIAL_CAP` on the module API.
257
264
  """
258
265
  super().__init__(dimensions, distance_metric, type)
259
266
  self.initial_cap = initial_cap
@@ -285,12 +292,18 @@ class VectorFieldAttributesHnsw(VectorFieldAttributes):
285
292
 
286
293
  Args:
287
294
  dimensions (int): Number of dimensions in the vector. Equivalent to `DIM` on the module API.
288
- distance_metric (DistanceMetricType): The distance metric used in vector type field. Can be one of `[L2 | IP | COSINE]`. Equivalent to `DISTANCE_METRIC` on the module API.
295
+ distance_metric (DistanceMetricType): The distance metric used in vector type field. Can be one of
296
+ `[L2 | IP | COSINE]`. Equivalent to `DISTANCE_METRIC` on the module API.
289
297
  type (VectorType): Vector type. The only supported type is `FLOAT32`. Equivalent to `TYPE` on the module API.
290
- initial_cap (Optional[int]): Initial vector capacity in the index affecting memory allocation size of the index. Defaults to `1024`. Equivalent to `INITIAL_CAP` on the module API.
291
- number_of_edges (Optional[int]): Number of maximum allowed outgoing edges for each node in the graph in each layer. Default is `16`, maximum is `512`. Equivalent to `M` on the module API.
292
- vectors_examined_on_construction (Optional[int]): Controls the number of vectors examined during index construction. Default value is `200`, Maximum value is `4096`. Equivalent to `EF_CONSTRUCTION` on the module API.
293
- vectors_examined_on_runtime (Optional[int]): Controls the number of vectors examined during query operations. Default value is `10`, Maximum value is `4096`. Equivalent to `EF_RUNTIME` on the module API.
298
+ initial_cap (Optional[int]): Initial vector capacity in the index affecting memory allocation size of the index.
299
+ Defaults to `1024`. Equivalent to `INITIAL_CAP` on the module API.
300
+ number_of_edges (Optional[int]): Number of maximum allowed outgoing edges for each node in the graph in each layer.
301
+ Default is `16`, maximum is `512`. Equivalent to `M` on the module API.
302
+ vectors_examined_on_construction (Optional[int]): Controls the number of vectors examined during index
303
+ construction. Default value is `200`, Maximum value is `4096`. Equivalent to `EF_CONSTRUCTION` on the
304
+ module API.
305
+ vectors_examined_on_runtime (Optional[int]): Controls the number of vectors examined during query operations.
306
+ Default value is `10`, Maximum value is `4096`. Equivalent to `EF_RUNTIME` on the module API.
294
307
  """
295
308
  super().__init__(dimensions, distance_metric, type)
296
309
  self.initial_cap = initial_cap
@@ -337,7 +350,8 @@ class VectorField(Field):
337
350
  name (TEncodable): The name of the vector field.
338
351
  algorithm (VectorAlgorithm): The vector indexing algorithm.
339
352
  alias (Optional[TEncodable]): An alias for the field.
340
- attributes (VectorFieldAttributes): Additional attributes to be passed with the vector field after the algorithm name.
353
+ attributes (VectorFieldAttributes): Additional attributes to be passed with the vector field after the
354
+ algorithm name.
341
355
  """
342
356
  super().__init__(name, FieldType.VECTOR, alias)
343
357
  self.algorithm = algorithm
@@ -2,16 +2,16 @@
2
2
  from enum import Enum
3
3
  from typing import List, Optional, Union, cast
4
4
 
5
- from glide.async_commands.server_modules.ft_options.ft_aggregate_options import (
5
+ from glide_shared.commands.server_modules.ft_options.ft_aggregate_options import (
6
6
  FtAggregateOptions,
7
7
  )
8
- from glide.async_commands.server_modules.ft_options.ft_constants import (
8
+ from glide_shared.commands.server_modules.ft_options.ft_constants import (
9
9
  FtProfileKeywords,
10
10
  )
11
- from glide.async_commands.server_modules.ft_options.ft_search_options import (
11
+ from glide_shared.commands.server_modules.ft_options.ft_search_options import (
12
12
  FtSearchOptions,
13
13
  )
14
- from glide.constants import TEncodable
14
+ from glide_shared.constants import TEncodable
15
15
 
16
16
 
17
17
  class QueryType(Enum):
@@ -45,9 +45,11 @@ class FtProfileOptions:
45
45
  Initialize a new FtProfileOptions instance.
46
46
 
47
47
  Args:
48
- query (TEncodable): The query that is being profiled. This is the query argument from the FT.AGGREGATE/FT.SEARCH command.
48
+ query (TEncodable): The query that is being profiled. This is the query argument from the
49
+ FT.AGGREGATE/FT.SEARCH command.
49
50
  query_type (Optional[QueryType]): The type of query to be profiled.
50
- query_options (Optional[Union[FtSearchOptions, FtAggregateOptions]]): The arguments/options for the FT.AGGREGATE/FT.SEARCH command being profiled.
51
+ query_options (Optional[Union[FtSearchOptions, FtAggregateOptions]]): The arguments/options for the
52
+ FT.AGGREGATE/FT.SEARCH command being profiled.
51
53
  limited (Optional[bool]): To provide some brief version of the output, otherwise a full verbose output is provided.
52
54
  """
53
55
  self.query = query
@@ -66,12 +68,14 @@ class FtProfileOptions:
66
68
  A class method to create FtProfileOptions with FT.SEARCH/FT.AGGREGATE options.
67
69
 
68
70
  Args:
69
- query (TEncodable): The query that is being profiled. This is the query argument from the FT.AGGREGATE/FT.SEARCH command.
70
- query_options (Optional[Union[FtSearchOptions, FtAggregateOptions]]): The arguments/options for the FT.AGGREGATE/FT.SEARCH command being profiled.
71
+ query (TEncodable): The query that is being profiled. This is the query argument from the
72
+ FT.AGGREGATE/FT.SEARCH command.
73
+ query_options (Optional[Union[FtSearchOptions, FtAggregateOptions]]): The arguments/options for the
74
+ FT.AGGREGATE/FT.SEARCH command being profiled.
71
75
  limited (Optional[bool]): To provide some brief version of the output, otherwise a full verbose output is provided.
72
76
  """
73
77
  query_type: QueryType = QueryType.SEARCH
74
- if type(query_options) == FtAggregateOptions:
78
+ if isinstance(query_options, FtAggregateOptions):
75
79
  query_type = QueryType.AGGREGATE
76
80
  return cls(query, query_type, query_options, limited)
77
81
 
@@ -83,7 +87,8 @@ class FtProfileOptions:
83
87
  A class method to create FtProfileOptions with QueryType.
84
88
 
85
89
  Args:
86
- query (TEncodable): The query that is being profiled. This is the query argument from the FT.AGGREGATE/FT.SEARCH command.
90
+ query (TEncodable): The query that is being profiled. This is the query argument from the
91
+ FT.AGGREGATE/FT.SEARCH command.
87
92
  query_type (QueryType): The type of query to be profiled.
88
93
  limited (Optional[bool]): To provide some brief version of the output, otherwise a full verbose output is provided.
89
94
  """
@@ -101,7 +106,7 @@ class FtProfileOptions:
101
106
  args.append(FtProfileKeywords.LIMITED)
102
107
  args.extend([FtProfileKeywords.QUERY, self.query])
103
108
  if self.query_options:
104
- if type(self.query_options) == FtAggregateOptions:
109
+ if isinstance(self.query_options, FtAggregateOptions):
105
110
  args.extend(cast(FtAggregateOptions, self.query_options).to_args())
106
111
  else:
107
112
  args.extend(cast(FtSearchOptions, self.query_options).to_args())