datasette-enrichments-slow 0.1__tar.gz → 0.2__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/PKG-INFO +2 -2
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/datasette_enrichments_slow/__init__.py +9 -0
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/datasette_enrichments_slow.egg-info/PKG-INFO +2 -2
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/pyproject.toml +1 -1
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/LICENSE +0 -0
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/README.md +0 -0
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/datasette_enrichments_slow.egg-info/SOURCES.txt +0 -0
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/datasette_enrichments_slow.egg-info/dependency_links.txt +0 -0
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/datasette_enrichments_slow.egg-info/entry_points.txt +0 -0
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/datasette_enrichments_slow.egg-info/requires.txt +0 -0
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/datasette_enrichments_slow.egg-info/top_level.txt +0 -0
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/setup.cfg +0 -0
- {datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/tests/test_enrichments_slow.py +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,11 @@ 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
|
+
)
|
28
34
|
|
29
35
|
return ConfigForm
|
30
36
|
|
@@ -36,5 +42,8 @@ class SlowEnrichment(Enrichment):
|
|
36
42
|
pks,
|
37
43
|
config,
|
38
44
|
):
|
45
|
+
error_rate = config.get("error_rate") or 0
|
39
46
|
for row in rows:
|
47
|
+
if error_rate and random.random() < error_rate:
|
48
|
+
raise ValueError("Error rate")
|
40
49
|
await asyncio.sleep(config["delay"])
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{datasette_enrichments_slow-0.1 → datasette_enrichments_slow-0.2}/tests/test_enrichments_slow.py
RENAMED
File without changes
|