taskflow 5.0.0__py3-none-any.whl → 5.1.1__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.
@@ -28,6 +28,7 @@ from kazoo.protocol import states as k_states
28
28
  from kazoo.recipe import watchers
29
29
  from oslo_serialization import jsonutils
30
30
  from oslo_utils import excutils
31
+ from oslo_utils import strutils
31
32
  from oslo_utils import timeutils
32
33
  from oslo_utils import uuidutils
33
34
 
@@ -829,7 +830,8 @@ class ZookeeperJobBoard(base.NotifyingJobBoard):
829
830
  excp.raise_with_cause(excp.JobFailure,
830
831
  "Failed to connect to zookeeper")
831
832
  try:
832
- if self._conf.get('check_compatible', True):
833
+ if strutils.bool_from_string(
834
+ self._conf.get('check_compatible'), default=True):
833
835
  kazoo_utils.check_compatible(self._client, self.MIN_ZK_VERSION)
834
836
  if self._worker is None and self._emit_notifications:
835
837
  self._worker = futurist.ThreadPoolExecutor(max_workers=1)
@@ -20,6 +20,7 @@ import contextlib
20
20
  from kazoo import exceptions as k_exc
21
21
  from kazoo.protocol import paths
22
22
  from oslo_serialization import jsonutils
23
+ from oslo_utils import strutils
23
24
 
24
25
  from taskflow import exceptions as exc
25
26
  from taskflow.persistence import path_based
@@ -161,7 +162,8 @@ class ZkConnection(path_based.PathBasedConnection):
161
162
  def validate(self):
162
163
  with self._exc_wrapper():
163
164
  try:
164
- if self._conf.get('check_compatible', True):
165
+ if strutils.bool_from_string(
166
+ self._conf.get('check_compatible'), default=True):
165
167
  k_utils.check_compatible(self._client, MIN_ZK_VERSION)
166
168
  except exc.IncompatibleVersion:
