datasette-enrichments-slow 0.2__tar.gz → 0.3a0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: datasette-enrichments-slow
3
- Version: 0.2
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"
@@ -31,6 +31,16 @@ class SlowEnrichment(Enrichment):
31
31
  description="What portion of rows should be errors? Between 0 and 1.0",
32
32
  default=0,
33
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
+ )
34
44
 
35
45
  return ConfigForm
36
46
 
@@ -43,7 +53,13 @@ class SlowEnrichment(Enrichment):
43
53
  config,
44
54
  ):
45
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
46
58
  for row in rows:
47
59
  if error_rate and random.random() < error_rate:
48
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()
49
65
  await asyncio.sleep(config["delay"])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: datasette-enrichments-slow
3
- Version: 0.2
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"
@@ -1,5 +1,5 @@
1
1
  datasette
2
- datasette-enrichments
2
+ datasette-enrichments>=0.5a1
3
3
 
4
4
  [test]
5
5
  pytest
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "datasette-enrichments-slow"
3
- version = "0.2"
3
+ version = "0.3a0"
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"}]
@@ -12,7 +12,7 @@ classifiers=[
12
12
  requires-python = ">=3.9"
13
13
  dependencies = [
14
14
  "datasette",
15
- "datasette-enrichments",
15
+ "datasette-enrichments>=0.5a1",
16
16
  ]
17
17
 
18
18
  [build-system]