datasette-enrichments-slow 0.1__py3-none-any.whl → 0.3a0__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.
- datasette_enrichments_slow/__init__.py +25 -0
- {datasette_enrichments_slow-0.1.dist-info → datasette_enrichments_slow-0.3a0.dist-info}/METADATA +3 -3
- datasette_enrichments_slow-0.3a0.dist-info/RECORD +7 -0
- {datasette_enrichments_slow-0.1.dist-info → datasette_enrichments_slow-0.3a0.dist-info}/WHEEL +1 -1
- datasette_enrichments_slow-0.1.dist-info/RECORD +0 -7
- {datasette_enrichments_slow-0.1.dist-info → datasette_enrichments_slow-0.3a0.dist-info}/LICENSE +0 -0
- {datasette_enrichments_slow-0.1.dist-info → datasette_enrichments_slow-0.3a0.dist-info}/entry_points.txt +0 -0
- {datasette_enrichments_slow-0.1.dist-info → datasette_enrichments_slow-0.3a0.dist-info}/top_level.txt +0 -0
@@ -2,6 +2,7 @@ import asyncio
|
|
2
2
|
from datasette_enrichments import Enrichment
|
3
3
|
from datasette import hookimpl
|
4
4
|
from wtforms import Form, FloatField
|
5
|
+
import random
|
5
6
|
|
6
7
|
|
7
8
|
@hookimpl
|
@@ -25,6 +26,21 @@ class SlowEnrichment(Enrichment):
|
|
25
26
|
description="How many seconds to delay for each row",
|
26
27
|
default=0.1,
|
27
28
|
)
|
29
|
+
error_rate = FloatField(
|
30
|
+
"Error rate",
|
31
|
+
description="What portion of rows should be errors? Between 0 and 1.0",
|
32
|
+
default=0,
|
33
|
+
)
|
34
|
+
pause_rate = FloatField(
|
35
|
+
"Pause rate",
|
36
|
+
description="Chance an item should pause the run, 0 to 1.0",
|
37
|
+
default=0,
|
38
|
+
)
|
39
|
+
cancel_rate = FloatField(
|
40
|
+
"Cancel rate",
|
41
|
+
description="Chance an item should cancel the run, 0 to 1.0",
|
42
|
+
default=0,
|
43
|
+
)
|
28
44
|
|
29
45
|
return ConfigForm
|
30
46
|
|
@@ -36,5 +52,14 @@ class SlowEnrichment(Enrichment):
|
|
36
52
|
pks,
|
37
53
|
config,
|
38
54
|
):
|
55
|
+
error_rate = config.get("error_rate") or 0
|
56
|
+
cancel_rate = config.get("cancel_rate") or 0
|
57
|
+
pause_rate = config.get("pause_rate") or 0
|
39
58
|
for row in rows:
|
59
|
+
if error_rate and random.random() < error_rate:
|
60
|
+
raise ValueError("Error rate")
|
61
|
+
if cancel_rate and random.random() < cancel_rate:
|
62
|
+
raise self.Cancel()
|
63
|
+
if pause_rate and random.random() < pause_rate:
|
64
|
+
raise self.Pause()
|
40
65
|
await asyncio.sleep(config["delay"])
|
{datasette_enrichments_slow-0.1.dist-info → datasette_enrichments_slow-0.3a0.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: datasette-enrichments-slow
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3a0
|
4
4
|
Summary: An enrichment on a slow loop to help debug progress bars
|
5
5
|
Author: Simon Willison
|
6
6
|
License: Apache-2.0
|
@@ -14,7 +14,7 @@ Requires-Python: >=3.9
|
|
14
14
|
Description-Content-Type: text/markdown
|
15
15
|
License-File: LICENSE
|
16
16
|
Requires-Dist: datasette
|
17
|
-
Requires-Dist: datasette-enrichments
|
17
|
+
Requires-Dist: datasette-enrichments>=0.5a1
|
18
18
|
Provides-Extra: test
|
19
19
|
Requires-Dist: pytest; extra == "test"
|
20
20
|
Requires-Dist: pytest-asyncio; extra == "test"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
datasette_enrichments_slow/__init__.py,sha256=oLtRUwe3rzp8KX1mu1BLwST_f53Lb2BtwNrQ90aQRMg,1962
|
2
|
+
datasette_enrichments_slow-0.3a0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
3
|
+
datasette_enrichments_slow-0.3a0.dist-info/METADATA,sha256=7YC8-K6OlkVLBzDJoo4V4DL-kKBKQGzPOr4ugj_3ng4,2302
|
4
|
+
datasette_enrichments_slow-0.3a0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
5
|
+
datasette_enrichments_slow-0.3a0.dist-info/entry_points.txt,sha256=cvHA2Xq1fpH6lmAljMedKADFzSa_4Lj7Px38hCoqHDQ,58
|
6
|
+
datasette_enrichments_slow-0.3a0.dist-info/top_level.txt,sha256=o-W1XO60TGFcagSJ9HljP25g_m1q_qnZxSJ9ftY70XQ,27
|
7
|
+
datasette_enrichments_slow-0.3a0.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
datasette_enrichments_slow/__init__.py,sha256=YH4FHP8NmsURC3lYDapLXmMPY_6Fsczrh15wk_6YpWU,924
|
2
|
-
datasette_enrichments_slow-0.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
3
|
-
datasette_enrichments_slow-0.1.dist-info/METADATA,sha256=6VJ5WKbUn1tvxxLgJVp-zGUDJCZDLaI4vyGoKWDxris,2293
|
4
|
-
datasette_enrichments_slow-0.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
5
|
-
datasette_enrichments_slow-0.1.dist-info/entry_points.txt,sha256=cvHA2Xq1fpH6lmAljMedKADFzSa_4Lj7Px38hCoqHDQ,58
|
6
|
-
datasette_enrichments_slow-0.1.dist-info/top_level.txt,sha256=o-W1XO60TGFcagSJ9HljP25g_m1q_qnZxSJ9ftY70XQ,27
|
7
|
-
datasette_enrichments_slow-0.1.dist-info/RECORD,,
|
{datasette_enrichments_slow-0.1.dist-info → datasette_enrichments_slow-0.3a0.dist-info}/LICENSE
RENAMED
File without changes
|
File without changes
|
File without changes
|