opentf-toolkit-nightly 0.58.0.dev1135__py3-none-any.whl → 0.58.0.dev1144__py3-none-any.whl

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.
@@ -50,7 +50,15 @@ CREATION_TIMESTAMP = 'creationTimestamp'
50
50
 
51
51
 
52
52
  class DataSourceScopeError(Exception):
53
- """CacheException class"""
53
+ """DataSourceScopeError class"""
54
+
55
+ def __init__(self, msg, details=None):
56
+ self.msg = msg
57
+ self.details = details
58
+
59
+
60
+ class DataSourceDataError(Exception):
61
+ """DataSourceDataError class"""
54
62
 
55
63
  def __init__(self, msg, details=None):
56
64
  self.msg = msg
@@ -626,7 +634,7 @@ def get_tags(events: List[Dict[str, Any]]) -> Dict[str, Any]:
626
634
  ```
627
635
  """
628
636
  if not (jobs := _get_workflow_jobs(events)):
629
- raise ValueError(
637
+ raise DataSourceDataError(
630
638
  'No job events found in workflow. Cannot extract data for tags.'
631
639
  )
632
640
  tags = {}
@@ -802,7 +810,7 @@ def get_jobs(events: List[Dict[str, Any]]) -> Dict[str, Any]:
802
810
  return not item and not items
803
811
 
804
812
  if not (workflow_jobs := _get_workflow_jobs(events)):
805
- raise ValueError(
813
+ raise DataSourceDataError(
806
814
  'No job events found in workflow. Cannot extract data for jobs.'
807
815
  )
808
816
 
opentf/commons/pubsub.py CHANGED
@@ -108,7 +108,7 @@ def _do(req, path: str, eventbus: Dict[str, Any], **kwargs) -> Response:
108
108
  )
109
109
 
110
110
 
111
- def _dispatch_events(dispatch_queue: Queue, fn, app) -> None:
111
+ def _dispatch_events(dispatch_queue: Queue, fn, app, strategy) -> None:
112
112
  """Async event dispatch thread handler."""
113
113
  delay = 0
114
114
  while True:
@@ -119,10 +119,13 @@ def _dispatch_events(dispatch_queue: Queue, fn, app) -> None:
119
119
  delay = 0
120
120
  except Exception:
121
121
  dispatch_queue.put(publication)
122
- delay = min(2 * delay + 0.2, 60)
122
+ delay = min(2 * delay + 1, 60)
123
+ app.logger.debug(
124
+ 'Failed to dispatch publication, retrying in %d seconds.', delay
125
+ )
123
126
  sleep(delay)
124
127
  except Exception as err:
125
- app.logger.error(f'Internal error while dispatching publication: {err}.')
128
+ app.logger.error('Internal error while dispatching publication: %s.', err)
126
129
 
127
130
 
128
131
  def subscribe(
@@ -236,7 +239,7 @@ def publish(publication: Any, context: Dict[str, Any]) -> Response:
236
239
  return _do(post, '/publications', context['eventbus'], json=publication)
237
240
 
238
241
 
239
- def make_dispatchqueue(app, fn=publish) -> Queue:
242
+ def make_dispatchqueue(app, fn=publish, strategy=None) -> Queue:
240
243
  """Make an asynchronous dispatch queue.
241
244
 
242
245
  Handles publication failures by waiting for an increasing delay and
@@ -251,6 +254,7 @@ def make_dispatchqueue(app, fn=publish) -> Queue:
251
254
  # Optional parameters
252
255
 
253
256
  - fn: a function (`publish` by default)
257
+ - stragegy: a dictionary or None (None by default)
254
258
 
255
259
  # Returned value
256
260
 
@@ -260,7 +264,7 @@ def make_dispatchqueue(app, fn=publish) -> Queue:
260
264
  app.logger.debug('Starting events dispatch thread.')
261
265
  try:
262
266
  threading.Thread(
263
- target=_dispatch_events, args=[queue, fn, app], daemon=True
267
+ target=_dispatch_events, args=[queue, fn, app, strategy], daemon=True
264
268
  ).start()
265
269
  return queue
266
270
  except Exception as err:
opentf/commons/schemas.py CHANGED
@@ -33,7 +33,7 @@ SSHSERVICECONFIG = 'opentestfactory.org/v1alpha2/SSHServiceConfig'
33
33
  EVENTBUSCONFIG = 'opentestfactory.org/v1alpha1/EventBusConfig'
34
34
  PROVIDERCONFIG = 'opentestfactory.org/v1beta1/ProviderConfig'
35
35
 
36
- SUBSCRIPTION = 'opentestfactory.org/v1alpha1/Subscription'
36
+ SUBSCRIPTION = 'opentestfactory.org/v1/Subscription'
37
37
 
38
38
  WORKFLOW = 'opentestfactory.org/v1/Workflow'
39
39
  WORKFLOWCANCELLATION = 'opentestfactory.org/v1/WorkflowCancellation'
@@ -4,7 +4,7 @@
4
4
  "type": "object",
5
5
  "properties": {
6
6
  "apiVersion": {
7
- "union": [
7
+ "enum": [
8
8
  "opentestfactory.org/v1alpha1",
9
9
  "opentestfactory.org/v1beta1",
10
10
  "opentestfactory.org/v1"
@@ -0,0 +1,187 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2019-09/schema#",
3
+ "title": "JSON SCHEMA for opentestfactory.org/v1 Subscription manifests",
4
+ "type": "object",
5
+ "properties": {
6
+ "apiVersion": {
7
+ "enum": [
8
+ "opentestfactory.org/v1alpha1",
9
+ "opentestfactory.org/v1"
10
+ ]
11
+ },
12
+ "kind": {
13
+ "const": "Subscription"
14
+ },
15
+ "metadata": {
16
+ "type": "object",
17
+ "properties": {
18
+ "name": {
19
+ "type": "string"
20
+ }
21
+ },
22
+ "additionalProperties": true,
23
+ "required": [
24
+ "name"
25
+ ]
26
+ },
27
+ "spec": {
28
+ "type": "object",
29
+ "properties": {
30
+ "selector": {
31
+ "type": "object",
32
+ "properties": {
33
+ "matchKind": {
34
+ "type": "string"
35
+ },
36
+ "matchLabels": {
37
+ "type": "object",
38
+ "patternProperties": {
39
+ "^([a-zA-Z0-9-.]+/)?[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$": {
40
+ "type": "string"
41
+ }
42
+ },
43
+ "minProperties": 1,
44
+ "additionalProperties": false
45
+ },
46
+ "matchExpressions": {
47
+ "$ref": "#/definitions/expressions"
48
+ },
49
+ "matchFields": {
50
+ "type": "object",
51
+ "patternProperties": {
52
+ "^[a-z]([a-zA-Z0-9.-]*[a-zA-Z0-9])?$": {
53
+ "type": "string"
54
+ }
55
+ },
56
+ "minProperties": 1,
57
+ "additionalProperties": false
58
+ },
59
+ "matchFieldExpressions": {
60
+ "$ref": "#/definitions/expressions"
61
+ }
62
+ },
63
+ "minProperties": 1,
64
+ "additionalProperties": false
65
+ },
66
+ "subscriber": {
67
+ "type": "object",
68
+ "properties": {
69
+ "endpoint": {
70
+ "type": "string"
71
+ },
72
+ "insecure-skip-tls-verify": {
73
+ "type": "boolean"
74
+ }
75
+ },
76
+ "additionalProperties": false,
77
+ "required": [
78
+ "endpoint"
79
+ ]
80
+ },
81
+ "queues": {
82
+ "type": "number"
83
+ },
84
+ "rateLimit": {
85
+ "type": "number"
86
+ },
87
+ "backoff": {
88
+ "type": "object",
89
+ "properties": {
90
+ "duration": {
91
+ "type": "string"
92
+ },
93
+ "factor": {
94
+ "type": "number"
95
+ },
96
+ "jitter": {
97
+ "type": "number"
98
+ },
99
+ "steps": {
100
+ "type": "number"
101
+ },
102
+ "retries": {
103
+ "type": "number"
104
+ }
105
+ },
106
+ "additionalProperties": false,
107
+ "required": [
108
+ "duration",
109
+ "factor",
110
+ "jitter",
111
+ "steps",
112
+ "retries"
113
+ ]
114
+ }
115
+ },
116
+ "required": [
117
+ "subscriber"
118
+ ],
119
+ "additionalProperties": false
120
+ }
121
+ },
122
+ "required": [
123
+ "apiVersion",
124
+ "kind",
125
+ "metadata",
126
+ "spec"
127
+ ],
128
+ "additionalProperties": false,
129
+ "definitions": {
130
+ "expressions": {
131
+ "type": "array",
132
+ "minItems": 1,
133
+ "items": {
134
+ "anyOf": [
135
+ {
136
+ "type": "object",
137
+ "properties": {
138
+ "key": {
139
+ "type": "string"
140
+ },
141
+ "operator": {
142
+ "enum": [
143
+ "In",
144
+ "NotIn",
145
+ "ContainsAll",
146
+ "DoesNotContainAll"
147
+ ]
148
+ },
149
+ "values": {
150
+ "type": "array",
151
+ "minItems": 1,
152
+ "items": {
153
+ "type": "string"
154
+ }
155
+ }
156
+ },
157
+ "additionalProperties": false,
158
+ "required": [
159
+ "key",
160
+ "operator",
161
+ "values"
162
+ ]
163
+ },
164
+ {
165
+ "type": "object",
166
+ "properties": {
167
+ "key": {
168
+ "type": "string"
169
+ },
170
+ "operator": {
171
+ "enum": [
172
+ "Exists",
173
+ "DoesNotExist"
174
+ ]
175
+ }
176
+ },
177
+ "additionalProperties": false,
178
+ "required": [
179
+ "key",
180
+ "operator"
181
+ ]
182
+ }
183
+ ]
184
+ }
185
+ }
186
+ }
187
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opentf-toolkit-nightly
3
- Version: 0.58.0.dev1135
3
+ Version: 0.58.0.dev1144
4
4
  Summary: OpenTestFactory Orchestrator Toolkit
5
5
  Home-page: https://gitlab.com/henixdevelopment/open-source/opentestfactory/python-toolkit
6
6
  Author: Martin Lafaix
@@ -1,17 +1,18 @@
1
1
  opentf/commons/__init__.py,sha256=AnnUMqwHwYnZxMhGdAwFGNbKIcr4HNVRUEfUuB2ub-c,22481
2
2
  opentf/commons/auth.py,sha256=bM2Z3kxm2Wku1lKXaRAIg37LHvXWAXIZIqjplDfN2P8,15899
3
3
  opentf/commons/config.py,sha256=dyus4K5Zdmcftc3Y9Z1YRkzA1KwiRLHoeAlg2_A49QM,7876
4
- opentf/commons/datasources.py,sha256=OcwVLPGK0iCnTgHu3RJ9C1U3AUs5LTKvyOTQZFIh7Ek,25996
4
+ opentf/commons/datasources.py,sha256=GSbjrYnZQup2B3r7T7l3C_o6R2jS13nQiu6dRitoenk,26194
5
5
  opentf/commons/expressions.py,sha256=jM_YKXVOFhvOE2aE2IuacuvxhIsOYTFs2oQkpcbWR6g,19645
6
- opentf/commons/pubsub.py,sha256=DVrSara5FRfNdPBwXKUkTobqGki0RPDehylTEFcJnFc,7341
7
- opentf/commons/schemas.py,sha256=Ub6klLnDh_O44r0aZzsspMV3sx-An0lClfim1dyASZQ,4260
6
+ opentf/commons/pubsub.py,sha256=kHJggZZnoibx31r9NzTd6tyCjHO2NJlr_q1UY4fVwCQ,7567
7
+ opentf/commons/schemas.py,sha256=cjyPXRhRIPQauCdy9zGRaOkqdVcklz47JnljTTLNpq8,4254
8
8
  opentf/commons/selectors.py,sha256=DEpLgRAr5HXSpSYI4liXP2hLUTvOSexFa9Vfa1xIQTk,7134
9
9
  opentf/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  opentf/schemas/abac.opentestfactory.org/v1alpha1/Policy.json,sha256=JXsfNAPSEYggeyaDutSQBeG38o4Bmcr70dPLWWeqIh8,2105
11
11
  opentf/schemas/opentestfactory.org/v1/ExecutionCommand.json,sha256=UtmAlTaYdPSZDeQnx-ocX8IonyEPWoNmgDkHwQwQxWE,4126
12
- opentf/schemas/opentestfactory.org/v1/GeneratorResult.json,sha256=neoFocJGkVTQQPtnG5xnbqNLX8ivFBJbanbbPweId7s,16608
12
+ opentf/schemas/opentestfactory.org/v1/GeneratorResult.json,sha256=sOwieyDWi6UZR7X29R9IjOR87ruSRQ4U6CM2_yT81Zk,16607
13
13
  opentf/schemas/opentestfactory.org/v1/ProviderCommand.json,sha256=EU4kvEKxlqpH2IkLZ1HdBealuG6C0YzPkAtI7dNrfHg,4427
14
14
  opentf/schemas/opentestfactory.org/v1/ProviderResult.json,sha256=Ej4zhCE3rCqCGKcaeAoIHwSJTV_7fw-rAxhJ52qA-Gs,9641
15
+ opentf/schemas/opentestfactory.org/v1/Subscription.json,sha256=ULD4s-PViRAHUt_iHnvzpQAxONjGW95hXB4tvMS8u_E,6341
15
16
  opentf/schemas/opentestfactory.org/v1/Workflow.json,sha256=WAFvCAIxmp22-AN1wPuOkd3BYs8UP5u3hj74NnlO3vU,22945
16
17
  opentf/schemas/opentestfactory.org/v1/WorkflowCanceled.json,sha256=BCWxnm3rt4VWh9GXkIhdNY9JYohFWxi9Wg3JjXIavaU,1694
17
18
  opentf/schemas/opentestfactory.org/v1/WorkflowCancellation.json,sha256=HAtc8xjrr-WwXwIck9B86BrHELkCb1oPYhTsRzHMMOE,1993
@@ -56,8 +57,8 @@ opentf/scripts/startup.py,sha256=c5fhYUy_Nk6z-eo0kW0mG56452dcIw9mzb9trljZYZ4,214
56
57
  opentf/toolkit/__init__.py,sha256=mYeJPZ92ulbTBItqEsZgF4nnuRh6G19QPY3Jxc92ifc,23028
57
58
  opentf/toolkit/channels.py,sha256=6xcVKHUK2FdyVKIQmPQbakngfVuQDzCcD_lInOdKpro,17171
58
59
  opentf/toolkit/core.py,sha256=6nud1vqcfjs9swZu_Z-rbvdbejtrlSjOd8eZXIF0ChE,9795
59
- opentf_toolkit_nightly-0.58.0.dev1135.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
60
- opentf_toolkit_nightly-0.58.0.dev1135.dist-info/METADATA,sha256=rbyrYzr3i-uH7md-UQSKBu5TEXC8HZZ57gc8jlyGwm4,1946
61
- opentf_toolkit_nightly-0.58.0.dev1135.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
62
- opentf_toolkit_nightly-0.58.0.dev1135.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
63
- opentf_toolkit_nightly-0.58.0.dev1135.dist-info/RECORD,,
60
+ opentf_toolkit_nightly-0.58.0.dev1144.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
61
+ opentf_toolkit_nightly-0.58.0.dev1144.dist-info/METADATA,sha256=aw6HxZ-BdUC88HFnFuTYMtjBi-jU-3n48YVykNCkuik,1946
62
+ opentf_toolkit_nightly-0.58.0.dev1144.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
63
+ opentf_toolkit_nightly-0.58.0.dev1144.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
64
+ opentf_toolkit_nightly-0.58.0.dev1144.dist-info/RECORD,,