datasette-enrichments-slow 0.1__py3-none-any.whl → 0.2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -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"])
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: datasette-enrichments-slow
3
- Version: 0.1
3
+ Version: 0.2
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
@@ -0,0 +1,7 @@
1
+ datasette_enrichments_slow/__init__.py,sha256=cPnIhtqLPq6mcohBVryJfHFa32WYM3DssRUwgDCp5pY,1292
2
+ datasette_enrichments_slow-0.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
3
+ datasette_enrichments_slow-0.2.dist-info/METADATA,sha256=ynTMyO8aqfOJFMOzJlVkJYzYxKhjNMeimK-2fpJJpd8,2293
4
+ datasette_enrichments_slow-0.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
5
+ datasette_enrichments_slow-0.2.dist-info/entry_points.txt,sha256=cvHA2Xq1fpH6lmAljMedKADFzSa_4Lj7Px38hCoqHDQ,58
6
+ datasette_enrichments_slow-0.2.dist-info/top_level.txt,sha256=o-W1XO60TGFcagSJ9HljP25g_m1q_qnZxSJ9ftY70XQ,27
7
+ datasette_enrichments_slow-0.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -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,,