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.
@@ -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
@@ -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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "datasette-enrichments-slow"
3
- version = "0.1"
3
+ version = "0.2"
4
4
  description = "An enrichment on a slow loop to help debug progress bars"
5
5
  readme = "README.md"
6
6
  authors = [{name = "Simon Willison"}]