167
169
  exc.raise_with_cause(exc.StorageFailure, "Backend storage is"
@@ -293,3 +293,47 @@ class ZakeJobboardTest(test.TestCase, ZookeeperBoardTestMixin):
293
293
  self.assertRaises(excp.NotImplementedError,
294
294
  self.board.register_entity,
295
295
  entity_instance_2)
296
+
297
+ def test_connect_check_compatible(self):
298
+ # Valid version
299
+ client = fake_client.FakeClient()
300
+ board = impl_zookeeper.ZookeeperJobBoard(
301
+ 'test-board', {'check_compatible': True},
302
+ client=client)
303
+ self.addCleanup(board.close)
304
+ self.addCleanup(self.close_client, client)
305
+
306
+ with base.connect_close(board):
307
+ pass
308
+
309
+ # Invalid version, no check
310
+ client = fake_client.FakeClient(server_version=(3, 2, 0))
311
+ board = impl_zookeeper.ZookeeperJobBoard(
312
+ 'test-board', {'check_compatible': False},
313
+ client=client)
314
+ self.addCleanup(board.close)
315
+ self.addCleanup(self.close_client, client)
316
+
317
+ with base.connect_close(board):
318
+ pass
319
+
320
+ # Invalid version, check_compatible=True
321
+ client = fake_client.FakeClient(server_version=(3, 2, 0))
322
+ board = impl_zookeeper.ZookeeperJobBoard(
323
+ 'test-board', {'check_compatible': True},
324
+ client=client)
325
+ self.addCleanup(board.close)
326
+ self.addCleanup(self.close_client, client)
327
+
328
+ self.assertRaises(excp.IncompatibleVersion, board.connect)
329
+
330
+ # Invalid version, check_compatible='False'
331
+ client = fake_client.FakeClient(server_version=(3, 2, 0))
332
+ board = impl_zookeeper.ZookeeperJobBoard(
333
+ 'test-board', {'check_compatible': 'False'},
334
+ client=client)
335
+ self.addCleanup(board.close)
336
+ self.addCleanup(self.close_client, client)
337
+
338
+ with base.connect_close(board):
339
+ pass
@@ -140,14 +140,21 @@ class IterUtilsTest(test.TestCase):
140
140
  self.assertRaises(ValueError, iter_utils.while_is_not, 2, 'a')
141
141
 
142
142
  def test_while_is_not(self):
143
- it = iter(string.ascii_lowercase)
144
- self.assertEqual(['a'],
145
- list(iter_utils.while_is_not(it, 'a')))
146
- it = iter(string.ascii_lowercase)
147
- self.assertEqual(['a', 'b'],
148
- list(iter_utils.while_is_not(it, 'b')))
149
- self.assertEqual(list(string.ascii_lowercase[2:]),
150
- list(iter_utils.while_is_not(it, 'zzz')))
151
- it = iter(string.ascii_lowercase)
152
- self.assertEqual(list(string.ascii_lowercase),
153
- list(iter_utils.while_is_not(it, '')))
143
+ class Dummy(object):
144
+ def __init__(self, char):
145
+ self.char = char
146
+ dummy_list = [Dummy(a)
147
+ for a in string.ascii_lowercase]
148
+
149
+ it = iter(dummy_list)
150
+ self.assertEqual([dummy_list[0]],
151
+ list(iter_utils.while_is_not(it, dummy_list[0])))
152
+ it = iter(dummy_list)
153
+ self.assertEqual(dummy_list[0:2],
154
+ list(iter_utils.while_is_not(it, dummy_list[1])))
155
+ self.assertEqual(dummy_list[2:],
156
+ list(iter_utils.while_is_not(it, Dummy('zzz'))))
157
+
158
+ it = iter(dummy_list)
159
+ self.assertEqual(dummy_list,
160
+ list(iter_utils.while_is_not(it, Dummy(''))))
@@ -0,0 +1,67 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Copyright (C) Red Hat
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License. You may obtain
7
+ # a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations
15
+ # under the License.
16
+
17
+ from unittest import mock
18
+
19
+ from taskflow import test
20
+ from taskflow.utils import kazoo_utils
21
+
22
+
23
+ class MakeClientTest(test.TestCase):
24
+
25
+ @mock.patch("kazoo.client.KazooClient")
26
+ def test_make_client_config(self, mock_kazoo_client):
27
+ conf = {}
28
+ expected = {
29
+ 'hosts': 'localhost:2181',
30
+ 'logger': mock.ANY,
31
+ 'read_only': False,
32
+ 'randomize_hosts': False,
33
+ 'keyfile': None,
34
+ 'keyfile_password': None,
35
+ 'certfile': None,
36
+ 'use_ssl': False,
37
+ 'verify_certs': True
38
+ }
39
+
40
+ kazoo_utils.make_client(conf)
41
+
42
+ mock_kazoo_client.assert_called_once_with(**expected)
43
+
44
+ mock_kazoo_client.reset_mock()
45
+
46
+ # With boolean passed as strings
47
+ conf = {
48
+ 'use_ssl': 'True',
49
+ 'verify_certs': 'False'
50
+ }
51
+ expected = {
52
+ 'hosts': 'localhost:2181',
53
+ 'logger': mock.ANY,
54
+ 'read_only': False,
55
+ 'randomize_hosts': False,
56
+ 'keyfile': None,
57
+ 'keyfile_password': None,
58
+ 'certfile': None,
59
+ 'use_ssl': True,
60
+ 'verify_certs': False
61
+ }
62
+
63
+ kazoo_utils.make_client(conf)
64
+
65
+ mock_kazoo_client.assert_called_once_with(**expected)
66
+
67
+ mock_kazoo_client.reset_mock()
@@ -17,6 +17,7 @@
17
17
  from kazoo import client
18
18
  from kazoo import exceptions as k_exc
19
19
  from oslo_utils import reflection
20
+ from oslo_utils import strutils
20
21
 
21
22
  from taskflow import exceptions as exc
22
23
  from taskflow import logging
@@ -24,6 +25,15 @@ from taskflow import logging
24
25
 
25
26
  LOG = logging.getLogger(__name__)
26
27
 
28
+ CONF_TRANSFERS = (
29
+ ('read_only', strutils.bool_from_string, False),
30
+ ('randomize_hosts', strutils.bool_from_string, False),
31
+ ('keyfile', None, None),
32
+ ('keyfile_password', None, None),
33
+ ('certfile', None, None),
34
+ ('use_ssl', strutils.bool_from_string, False),
35
+ ('verify_certs', strutils.bool_from_string, True))
36
+
27
37
 
28
38
  def _parse_hosts(hosts):
29
39
  if isinstance(hosts, str):
@@ -193,16 +203,19 @@ def make_client(conf):
193
203
  """
194
204
  # See: https://kazoo.readthedocs.io/en/latest/api/client.html
195
205
  client_kwargs = {
196
- 'read_only': bool(conf.get('read_only')),
197
- 'randomize_hosts': bool(conf.get('randomize_hosts')),
198
206
  'logger': LOG,
199
- 'keyfile': conf.get('keyfile', None),
200
- 'keyfile_password': conf.get('keyfile_password', None),
201
- 'certfile': conf.get('certfile', None),
202
- 'use_ssl': conf.get('use_ssl', False),
203
- 'verify_certs': conf.get('verify_certs', True),
204
-
205
207
  }
208
+
209
+ for key, value_type_converter, default in CONF_TRANSFERS:
210
+ if key in conf:
211
+ if value_type_converter is not None:
212
+ client_kwargs[key] = value_type_converter(conf[key],
213
+ default=default)
214
+ else:
215
+ client_kwargs[key] = conf[key]
216
+ else:
217
+ client_kwargs[key] = default
218
+
206
219
  # See: https://kazoo.readthedocs.io/en/latest/api/retry.html
207
220
  if 'command_retry' in conf:
208
221
  client_kwargs['command_retry'] = conf['command_retry']
@@ -17,12 +17,6 @@
17
17
  import jsonschema
18
18
  from jsonschema import exceptions as schema_exc
19
19
 
20
- # Special jsonschema validation types/adjustments.
21
- _SCHEMA_TYPES = {
22
- # See: https://github.com/Julian/jsonschema/issues/148
23
- 'array': (list, tuple),
24
- }
25
-
26
20
 
27
21
  # Expose these types so that people don't have to import the same exceptions.
28
22
  ValidationError = schema_exc.ValidationError
@@ -31,4 +25,11 @@ SchemaError = schema_exc.SchemaError
31
25
 
32
26
  def schema_validate(data, schema):
33
27
  """Validates given data using provided json schema."""
34
- jsonschema.validate(data, schema, types=_SCHEMA_TYPES)
28
+ Validator = jsonschema.validators.validator_for(schema)
29
+ # Special jsonschema validation types/adjustments.
30
+ # See: https://github.com/Julian/jsonschema/issues/148
31
+ type_checker = Validator.TYPE_CHECKER.redefine(
32
+ "array", lambda checker, data: isinstance(data, (list, tuple)))
33
+ TupleAllowingValidator = jsonschema.validators.extend(
34
+ Validator, type_checker=type_checker)
35
+ TupleAllowingValidator(schema).validate(data)
@@ -97,6 +97,7 @@ liuwei <liuw147@chinaunicom.cn>
97
97
  luke.li <lilu7189@fiberhome.com>
98
98
  maaoyu <maaoyu@inspur.com>
99
99
  melissaml <ma.lei@99cloud.net>
100
+ niuke <niuke19970315@163.com>
100
101
  qinchunhua <qin.chunhua@zte.com.cn>
101
102
  rahulram <rahurama@cisco.com>
102
103
  skudriashev <skudriashev@griddynamics.com>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: taskflow
3
- Version: 5.0.0
3
+ Version: 5.1.1
4
4
  Summary: Taskflow structured state management library.
5
5
  Home-page: https://docs.openstack.org/taskflow/latest/
6
6
  Author: OpenStack
@@ -106,7 +106,7 @@ taskflow/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
106
106
  taskflow/jobs/base.py,sha256=ncIAaBBHIdQ71kvKfOVvoq2noFjrNnmOwVT9YNFh5Yg,22043
107
107
  taskflow/jobs/backends/__init__.py,sha256=ILlqq_U0FPM77nPQgx_OexjHxUvC5Tl4RXkX-IznSfw,2902
108
108
  taskflow/jobs/backends/impl_redis.py,sha256=ANcQODjj_f_biMWas1p0sgwUXfa9X32mrL1OSeHR4J4,43520
109
- taskflow/jobs/backends/impl_zookeeper.py,sha256=BmAQ2LtzafvgoMvN1uSR9whEsKeMv0T15ffpEwKyj1c,37555
109
+ taskflow/jobs/backends/impl_zookeeper.py,sha256=yMwhmyXRknhOpJiV2gHQQnHv885JAOWss-LGOM6SoQQ,37643
110
110
  taskflow/listeners/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
111
111
  taskflow/listeners/base.py,sha256=vhbh4CcTW9iulQCG-A5G0iJDp7-j1m1XALYRewOanik,7391
112
112
  taskflow/listeners/capturing.py,sha256=14wrkVMrlmPm5jTnTTFM0RFv4PuKMIaIEPmYA4Ki4TA,4329
@@ -126,7 +126,7 @@ taskflow/persistence/backends/__init__.py,sha256=z5k5CZNjtbKvj2uxqNrdPmREDUGlTMr
126
126
  taskflow/persistence/backends/impl_dir.py,sha256=t8YQe4llF4ghguTh45BBEzRvvtpCllaAbuFZhOY_4os,6085
127
127
  taskflow/persistence/backends/impl_memory.py,sha256=PHKHqeV_KkkwCpT42J2j22o8gfdjAKt3recCP6k5TUw,13390
128
128
  taskflow/persistence/backends/impl_sqlalchemy.py,sha256=eHPgb217qQRpJhp3VtGgpUufeTHCimDgcMSo2lKvUb0,25408
129
- taskflow/persistence/backends/impl_zookeeper.py,sha256=sV6nunPEY_plZFbRdVUZRVu_y7awCtMxwhMvx7aV1o4,6096
129
+ taskflow/persistence/backends/impl_zookeeper.py,sha256=PaJmf-xDk7udmYzrMxRM-ARrd1HfAucqQjYIljmpixM,6188
130
130
  taskflow/persistence/backends/sqlalchemy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
131
131
  taskflow/persistence/backends/sqlalchemy/migration.py,sha256=YS4UPcygmYV1lRTogPUuyMM39DupIZ1LwuD23yoaEno,1140
132
132
  taskflow/persistence/backends/sqlalchemy/tables.py,sha256=CUHMWfVIK9bim-APx4QSmFuru1FyJIrOFl7hT51dQcs,4819
@@ -174,7 +174,8 @@ taskflow/tests/unit/test_types.py,sha256=uecv0lBqPAfAdTDXYMoM8Pi-P9JROR-aA_xkK0t
174
174
  taskflow/tests/unit/test_utils.py,sha256=WnTW4hVhq16O0I88K1oMEv1X8x1DMMaK8H_wT2q9W8E,11029
175
175
  taskflow/tests/unit/test_utils_async_utils.py,sha256=BkVaxbRO3XX2ueAy6kSplq4D1SVos8DOaf9V1mueEf4,981
176
176
  taskflow/tests/unit/test_utils_binary.py,sha256=OdF2BIeUCIP4hXi6QsYv8IqZtDpmqCZySlv5nLZ6UOk,3168
177
- taskflow/tests/unit/test_utils_iter_utils.py,sha256=0CoXh3IHFki7Pz6Ynby0kqvSasVCR8zQlK-wo_7Tj3I,5551
177
+ taskflow/tests/unit/test_utils_iter_utils.py,sha256=jzUJzUtfL1EPRoQLoUzZ0chlkuTKoqQKHjz7F-LaZ3Y,5716
178
+ taskflow/tests/unit/test_utils_kazoo_utils.py,sha256=lYV5ust99XF-ExaPaZ6_laPSJDewT6cTrBWw9X13nGw,1963
178
179
  taskflow/tests/unit/test_utils_threading_utils.py,sha256=JxWTMFQwjUXmsEBKl6c207VPpZn3Wh_lY3MYH-iEFUA,5503
179
180
  taskflow/tests/unit/action_engine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
180
181
  taskflow/tests/unit/action_engine/test_builder.py,sha256=tuL4LoPpnvqnGBE9qAoVXVHLzARGwhhOu4q1cSnvZ68,12866
@@ -186,7 +187,7 @@ taskflow/tests/unit/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
186
187
  taskflow/tests/unit/jobs/base.py,sha256=wYv5ziDeVdYn2nhuMSfYTWU39Xxpv8lRKvJbGsB79lM,8447
187
188
  taskflow/tests/unit/jobs/test_entrypoint.py,sha256=t2m5zeYhjb2pmPxBgGO_0AMWR0dabWxglDBODzLE0fY,2220
188
189
  taskflow/tests/unit/jobs/test_redis_job.py,sha256=GSYGoBS7c9Sd5cJlBmx3B6vUKQR4yXkUlOHdzhNNGqs,5174
189
- taskflow/tests/unit/jobs/test_zk_job.py,sha256=F0Fe7dbtSoKNQA-pO7dIHTL6uicCei18iJL_1AqVxJo,12225
190
+ taskflow/tests/unit/jobs/test_zk_job.py,sha256=K9FU38I-w_pybn81pK4ULffJdssxPLzc4W-brRRgIX8,13797
190
191
  taskflow/tests/unit/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
191
192
  taskflow/tests/unit/patterns/test_graph_flow.py,sha256=ywPavkeuES91IphE2mqGpHbUk9w_DZJMNra_RKuVWAU,12464
192
193
  taskflow/tests/unit/patterns/test_linear_flow.py,sha256=VMSU1lPq4pgkmKHeM70ZJglG1T-MylrNX6NuPGKBeX4,5145
@@ -223,18 +224,18 @@ taskflow/utils/async_utils.py,sha256=aoRp7cY8cm5jSsOy3RyV5Fjr27U2J_V6ldMYVWTPJJ4
223
224
  taskflow/utils/banner.py,sha256=_44ZM33gye8orjUN4B_VdQe8ksEPAK3WI6pfrMMiEiE,3635
224
225
  taskflow/utils/eventlet_utils.py,sha256=-0Tpw9x8UmQYXbyCbh751k1D5gPYVQv2zqCRis3vcmE,1149
225
226
  taskflow/utils/iter_utils.py,sha256=RAMpEe7pYsXXoObke0Jh2ePpfdX7cTDxhTgHua2v37M,4674
226
- taskflow/utils/kazoo_utils.py,sha256=kqBvM43I9iRbroeAr42dh84fGR3d0kT5gnWxuXAtHmU,9521
227
+ taskflow/utils/kazoo_utils.py,sha256=fCHMC-a5ayJqzBVjdTiy1WqBE6hSmRwxx7GkF-jd6Nw,9915
227
228
  taskflow/utils/kombu_utils.py,sha256=tgAN6c7kSggbT0rMn3rVzkKm9e1CmW90Jpb5279G2zg,2528
228
229
  taskflow/utils/misc.py,sha256=yHfRx6P0TqADiL-f-m5H74ugG2U7p5ktYkMK9DVGdWA,18504
229
230
  taskflow/utils/persistence_utils.py,sha256=GWceOcxdfsf-MtrdR74xmC2khClF8im6DpZmR2UpYuU,3899
230
231
  taskflow/utils/redis_utils.py,sha256=G3QinnXJFcNWKIDhw_nwVO6QtZxzjA9w57DJs8N2qC4,4369
231
- taskflow/utils/schema_utils.py,sha256=pQxt31sz-l--ufIbsBpql58mu0iktZXAjyCxwxR231I,1199
232
+ taskflow/utils/schema_utils.py,sha256=Zf6eL0NK0_TVFD_Sc1yEZYswFz9K0tet1Dmj48F8uMA,1434
232
233
  taskflow/utils/threading_utils.py,sha256=eiaNUK127DOBr_zfj3-j4Oi5a2dsD7VunVeTYN6NjPo,5849
233
- taskflow-5.0.0.dist-info/AUTHORS,sha256=P7_HgYtGEK4P6xFFhjB9HZU39_TO4lod2rqPTjEQeFU,4345
234
- taskflow-5.0.0.dist-info/LICENSE,sha256=0t4vVm0tDgtQn7DqH6Nmn0kGSrHeIcV0U8qzdQojTo8,10143
235
- taskflow-5.0.0.dist-info/METADATA,sha256=AV8kWvvR84LY4uywfeaJJZNrhXzlgQaWrKM_1ai_R4E,5036
236
- taskflow-5.0.0.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
237
- taskflow-5.0.0.dist-info/entry_points.txt,sha256=MGjjnng_YpSJs9BMAJBC2hJnljMV0pNllXl_5VoHJV0,1183
238
- taskflow-5.0.0.dist-info/pbr.json,sha256=Cluc2FMozs5sx5RsthVlLQG6aesudF0VJLu9zv2lGsc,47
239
- taskflow-5.0.0.dist-info/top_level.txt,sha256=PsdN41vwysesDlqHCSVVXH4mkTMdMiZFW_yHEAXiZE4,9
240
- taskflow-5.0.0.dist-info/RECORD,,
234
+ taskflow-5.1.1.dist-info/AUTHORS,sha256=YKkAn3T15aBNUg0A7QgHXZ3c5EkcZCVus2pVqydp520,4375
235
+ taskflow-5.1.1.dist-info/LICENSE,sha256=0t4vVm0tDgtQn7DqH6Nmn0kGSrHeIcV0U8qzdQojTo8,10143
236
+ taskflow-5.1.1.dist-info/METADATA,sha256=687s8OImJPu_hi-kUABc3BUBIzZHeq50QVEcZntkhl0,5036
237
+ taskflow-5.1.1.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
238
+ taskflow-5.1.1.dist-info/entry_points.txt,sha256=MGjjnng_YpSJs9BMAJBC2hJnljMV0pNllXl_5VoHJV0,1183
239
+ taskflow-5.1.1.dist-info/pbr.json,sha256=8WxZ922I9fo3mk5RLexixZioeQ97VUZU4Edc4Wm-B9c,47
240
+ taskflow-5.1.1.dist-info/top_level.txt,sha256=PsdN41vwysesDlqHCSVVXH4mkTMdMiZFW_yHEAXiZE4,9
241
+ taskflow-5.1.1.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ {"git_version": "78aa34f4", "is_release": true}
@@ -1 +0,0 @@
1
- {"git_version": "6dfc1801", "is_release": true}