cmem-plugin-random 0.5.0__tar.gz → 0.7.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cmem-plugin-random
3
- Version: 0.5.0
3
+ Version: 0.7.0
4
4
  Summary: Select random samples and generate random values.
5
5
  License: Apache-2.0
6
6
  License-File: LICENSE
@@ -14,7 +14,7 @@ Classifier: License :: OSI Approved :: Apache Software License
14
14
  Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
- Requires-Dist: cmem-plugin-base (>=4.15.0,<5.0.0)
17
+ Requires-Dist: cmem-plugin-base (>=4.19.0,<5.0.0)
18
18
  Description-Content-Type: text/markdown
19
19
 
20
20
  # cmem-plugin-random
@@ -143,7 +143,7 @@ class GenerateEntities(WorkflowPlugin):
143
143
  paths=paths,
144
144
  )
145
145
 
146
- def generate_entities(self) -> Generator[Entity, None, None]:
146
+ def generate_entities(self) -> Generator[Entity]:
147
147
  """Generate entities"""
148
148
  for _ in range(self.number_of_entities):
149
149
  entity_uri = f"urn:uuid:{uuid.uuid4()!s}"
@@ -3,13 +3,12 @@
3
3
  import random
4
4
  from collections.abc import Sequence
5
5
 
6
- from cmem_plugin_base.dataintegration.context import ExecutionContext
6
+ from cmem_plugin_base.dataintegration.context import ExecutionContext, ExecutionReport
7
7
  from cmem_plugin_base.dataintegration.description import Icon, Plugin, PluginParameter
8
8
  from cmem_plugin_base.dataintegration.entity import Entities
9
9
  from cmem_plugin_base.dataintegration.plugins import WorkflowPlugin
10
10
  from cmem_plugin_base.dataintegration.ports import (
11
11
  FixedNumberOfInputs,
12
- FlexibleSchemaPort,
13
12
  UnknownSchemaPort,
14
13
  )
15
14
 
@@ -21,6 +20,8 @@ param_count = PluginParameter(
21
20
 
22
21
  documentation = """This workflow task selects X random entities from an input dataset
23
22
  using the standard pseudo-random generator (reservoir sampling).
23
+
24
+ The task supports only flat entities. Hierarchical entities are ignored.
24
25
  """
25
26
 
26
27
 
@@ -45,17 +46,26 @@ class SelectEntities(WorkflowPlugin):
45
46
 
46
47
  # Input and output ports
47
48
  self.input_ports = FixedNumberOfInputs([UnknownSchemaPort()])
48
- self.output_port = FlexibleSchemaPort()
49
+ self.output_port = UnknownSchemaPort()
49
50
 
50
51
  def execute(
51
52
  self,
52
53
  inputs: Sequence[Entities],
53
- context: ExecutionContext, # noqa: ARG002
54
+ context: ExecutionContext,
54
55
  ) -> Entities:
55
56
  """Execute the workflow plugin on a given collection of entities."""
56
57
  self.log.info("Start selecting random entities.")
57
58
  output_entities = []
59
+ i: int | None = None
58
60
  for i, entity in enumerate(inputs[0].entities):
61
+ if i % 1000 == 0:
62
+ context.report.update(
63
+ ExecutionReport(
64
+ entity_count=i,
65
+ operation="read",
66
+ operation_desc="entities read from input",
67
+ )
68
+ )
59
69
  if i < self.number_of_entities:
60
70
  output_entities.append(entity)
61
71
  else:
@@ -63,4 +73,12 @@ class SelectEntities(WorkflowPlugin):
63
73
  if random_int < self.number_of_entities:
64
74
  output_entities[random_int] = entity
65
75
 
76
+ context.report.update(
77
+ ExecutionReport(
78
+ entity_count=len(output_entities),
79
+ operation="write",
80
+ operation_desc=f"of {0 if i is None else i + 1} entities selected",
81
+ )
82
+ )
83
+
66
84
  return Entities(entities=iter(output_entities), schema=inputs[0].schema)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cmem-plugin-random"
3
- version = "0.5.0"
3
+ version = "0.7.0"
4
4
  license = "Apache-2.0"
5
5
  description = "Select random samples and generate random values."
6
6
  authors = ["eccenca GmbH <cmempy-developer@eccenca.com>"]
@@ -13,28 +13,33 @@ keywords = [
13
13
  ]
14
14
 
15
15
 
16
+ [tool.poetry.requires-plugins]
17
+ poetry-plugin-export = "^1.10.0"
18
+ poetry-plugin-shell = "^1.0.1"
19
+ poetry-dynamic-versioning = "^1.10.0"
20
+
16
21
  [tool.poetry.dependencies]# if you need to change python version here, change it also in .python-version
17
22
  python = "^3.13"
18
23
 
19
24
  [tool.poetry.dependencies.cmem-plugin-base]
20
- version = "^4.15.0"
25
+ version = "^4.19.0"
21
26
  allow-prereleases = false
22
27
 
23
28
  [tool.poetry.group.dev.dependencies.cmem-cmemc]
24
29
  version = ">=24.2.0"
25
30
 
26
31
  [tool.poetry.group.dev.dependencies]
27
- deptry = "^0.24.0"
32
+ deptry = "^0.25.1"
28
33
  genbadge = {extras = ["coverage"], version = "^1.1.3"}
29
- mypy = "^1.19.1"
34
+ mypy = "^2.1.0"
30
35
  pip = "^26"
31
- pytest = "^9.0.2"
32
- pytest-cov = "^7.0.0"
36
+ pytest = "^9.1.0"
37
+ pytest-cov = "^7.1.0"
33
38
  pytest-dotenv = "^0.5.2"
34
39
  pytest-html = "^4.2.0"
35
40
  pytest-memray = { version = "^1.8.0", markers = "platform_system != 'Windows'" }
36
- ruff = "^0.15.0"
37
- trivy-py-ecc = "^0.69"
41
+ ruff = "^0.15.17"
42
+ trivy-py-ecc = "^0.71.2.1"
38
43
 
39
44
  [build-system]
40
45
  requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
@@ -67,7 +72,7 @@ exclude_also = [
67
72
 
68
73
  [tool.ruff]
69
74
  line-length = 100
70
- target-version = "py311"
75
+ target-version = "py313"
71
76
 
72
77
  [tool.ruff.format]
73
78
  line-ending = "lf" # Use `\n` line endings for all files