scruby 0.14.1__py3-none-any.whl → 0.14.2__py3-none-any.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 scruby might be problematic. Click here for more details.
- scruby/aggregation.py +4 -4
- scruby/db.py +10 -5
- {scruby-0.14.1.dist-info → scruby-0.14.2.dist-info}/METADATA +1 -1
- scruby-0.14.2.dist-info/RECORD +10 -0
- scruby-0.14.1.dist-info/RECORD +0 -10
- {scruby-0.14.1.dist-info → scruby-0.14.2.dist-info}/WHEEL +0 -0
- {scruby-0.14.1.dist-info → scruby-0.14.2.dist-info}/licenses/LICENSE +0 -0
scruby/aggregation.py
CHANGED
|
@@ -41,11 +41,11 @@ class Counter:
|
|
|
41
41
|
"""Aggregation class for calculating the number of documents.
|
|
42
42
|
|
|
43
43
|
Args:
|
|
44
|
-
|
|
44
|
+
limit: The maximum counter value.
|
|
45
45
|
"""
|
|
46
46
|
|
|
47
|
-
def __init__(self,
|
|
48
|
-
self.
|
|
47
|
+
def __init__(self, limit: int = 1000) -> None:
|
|
48
|
+
self.limit = limit
|
|
49
49
|
self.counter = 0
|
|
50
50
|
|
|
51
51
|
def check(self) -> bool:
|
|
@@ -54,7 +54,7 @@ class Counter:
|
|
|
54
54
|
Returns:
|
|
55
55
|
Boolean value. If `True`, the maximum value is achieved.
|
|
56
56
|
"""
|
|
57
|
-
return self.counter >= self.
|
|
57
|
+
return self.counter >= self.limit
|
|
58
58
|
|
|
59
59
|
def next(self) -> None:
|
|
60
60
|
"""Increment the counter on one."""
|
scruby/db.py
CHANGED
|
@@ -335,7 +335,7 @@ class Scruby[T]:
|
|
|
335
335
|
def find_many(
|
|
336
336
|
self,
|
|
337
337
|
filter_fn: Callable,
|
|
338
|
-
|
|
338
|
+
limit_docs: int = 1000,
|
|
339
339
|
max_workers: int | None = None,
|
|
340
340
|
timeout: float | None = None,
|
|
341
341
|
) -> list[T] | None:
|
|
@@ -347,7 +347,7 @@ class Scruby[T]:
|
|
|
347
347
|
|
|
348
348
|
Args:
|
|
349
349
|
filter_fn: A function that execute the conditions of filtering.
|
|
350
|
-
|
|
350
|
+
limit_docs: Limiting the number of documents. By default = 1000.
|
|
351
351
|
max_workers: The maximum number of processes that can be used to
|
|
352
352
|
execute the given calls. If None or not given then as many
|
|
353
353
|
worker processes will be created as the machine has processors.
|
|
@@ -363,7 +363,7 @@ class Scruby[T]:
|
|
|
363
363
|
with concurrent.futures.ThreadPoolExecutor(max_workers) as executor:
|
|
364
364
|
results = []
|
|
365
365
|
for branch_number in branch_numbers:
|
|
366
|
-
if counter ==
|
|
366
|
+
if counter == limit_docs:
|
|
367
367
|
break
|
|
368
368
|
future = executor.submit(
|
|
369
369
|
search_task_fn,
|
|
@@ -538,12 +538,16 @@ class Scruby[T]:
|
|
|
538
538
|
docs.append(class_model.model_validate_json(val))
|
|
539
539
|
return docs
|
|
540
540
|
|
|
541
|
-
def run_custom_task(self,
|
|
541
|
+
def run_custom_task(self, custom_task_fn: Callable, limit_docs: int = 1000) -> Any:
|
|
542
542
|
"""Running custom task.
|
|
543
543
|
|
|
544
544
|
This method running a task created on the basis of a quantum loop.
|
|
545
545
|
Effectiveness running task depends on the number of processor threads.
|
|
546
546
|
Ideally, hundreds and even thousands of threads are required.
|
|
547
|
+
|
|
548
|
+
Args:
|
|
549
|
+
custom_task_fn: A function that execute the custom task.
|
|
550
|
+
limit_docs: Limiting the number of documents. By default = 1000.
|
|
547
551
|
"""
|
|
548
552
|
kwargs = {
|
|
549
553
|
"get_docs_fn": self._task_get_docs,
|
|
@@ -551,5 +555,6 @@ class Scruby[T]:
|
|
|
551
555
|
"hash_reduce_left": self.__hash_reduce_left,
|
|
552
556
|
"db_root": self.__db_root,
|
|
553
557
|
"class_model": self.__class_model,
|
|
558
|
+
"limit_docs": limit_docs,
|
|
554
559
|
}
|
|
555
|
-
return
|
|
560
|
+
return custom_task_fn(**kwargs)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
scruby/__init__.py,sha256=GOVcjXmcOEDBbJQJDJlQq-x3M-VGJaMSN278EXsl2po,884
|
|
2
|
+
scruby/aggregation.py,sha256=x_9ZJQHJHDISxRvddS5A2Hb0saIcfPTh1Veyf2KgX8A,2919
|
|
3
|
+
scruby/constants.py,sha256=3LZfcxcuRqwzoB0-iogLMjKBZRdxfWJmTbyPwVRhQgY,1007
|
|
4
|
+
scruby/db.py,sha256=_-2h6x1WkND52q-lDGYBFcQJ_7Mwxq3Rh4ZFfqIinsQ,21100
|
|
5
|
+
scruby/errors.py,sha256=aHQri4LNcFVQrSHwjyzb1fL8O49SwjYEU4QgMOo4uyA,622
|
|
6
|
+
scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
scruby-0.14.2.dist-info/METADATA,sha256=vWhruXyj6cQyhPbXjMsUnz-j3L92eImp_R1QxX16BH0,10925
|
|
8
|
+
scruby-0.14.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
+
scruby-0.14.2.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
10
|
+
scruby-0.14.2.dist-info/RECORD,,
|
scruby-0.14.1.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
scruby/__init__.py,sha256=GOVcjXmcOEDBbJQJDJlQq-x3M-VGJaMSN278EXsl2po,884
|
|
2
|
-
scruby/aggregation.py,sha256=fOsfMyCm28frKOFHmWzuGU81QPeJTJfs4EVIIroxOcQ,2909
|
|
3
|
-
scruby/constants.py,sha256=3LZfcxcuRqwzoB0-iogLMjKBZRdxfWJmTbyPwVRhQgY,1007
|
|
4
|
-
scruby/db.py,sha256=OXtMqq9y6RQkHHWOgFVXqI96v7g58SIoLUq-h09WxjI,20899
|
|
5
|
-
scruby/errors.py,sha256=aHQri4LNcFVQrSHwjyzb1fL8O49SwjYEU4QgMOo4uyA,622
|
|
6
|
-
scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
scruby-0.14.1.dist-info/METADATA,sha256=cnKZxapHkg2CRAFX_M1AgMiZ5oDNvW0nSjaTnlnryLw,10925
|
|
8
|
-
scruby-0.14.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
-
scruby-0.14.1.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
10
|
-
scruby-0.14.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|