taskflow 5.12.0__py3-none-any.whl → 6.0.0__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.
- taskflow/atom.py +3 -5
- taskflow/conductors/backends/__init__.py +0 -2
- taskflow/conductors/backends/impl_blocking.py +1 -3
- taskflow/conductors/backends/impl_executor.py +3 -6
- taskflow/conductors/backends/impl_nonblocking.py +1 -3
- taskflow/conductors/base.py +1 -3
- taskflow/deciders.py +0 -2
- taskflow/engines/__init__.py +0 -2
- taskflow/engines/action_engine/actions/base.py +1 -3
- taskflow/engines/action_engine/actions/retry.py +1 -3
- taskflow/engines/action_engine/actions/task.py +1 -3
- taskflow/engines/action_engine/builder.py +2 -4
- taskflow/engines/action_engine/compiler.py +9 -11
- taskflow/engines/action_engine/completer.py +5 -7
- taskflow/engines/action_engine/deciders.py +1 -3
- taskflow/engines/action_engine/engine.py +4 -26
- taskflow/engines/action_engine/executor.py +2 -4
- taskflow/engines/action_engine/runtime.py +1 -3
- taskflow/engines/action_engine/scheduler.py +3 -5
- taskflow/engines/action_engine/scopes.py +3 -5
- taskflow/engines/action_engine/selector.py +1 -3
- taskflow/engines/action_engine/traversal.py +0 -2
- taskflow/engines/base.py +1 -3
- taskflow/engines/helpers.py +0 -2
- taskflow/engines/worker_based/dispatcher.py +2 -4
- taskflow/engines/worker_based/endpoint.py +1 -3
- taskflow/engines/worker_based/engine.py +1 -4
- taskflow/engines/worker_based/executor.py +0 -2
- taskflow/engines/worker_based/protocol.py +1 -3
- taskflow/engines/worker_based/proxy.py +2 -4
- taskflow/engines/worker_based/server.py +3 -5
- taskflow/engines/worker_based/types.py +6 -7
- taskflow/engines/worker_based/worker.py +4 -6
- taskflow/examples/99_bottles.py +0 -2
- taskflow/examples/alphabet_soup.py +0 -2
- taskflow/examples/build_a_car.py +1 -3
- taskflow/examples/buildsystem.py +1 -3
- taskflow/examples/calculate_in_parallel.py +1 -3
- taskflow/examples/calculate_linear.py +3 -5
- taskflow/examples/create_parallel_volume.py +2 -5
- taskflow/examples/delayed_return.py +1 -3
- taskflow/examples/distance_calculator.py +12 -24
- taskflow/examples/dump_memory_backend.py +1 -3
- taskflow/examples/echo_listener.py +0 -2
- taskflow/examples/example_utils.py +1 -3
- taskflow/examples/fake_billing.py +9 -11
- taskflow/examples/graph_flow.py +2 -4
- taskflow/examples/hello_world.py +2 -4
- taskflow/examples/jobboard_produce_consume_colors.py +3 -5
- taskflow/examples/parallel_table_multiply.py +1 -3
- taskflow/examples/persistence_example.py +1 -3
- taskflow/examples/pseudo_scoping.py +2 -4
- taskflow/examples/resume_from_backend.py +1 -3
- taskflow/examples/resume_many_flows/my_flows.py +0 -2
- taskflow/examples/resume_many_flows/resume_all.py +1 -3
- taskflow/examples/resume_many_flows/run_flow.py +2 -4
- taskflow/examples/resume_many_flows.py +0 -2
- taskflow/examples/resume_vm_boot.py +12 -15
- taskflow/examples/resume_volume_create.py +3 -5
- taskflow/examples/retry_flow.py +0 -2
- taskflow/examples/reverting_linear.py +1 -3
- taskflow/examples/run_by_iter.py +0 -2
- taskflow/examples/run_by_iter_enumerate.py +1 -3
- taskflow/examples/share_engine_thread.py +2 -4
- taskflow/examples/simple_linear.py +0 -2
- taskflow/examples/simple_linear_listening.py +1 -3
- taskflow/examples/simple_linear_pass.py +0 -2
- taskflow/examples/simple_map_reduce.py +0 -2
- taskflow/examples/switch_graph_flow.py +1 -3
- taskflow/examples/timing_listener.py +1 -3
- taskflow/examples/tox_conductor.py +3 -5
- taskflow/examples/wbe_event_sender.py +0 -2
- taskflow/examples/wbe_mandelbrot.py +0 -2
- taskflow/examples/wbe_simple_linear.py +0 -2
- taskflow/examples/wrapped_exception.py +0 -2
- taskflow/exceptions.py +7 -9
- taskflow/flow.py +1 -3
- taskflow/formatters.py +22 -8
- taskflow/jobs/backends/__init__.py +0 -2
- taskflow/jobs/backends/impl_redis.py +22 -18
- taskflow/jobs/backends/impl_zookeeper.py +7 -8
- taskflow/jobs/base.py +5 -7
- taskflow/listeners/base.py +1 -3
- taskflow/listeners/capturing.py +1 -3
- taskflow/listeners/claims.py +1 -3
- taskflow/listeners/logging.py +10 -6
- taskflow/listeners/printing.py +1 -3
- taskflow/listeners/timing.py +10 -13
- taskflow/logging.py +0 -2
- taskflow/patterns/graph_flow.py +2 -4
- taskflow/patterns/linear_flow.py +4 -9
- taskflow/patterns/unordered_flow.py +4 -9
- taskflow/persistence/backends/__init__.py +1 -3
- taskflow/persistence/backends/impl_dir.py +3 -6
- taskflow/persistence/backends/impl_memory.py +6 -9
- taskflow/persistence/backends/impl_sqlalchemy.py +4 -6
- taskflow/persistence/backends/impl_zookeeper.py +2 -4
- taskflow/persistence/backends/sqlalchemy/alembic/env.py +0 -2
- taskflow/persistence/backends/sqlalchemy/alembic/versions/00af93df9d77_add_unique_into_all_indexes.py +80 -0
- taskflow/persistence/backends/sqlalchemy/alembic/versions/14b227d79a87_add_intention_column.py +0 -2
- taskflow/persistence/backends/sqlalchemy/alembic/versions/1c783c0c2875_replace_exception_an.py +0 -2
- taskflow/persistence/backends/sqlalchemy/alembic/versions/1cea328f0f65_initial_logbook_deta.py +0 -2
- taskflow/persistence/backends/sqlalchemy/alembic/versions/2ad4984f2864_switch_postgres_to_json_native.py +0 -2
- taskflow/persistence/backends/sqlalchemy/alembic/versions/3162c0f3f8e4_add_revert_results_and_revert_failure_.py +0 -2
- taskflow/persistence/backends/sqlalchemy/alembic/versions/589dccdf2b6e_rename_taskdetails_to_atomdetails.py +0 -2
- taskflow/persistence/backends/sqlalchemy/alembic/versions/84d6e888850_add_task_detail_type.py +0 -2
- taskflow/persistence/backends/sqlalchemy/tables.py +0 -2
- taskflow/persistence/base.py +2 -4
- taskflow/persistence/models.py +19 -24
- taskflow/persistence/path_based.py +1 -3
- taskflow/retry.py +12 -18
- taskflow/states.py +0 -2
- taskflow/storage.py +9 -11
- taskflow/task.py +15 -18
- taskflow/test.py +5 -5
- taskflow/tests/test_examples.py +0 -2
- taskflow/tests/unit/action_engine/test_builder.py +1 -3
- taskflow/tests/unit/action_engine/test_compile.py +4 -6
- taskflow/tests/unit/action_engine/test_creation.py +0 -21
- taskflow/tests/unit/action_engine/test_scoping.py +1 -3
- taskflow/tests/unit/jobs/base.py +1 -3
- taskflow/tests/unit/jobs/test_entrypoint.py +0 -2
- taskflow/tests/unit/jobs/test_redis_job.py +1 -3
- taskflow/tests/unit/jobs/test_zk_job.py +2 -4
- taskflow/tests/unit/patterns/test_graph_flow.py +18 -20
- taskflow/tests/unit/patterns/test_linear_flow.py +7 -9
- taskflow/tests/unit/patterns/test_unordered_flow.py +12 -14
- taskflow/tests/unit/persistence/base.py +2 -4
- taskflow/tests/unit/persistence/test_dir_persistence.py +2 -4
- taskflow/tests/unit/persistence/test_memory_persistence.py +2 -4
- taskflow/tests/unit/persistence/test_sql_persistence.py +4 -6
- taskflow/tests/unit/persistence/test_zk_persistence.py +2 -4
- taskflow/tests/unit/test_arguments_passing.py +3 -25
- taskflow/tests/unit/test_check_transition.py +3 -5
- taskflow/tests/unit/test_conductors.py +0 -2
- taskflow/tests/unit/test_deciders.py +1 -3
- taskflow/tests/unit/test_engine_helpers.py +0 -2
- taskflow/tests/unit/test_engines.py +19 -102
- taskflow/tests/unit/test_exceptions.py +4 -6
- taskflow/tests/unit/test_failure.py +10 -12
- taskflow/tests/unit/test_flow_dependencies.py +62 -64
- taskflow/tests/unit/test_formatters.py +0 -2
- taskflow/tests/unit/test_functor_task.py +1 -3
- taskflow/tests/unit/test_listeners.py +9 -11
- taskflow/tests/unit/test_mapfunctor_task.py +1 -3
- taskflow/tests/unit/test_notifier.py +1 -3
- taskflow/tests/unit/test_progress.py +2 -4
- taskflow/tests/unit/test_reducefunctor_task.py +1 -3
- taskflow/tests/unit/test_retries.py +1 -25
- taskflow/tests/unit/test_states.py +0 -2
- taskflow/tests/unit/test_storage.py +10 -12
- taskflow/tests/unit/test_suspend.py +2 -23
- taskflow/tests/unit/test_task.py +17 -19
- taskflow/tests/unit/test_types.py +4 -6
- taskflow/tests/unit/test_utils.py +9 -11
- taskflow/tests/unit/test_utils_async_utils.py +0 -2
- taskflow/tests/unit/test_utils_binary.py +12 -14
- taskflow/tests/unit/test_utils_iter_utils.py +1 -3
- taskflow/tests/unit/test_utils_kazoo_utils.py +0 -2
- taskflow/tests/unit/test_utils_threading_utils.py +1 -3
- taskflow/tests/unit/worker_based/test_creation.py +0 -2
- taskflow/tests/unit/worker_based/test_dispatcher.py +0 -2
- taskflow/tests/unit/worker_based/test_endpoint.py +2 -4
- taskflow/tests/unit/worker_based/test_executor.py +1 -3
- taskflow/tests/unit/worker_based/test_message_pump.py +0 -2
- taskflow/tests/unit/worker_based/test_pipeline.py +0 -2
- taskflow/tests/unit/worker_based/test_protocol.py +2 -4
- taskflow/tests/unit/worker_based/test_proxy.py +2 -4
- taskflow/tests/unit/worker_based/test_server.py +3 -5
- taskflow/tests/unit/worker_based/test_types.py +0 -2
- taskflow/tests/unit/worker_based/test_worker.py +1 -3
- taskflow/tests/utils.py +11 -15
- taskflow/types/entity.py +1 -3
- taskflow/types/failure.py +3 -6
- taskflow/types/graph.py +14 -18
- taskflow/types/latch.py +1 -3
- taskflow/types/notifier.py +6 -9
- taskflow/types/sets.py +2 -5
- taskflow/types/timing.py +1 -3
- taskflow/types/tree.py +6 -10
- taskflow/utils/async_utils.py +0 -2
- taskflow/utils/banner.py +8 -9
- taskflow/utils/eventlet_utils.py +0 -2
- taskflow/utils/iter_utils.py +0 -2
- taskflow/utils/kazoo_utils.py +7 -9
- taskflow/utils/kombu_utils.py +5 -7
- taskflow/utils/misc.py +4 -6
- taskflow/utils/persistence_utils.py +0 -2
- taskflow/utils/redis_utils.py +2 -4
- taskflow/utils/schema_utils.py +0 -2
- taskflow/utils/threading_utils.py +1 -3
- taskflow/version.py +1 -3
- {taskflow-5.12.0.dist-info → taskflow-6.0.0.dist-info}/AUTHORS +1 -0
- {taskflow-5.12.0.dist-info → taskflow-6.0.0.dist-info}/METADATA +1 -1
- taskflow-6.0.0.dist-info/RECORD +243 -0
- {taskflow-5.12.0.dist-info → taskflow-6.0.0.dist-info}/WHEEL +1 -1
- taskflow-6.0.0.dist-info/pbr.json +1 -0
- taskflow/engines/action_engine/process_executor.py +0 -720
- taskflow/tests/unit/action_engine/test_process_executor.py +0 -106
- taskflow-5.12.0.dist-info/RECORD +0 -244
- taskflow-5.12.0.dist-info/pbr.json +0 -1
- {taskflow-5.12.0.dist-info → taskflow-6.0.0.dist-info}/LICENSE +0 -0
- {taskflow-5.12.0.dist-info → taskflow-6.0.0.dist-info}/entry_points.txt +0 -0
- {taskflow-5.12.0.dist-info → taskflow-6.0.0.dist-info}/top_level.txt +0 -0
taskflow/tests/utils.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -151,7 +149,7 @@ class GiveBackRevert(task.Task):
|
|
|
151
149
|
return result + 1
|
|
152
150
|
|
|
153
151
|
|
|
154
|
-
class FakeTask
|
|
152
|
+
class FakeTask:
|
|
155
153
|
|
|
156
154
|
def execute(self, **kwargs):
|
|
157
155
|
pass
|
|
@@ -169,16 +167,14 @@ RUNTIME_ERROR_CLASSES = ['RuntimeError', 'Exception', 'BaseException',
|
|
|
169
167
|
|
|
170
168
|
class ProvidesRequiresTask(task.Task):
|
|
171
169
|
def __init__(self, name, provides, requires, return_tuple=True):
|
|
172
|
-
super(
|
|
173
|
-
provides=provides,
|
|
174
|
-
requires=requires)
|
|
170
|
+
super().__init__(name=name, provides=provides, requires=requires)
|
|
175
171
|
self.return_tuple = isinstance(provides, (tuple, list))
|
|
176
172
|
|
|
177
173
|
def execute(self, *args, **kwargs):
|
|
178
174
|
if self.return_tuple:
|
|
179
175
|
return tuple(range(len(self.provides)))
|
|
180
176
|
else:
|
|
181
|
-
return
|
|
177
|
+
return {k: k for k in self.provides}
|
|
182
178
|
|
|
183
179
|
|
|
184
180
|
# Used to format the captured values into strings (which are easier to
|
|
@@ -197,7 +193,7 @@ class CaptureListener(capturing.CaptureListener):
|
|
|
197
193
|
name_postfix, name_key = LOOKUP_NAME_POSTFIX[kind]
|
|
198
194
|
name = details[name_key] + name_postfix
|
|
199
195
|
if 'result' in details:
|
|
200
|
-
name += '
|
|
196
|
+
name += ' {}({})'.format(state, details['result'])
|
|
201
197
|
else:
|
|
202
198
|
name += " %s" % state
|
|
203
199
|
return name
|
|
@@ -387,9 +383,9 @@ class SleepTask(task.Task):
|
|
|
387
383
|
time.sleep(duration)
|
|
388
384
|
|
|
389
385
|
|
|
390
|
-
class EngineTestBase
|
|
386
|
+
class EngineTestBase:
|
|
391
387
|
def setUp(self):
|
|
392
|
-
super(
|
|
388
|
+
super().setUp()
|
|
393
389
|
self.backend = impl_memory.MemoryBackend(conf={})
|
|
394
390
|
|
|
395
391
|
def tearDown(self):
|
|
@@ -397,7 +393,7 @@ class EngineTestBase(object):
|
|
|
397
393
|
with contextlib.closing(self.backend) as be:
|
|
398
394
|
with contextlib.closing(be.get_connection()) as conn:
|
|
399
395
|
conn.clear_all()
|
|
400
|
-
super(
|
|
396
|
+
super().tearDown()
|
|
401
397
|
|
|
402
398
|
def _make_engine(self, flow, **kwargs):
|
|
403
399
|
raise exceptions.NotImplementedError("_make_engine() must be"
|
|
@@ -405,7 +401,7 @@ class EngineTestBase(object):
|
|
|
405
401
|
" desired")
|
|
406
402
|
|
|
407
403
|
|
|
408
|
-
class FailureMatcher
|
|
404
|
+
class FailureMatcher:
|
|
409
405
|
"""Needed for failure objects comparison."""
|
|
410
406
|
|
|
411
407
|
def __init__(self, failure):
|
|
@@ -433,7 +429,7 @@ class OneReturnRetry(retry.AlwaysRevert):
|
|
|
433
429
|
class ConditionalTask(ProgressingTask):
|
|
434
430
|
|
|
435
431
|
def execute(self, x, y):
|
|
436
|
-
super(
|
|
432
|
+
super().execute()
|
|
437
433
|
if x != y:
|
|
438
434
|
raise RuntimeError('Woot!')
|
|
439
435
|
|
|
@@ -441,7 +437,7 @@ class ConditionalTask(ProgressingTask):
|
|
|
441
437
|
class WaitForOneFromTask(ProgressingTask):
|
|
442
438
|
|
|
443
439
|
def __init__(self, name, wait_for, wait_states, **kwargs):
|
|
444
|
-
super(
|
|
440
|
+
super().__init__(name, **kwargs)
|
|
445
441
|
if isinstance(wait_for, str):
|
|
446
442
|
self.wait_for = [wait_for]
|
|
447
443
|
else:
|
|
@@ -458,7 +454,7 @@ class WaitForOneFromTask(ProgressingTask):
|
|
|
458
454
|
'for %s to change state to %s'
|
|
459
455
|
% (WAIT_TIMEOUT, self.wait_for,
|
|
460
456
|
self.wait_states))
|
|
461
|
-
return super(
|
|
457
|
+
return super().execute()
|
|
462
458
|
|
|
463
459
|
def callback(self, state, details):
|
|
464
460
|
name = details.get('task_name', None)
|
taskflow/types/entity.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2015 Rackspace Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -15,7 +13,7 @@
|
|
|
15
13
|
# under the License.
|
|
16
14
|
|
|
17
15
|
|
|
18
|
-
class Entity
|
|
16
|
+
class Entity:
|
|
19
17
|
"""Entity object that identifies some resource/item/other.
|
|
20
18
|
|
|
21
19
|
:ivar kind: **immutable** type/kind that identifies this
|
taskflow/types/failure.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -433,8 +431,8 @@ class Failure():
|
|
|
433
431
|
if not self._exc_type_names:
|
|
434
432
|
buf.write('Failure: %s' % (self._exception_str))
|
|
435
433
|
else:
|
|
436
|
-
buf.write('Failure:
|
|
437
|
-
|
|
434
|
+
buf.write('Failure: {}: {}'.format(self._exc_type_names[0],
|
|
435
|
+
self._exception_str))
|
|
438
436
|
if traceback:
|
|
439
437
|
if self._traceback_str is not None:
|
|
440
438
|
traceback_str = self._traceback_str.rstrip()
|
|
@@ -452,8 +450,7 @@ class Failure():
|
|
|
452
450
|
|
|
453
451
|
def __iter__(self):
|
|
454
452
|
"""Iterate over exception type names."""
|
|
455
|
-
|
|
456
|
-
yield et
|
|
453
|
+
yield from self._exc_type_names
|
|
457
454
|
|
|
458
455
|
def __getstate__(self):
|
|
459
456
|
dct = self.to_dict()
|
taskflow/types/graph.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -31,15 +29,15 @@ def _common_format(g, edge_notation):
|
|
|
31
29
|
lines.append("Nodes: %s" % g.number_of_nodes())
|
|
32
30
|
for n, n_data in g.nodes(data=True):
|
|
33
31
|
if n_data:
|
|
34
|
-
lines.append(" -
|
|
32
|
+
lines.append(" - {} ({})".format(n, n_data))
|
|
35
33
|
else:
|
|
36
34
|
lines.append(" - %s" % n)
|
|
37
35
|
lines.append("Edges: %s" % g.number_of_edges())
|
|
38
36
|
for (u, v, e_data) in g.edges(data=True):
|
|
39
37
|
if e_data:
|
|
40
|
-
lines.append("
|
|
38
|
+
lines.append(" {} {} {} ({})".format(u, edge_notation, v, e_data))
|
|
41
39
|
else:
|
|
42
|
-
lines.append("
|
|
40
|
+
lines.append(" {} {} {}".format(u, edge_notation, v))
|
|
43
41
|
return lines
|
|
44
42
|
|
|
45
43
|
|
|
@@ -47,8 +45,7 @@ class Graph(nx.Graph):
|
|
|
47
45
|
"""A graph subclass with useful utility functions."""
|
|
48
46
|
|
|
49
47
|
def __init__(self, incoming_graph_data=None, name=''):
|
|
50
|
-
super(
|
|
51
|
-
name=name)
|
|
48
|
+
super().__init__(incoming_graph_data=incoming_graph_data, name=name)
|
|
52
49
|
self.frozen = False
|
|
53
50
|
|
|
54
51
|
def freeze(self):
|
|
@@ -68,14 +65,14 @@ class Graph(nx.Graph):
|
|
|
68
65
|
def add_edge(self, u, v, attr_dict=None, **attr):
|
|
69
66
|
"""Add an edge between u and v."""
|
|
70
67
|
if attr_dict is not None:
|
|
71
|
-
return super(
|
|
72
|
-
return super(
|
|
68
|
+
return super().add_edge(u, v, **attr_dict)
|
|
69
|
+
return super().add_edge(u, v, **attr)
|
|
73
70
|
|
|
74
71
|
def add_node(self, n, attr_dict=None, **attr):
|
|
75
72
|
"""Add a single node n and update node attributes."""
|
|
76
73
|
if attr_dict is not None:
|
|
77
|
-
return super(
|
|
78
|
-
return super(
|
|
74
|
+
return super().add_node(n, **attr_dict)
|
|
75
|
+
return super().add_node(n, **attr)
|
|
79
76
|
|
|
80
77
|
def fresh_copy(self):
|
|
81
78
|
"""Return a fresh copy graph with the same data structure.
|
|
@@ -91,8 +88,7 @@ class DiGraph(nx.DiGraph):
|
|
|
91
88
|
"""A directed graph subclass with useful utility functions."""
|
|
92
89
|
|
|
93
90
|
def __init__(self, incoming_graph_data=None, name=''):
|
|
94
|
-
super(
|
|
95
|
-
name=name)
|
|
91
|
+
super().__init__(incoming_graph_data=incoming_graph_data, name=name)
|
|
96
92
|
self.frozen = False
|
|
97
93
|
|
|
98
94
|
def freeze(self):
|
|
@@ -165,7 +161,7 @@ class DiGraph(nx.DiGraph):
|
|
|
165
161
|
NOTE(harlowja): predecessor cycles (if they exist) will not be iterated
|
|
166
162
|
over more than once (this prevents infinite iteration).
|
|
167
163
|
"""
|
|
168
|
-
visited =
|
|
164
|
+
visited = {n}
|
|
169
165
|
queue = collections.deque(self.predecessors(n))
|
|
170
166
|
while queue:
|
|
171
167
|
pred = queue.popleft()
|
|
@@ -179,14 +175,14 @@ class DiGraph(nx.DiGraph):
|
|
|
179
175
|
def add_edge(self, u, v, attr_dict=None, **attr):
|
|
180
176
|
"""Add an edge between u and v."""
|
|
181
177
|
if attr_dict is not None:
|
|
182
|
-
return super(
|
|
183
|
-
return super(
|
|
178
|
+
return super().add_edge(u, v, **attr_dict)
|
|
179
|
+
return super().add_edge(u, v, **attr)
|
|
184
180
|
|
|
185
181
|
def add_node(self, n, attr_dict=None, **attr):
|
|
186
182
|
"""Add a single node n and update node attributes."""
|
|
187
183
|
if attr_dict is not None:
|
|
188
|
-
return super(
|
|
189
|
-
return super(
|
|
184
|
+
return super().add_node(n, **attr_dict)
|
|
185
|
+
return super().add_node(n, **attr)
|
|
190
186
|
|
|
191
187
|
def fresh_copy(self):
|
|
192
188
|
"""Return a fresh copy graph with the same data structure.
|
taskflow/types/latch.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -19,7 +17,7 @@ import threading
|
|
|
19
17
|
from oslo_utils import timeutils
|
|
20
18
|
|
|
21
19
|
|
|
22
|
-
class Latch
|
|
20
|
+
class Latch:
|
|
23
21
|
"""A class that ensures N-arrivals occur before unblocking.
|
|
24
22
|
|
|
25
23
|
TODO(harlowja): replace with http://bugs.python.org/issue8777 when we no
|
taskflow/types/notifier.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -24,7 +22,7 @@ from oslo_utils import reflection
|
|
|
24
22
|
LOG = logging.getLogger(__name__)
|
|
25
23
|
|
|
26
24
|
|
|
27
|
-
class Listener
|
|
25
|
+
class Listener:
|
|
28
26
|
"""Immutable helper that represents a notification listener/target."""
|
|
29
27
|
|
|
30
28
|
def __init__(self, callback, args=None, kwargs=None, details_filter=None):
|
|
@@ -89,7 +87,7 @@ class Listener(object):
|
|
|
89
87
|
self._callback(event_type, *self._args, **kwargs)
|
|
90
88
|
|
|
91
89
|
def __repr__(self):
|
|
92
|
-
repr_msg = "
|
|
90
|
+
repr_msg = "{} object at 0x{:x} calling into '{!r}'".format(
|
|
93
91
|
reflection.get_class_name(self, fully_qualified=False),
|
|
94
92
|
id(self), self._callback)
|
|
95
93
|
if self._details_filter is not None:
|
|
@@ -126,7 +124,7 @@ class Listener(object):
|
|
|
126
124
|
return not self.__eq__(other)
|
|
127
125
|
|
|
128
126
|
|
|
129
|
-
class Notifier
|
|
127
|
+
class Notifier:
|
|
130
128
|
"""A notification (`pub/sub`_ *like*) helper class.
|
|
131
129
|
|
|
132
130
|
It is intended to be used to subscribe to notifications of events
|
|
@@ -151,7 +149,7 @@ class Notifier(object):
|
|
|
151
149
|
ANY = '*'
|
|
152
150
|
|
|
153
151
|
#: Events which can *not* be used to trigger notifications
|
|
154
|
-
_DISALLOWED_NOTIFICATION_EVENTS =
|
|
152
|
+
_DISALLOWED_NOTIFICATION_EVENTS = {ANY}
|
|
155
153
|
|
|
156
154
|
def __init__(self):
|
|
157
155
|
self._topics = collections.defaultdict(list)
|
|
@@ -321,7 +319,7 @@ class RestrictedNotifier(Notifier):
|
|
|
321
319
|
"""
|
|
322
320
|
|
|
323
321
|
def __init__(self, watchable_events, allow_any=True):
|
|
324
|
-
super(
|
|
322
|
+
super().__init__()
|
|
325
323
|
self._watchable_events = frozenset(watchable_events)
|
|
326
324
|
self._allow_any = allow_any
|
|
327
325
|
|
|
@@ -332,8 +330,7 @@ class RestrictedNotifier(Notifier):
|
|
|
332
330
|
meta-type is not a specific event but is a capture-all that does not
|
|
333
331
|
imply the same meaning as specific event types.
|
|
334
332
|
"""
|
|
335
|
-
|
|
336
|
-
yield event_type
|
|
333
|
+
yield from self._watchable_events
|
|
337
334
|
|
|
338
335
|
def can_be_registered(self, event_type):
|
|
339
336
|
"""Checks if the event can be registered/subscribed to.
|
taskflow/types/sets.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -57,8 +55,7 @@ class OrderedSet(abc.Set, abc.Hashable):
|
|
|
57
55
|
return len(self._data)
|
|
58
56
|
|
|
59
57
|
def __iter__(self):
|
|
60
|
-
|
|
61
|
-
yield value
|
|
58
|
+
yield from self._data.keys()
|
|
62
59
|
|
|
63
60
|
def __setstate__(self, items):
|
|
64
61
|
self.__init__(iterable=iter(items))
|
|
@@ -67,7 +64,7 @@ class OrderedSet(abc.Set, abc.Hashable):
|
|
|
67
64
|
return tuple(self)
|
|
68
65
|
|
|
69
66
|
def __repr__(self):
|
|
70
|
-
return "
|
|
67
|
+
return "{}({})".format(type(self).__name__, list(self))
|
|
71
68
|
|
|
72
69
|
def copy(self):
|
|
73
70
|
"""Return a shallow copy of a set."""
|
taskflow/types/timing.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -17,7 +15,7 @@
|
|
|
17
15
|
import threading
|
|
18
16
|
|
|
19
17
|
|
|
20
|
-
class Timeout
|
|
18
|
+
class Timeout:
|
|
21
19
|
"""An object which represents a timeout.
|
|
22
20
|
|
|
23
21
|
This object has the ability to be interrupted before the actual timeout
|
taskflow/types/tree.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -28,10 +26,10 @@ class FrozenNode(Exception):
|
|
|
28
26
|
"""Exception raised when a frozen node is modified."""
|
|
29
27
|
|
|
30
28
|
def __init__(self):
|
|
31
|
-
super(
|
|
29
|
+
super().__init__("Frozen node(s) can't be modified")
|
|
32
30
|
|
|
33
31
|
|
|
34
|
-
class _DFSIter
|
|
32
|
+
class _DFSIter:
|
|
35
33
|
"""Depth first iterator (non-recursive) over the child nodes."""
|
|
36
34
|
|
|
37
35
|
def __init__(self, root, include_self=False, right_to_left=True):
|
|
@@ -60,7 +58,7 @@ class _DFSIter(object):
|
|
|
60
58
|
stack.extend(iter(node))
|
|
61
59
|
|
|
62
60
|
|
|
63
|
-
class _BFSIter
|
|
61
|
+
class _BFSIter:
|
|
64
62
|
"""Breadth first iterator (non-recursive) over the child nodes."""
|
|
65
63
|
|
|
66
64
|
def __init__(self, root, include_self=False, right_to_left=False):
|
|
@@ -89,7 +87,7 @@ class _BFSIter(object):
|
|
|
89
87
|
q.extend(node.reverse_iter())
|
|
90
88
|
|
|
91
89
|
|
|
92
|
-
class Node
|
|
90
|
+
class Node:
|
|
93
91
|
"""A n-ary node class that can be used to create tree structures."""
|
|
94
92
|
|
|
95
93
|
#: Default string prefix used in :py:meth:`.pformat`.
|
|
@@ -358,13 +356,11 @@ class Node(object):
|
|
|
358
356
|
|
|
359
357
|
def __iter__(self):
|
|
360
358
|
"""Iterates over the direct children of this node (right->left)."""
|
|
361
|
-
|
|
362
|
-
yield c
|
|
359
|
+
yield from self._children
|
|
363
360
|
|
|
364
361
|
def reverse_iter(self):
|
|
365
362
|
"""Iterates over the direct children of this node (left->right)."""
|
|
366
|
-
|
|
367
|
-
yield c
|
|
363
|
+
yield from reversed(self._children)
|
|
368
364
|
|
|
369
365
|
def index(self, item):
|
|
370
366
|
"""Finds the child index of a given item, searches in added order."""
|
taskflow/utils/async_utils.py
CHANGED
taskflow/utils/banner.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2016 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -74,12 +72,13 @@ def make_banner(what, chapters):
|
|
|
74
72
|
section_names = sorted(chapter_contents.keys())
|
|
75
73
|
for j, section_name in enumerate(section_names):
|
|
76
74
|
if j + 1 < len(section_names):
|
|
77
|
-
buf.write_nl("
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
buf.write_nl(" {} => {}".format(
|
|
76
|
+
section_name,
|
|
77
|
+
chapter_contents[section_name]))
|
|
80
78
|
else:
|
|
81
|
-
buf.write("
|
|
82
|
-
|
|
79
|
+
buf.write(" {} => {}".format(
|
|
80
|
+
section_name,
|
|
81
|
+
chapter_contents[section_name]))
|
|
83
82
|
elif isinstance(chapter_contents, (list, tuple, set)):
|
|
84
83
|
if isinstance(chapter_contents, set):
|
|
85
84
|
sections = sorted(chapter_contents)
|
|
@@ -87,9 +86,9 @@ def make_banner(what, chapters):
|
|
|
87
86
|
sections = chapter_contents
|
|
88
87
|
for j, section in enumerate(sections):
|
|
89
88
|
if j + 1 < len(sections):
|
|
90
|
-
buf.write_nl("
|
|
89
|
+
buf.write_nl(" {}. {}".format(j + 1, section))
|
|
91
90
|
else:
|
|
92
|
-
buf.write("
|
|
91
|
+
buf.write(" {}. {}".format(j + 1, section))
|
|
93
92
|
else:
|
|
94
93
|
raise TypeError("Unsupported chapter contents"
|
|
95
94
|
" type: one of dict, list, tuple, set expected"
|
taskflow/utils/eventlet_utils.py
CHANGED
taskflow/utils/iter_utils.py
CHANGED
taskflow/utils/kazoo_utils.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -41,7 +39,7 @@ def _parse_hosts(hosts):
|
|
|
41
39
|
if isinstance(hosts, (dict)):
|
|
42
40
|
host_ports = []
|
|
43
41
|
for (k, v) in hosts.items():
|
|
44
|
-
host_ports.append("
|
|
42
|
+
host_ports.append("{}:{}".format(k, v))
|
|
45
43
|
hosts = host_ports
|
|
46
44
|
if isinstance(hosts, (list, set, tuple)):
|
|
47
45
|
return ",".join([str(h) for h in hosts])
|
|
@@ -65,7 +63,7 @@ def prettify_failures(failures, limit=-1):
|
|
|
65
63
|
pass
|
|
66
64
|
pretty_op += "(%s)" % (", ".join(selected_attrs))
|
|
67
65
|
pretty_cause = reflection.get_class_name(r, fully_qualified=False)
|
|
68
|
-
prettier.append("
|
|
66
|
+
prettier.append("{}@{}".format(pretty_cause, pretty_op))
|
|
69
67
|
if limit <= 0 or len(prettier) <= limit:
|
|
70
68
|
return ", ".join(prettier)
|
|
71
69
|
else:
|
|
@@ -78,7 +76,7 @@ class KazooTransactionException(k_exc.KazooException):
|
|
|
78
76
|
"""Exception raised when a checked commit fails."""
|
|
79
77
|
|
|
80
78
|
def __init__(self, message, failures):
|
|
81
|
-
super(
|
|
79
|
+
super().__init__(message)
|
|
82
80
|
self._failures = tuple(failures)
|
|
83
81
|
|
|
84
82
|
@property
|
|
@@ -134,8 +132,8 @@ def check_compatible(client, min_version=None, max_version=None):
|
|
|
134
132
|
"""
|
|
135
133
|
server_version = None
|
|
136
134
|
if min_version:
|
|
137
|
-
server_version = tuple(
|
|
138
|
-
min_version = tuple(
|
|
135
|
+
server_version = tuple(int(a) for a in client.server_version())
|
|
136
|
+
min_version = tuple(int(a) for a in min_version)
|
|
139
137
|
if server_version < min_version:
|
|
140
138
|
pretty_server_version = ".".join([str(a) for a in server_version])
|
|
141
139
|
min_version = ".".join([str(a) for a in min_version])
|
|
@@ -145,8 +143,8 @@ def check_compatible(client, min_version=None, max_version=None):
|
|
|
145
143
|
min_version))
|
|
146
144
|
if max_version:
|
|
147
145
|
if server_version is None:
|
|
148
|
-
server_version = tuple(
|
|
149
|
-
max_version = tuple(
|
|
146
|
+
server_version = tuple(int(a) for a in client.server_version())
|
|
147
|
+
max_version = tuple(int(a) for a in max_version)
|
|
150
148
|
if server_version > max_version:
|
|
151
149
|
pretty_server_version = ".".join([str(a) for a in server_version])
|
|
152
150
|
max_version = ".".join([str(a) for a in max_version])
|
taskflow/utils/kombu_utils.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -22,7 +20,7 @@ _MSG_PROPERTIES = tuple([
|
|
|
22
20
|
])
|
|
23
21
|
|
|
24
22
|
|
|
25
|
-
class DelayedPretty
|
|
23
|
+
class DelayedPretty:
|
|
26
24
|
"""Wraps a message and delays prettifying it until requested.
|
|
27
25
|
|
|
28
26
|
TODO(harlowja): remove this when https://github.com/celery/kombu/pull/454/
|
|
@@ -70,7 +68,7 @@ def _prettify_message(message):
|
|
|
70
68
|
properties[segments[-1]] = value
|
|
71
69
|
if message.body is not None:
|
|
72
70
|
properties['body_length'] = len(message.body)
|
|
73
|
-
return "
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
return "{delivery_tag}: {properties}".format(
|
|
72
|
+
delivery_tag=message.delivery_tag,
|
|
73
|
+
properties=properties,
|
|
74
|
+
)
|
taskflow/utils/misc.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
# Copyright (C) 2013 Rackspace Hosting All Rights Reserved.
|
|
5
3
|
#
|
|
@@ -55,7 +53,7 @@ class StrEnum(str, enum.Enum):
|
|
|
55
53
|
if not isinstance(a, str):
|
|
56
54
|
raise TypeError("Enumeration '%s' (%s) is not"
|
|
57
55
|
" a string" % (a, type(a).__name__))
|
|
58
|
-
return super(
|
|
56
|
+
return super().__new__(cls, *args, **kwargs)
|
|
59
57
|
|
|
60
58
|
|
|
61
59
|
class StringIO(io.StringIO):
|
|
@@ -82,7 +80,7 @@ def get_hostname(unknown_hostname=UNKNOWN_HOSTNAME):
|
|
|
82
80
|
return unknown_hostname
|
|
83
81
|
else:
|
|
84
82
|
return hostname
|
|
85
|
-
except
|
|
83
|
+
except OSError:
|
|
86
84
|
return unknown_hostname
|
|
87
85
|
|
|
88
86
|
|
|
@@ -189,7 +187,7 @@ def find_subclasses(locations, base_cls, exclude_hidden=True):
|
|
|
189
187
|
except ValueError:
|
|
190
188
|
module = importutils.import_module(item)
|
|
191
189
|
else:
|
|
192
|
-
obj = importutils.import_class('
|
|
190
|
+
obj = importutils.import_class('{}.{}'.format(pkg, cls))
|
|
193
191
|
if not reflection.is_subclass(obj, base_cls):
|
|
194
192
|
raise TypeError("Object '%s' (%s) is not a '%s' subclass"
|
|
195
193
|
% (item, type(item), base_cls))
|
|
@@ -343,7 +341,7 @@ def decode_json(raw_data, root_types=(dict,)):
|
|
|
343
341
|
return _check_decoded_type(data, root_types=root_types)
|
|
344
342
|
|
|
345
343
|
|
|
346
|
-
class cachedproperty
|
|
344
|
+
class cachedproperty:
|
|
347
345
|
"""A *thread-safe* descriptor property that is only evaluated once.
|
|
348
346
|
|
|
349
347
|
This caching descriptor can be placed on instance methods to translate
|
taskflow/utils/redis_utils.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -41,7 +39,7 @@ class RedisClient(redis.Redis):
|
|
|
41
39
|
"""
|
|
42
40
|
|
|
43
41
|
def __init__(self, *args, **kwargs):
|
|
44
|
-
super(
|
|
42
|
+
super().__init__(*args, **kwargs)
|
|
45
43
|
self.closed = False
|
|
46
44
|
|
|
47
45
|
def close(self):
|
|
@@ -71,7 +69,7 @@ class UnknownExpire(enum.IntEnum):
|
|
|
71
69
|
DOES_NOT_EXPIRE = UnknownExpire.DOES_NOT_EXPIRE
|
|
72
70
|
KEY_NOT_FOUND = UnknownExpire.KEY_NOT_FOUND
|
|
73
71
|
|
|
74
|
-
_UNKNOWN_EXPIRE_MAPPING =
|
|
72
|
+
_UNKNOWN_EXPIRE_MAPPING = {e.value: e for e in list(UnknownExpire)}
|
|
75
73
|
|
|
76
74
|
|
|
77
75
|
def get_expiry(client, key, prior_version=None):
|
taskflow/utils/schema_utils.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2013 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -73,7 +71,7 @@ def no_op(*args, **kwargs):
|
|
|
73
71
|
"""Function that does nothing."""
|
|
74
72
|
|
|
75
73
|
|
|
76
|
-
class ThreadBundle
|
|
74
|
+
class ThreadBundle:
|
|
77
75
|
"""A group/bundle of threads that start/stop together."""
|
|
78
76
|
|
|
79
77
|
def __init__(self):
|
taskflow/version.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
# Copyright (C) 2013 Yahoo! Inc. All Rights Reserved.
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
@@ -28,4 +26,4 @@ def version_string_with_package():
|
|
|
28
26
|
if TASK_PACKAGE is None:
|
|
29
27
|
return version_string()
|
|
30
28
|
else:
|
|
31
|
-
return "
|
|
29
|
+
return "{}-{}".format(version_string(), TASK_PACKAGE)
|
|
@@ -45,6 +45,7 @@ Jeremy Stanley <fungi@yuggoth.org>
|
|
|
45
45
|
Jessica Lucci <jessica.lucci@rackspace.com>
|
|
46
46
|
Ji-Wei <ji.wei3@zte.com.cn>
|
|
47
47
|
Joe Gordon <joe.gordon0@gmail.com>
|
|
48
|
+
Jose Castro Leon <jose.castro.leon@cern.ch>
|
|
48
49
|
Joshua Harlow <harlowja@gmail.com>
|
|
49
50
|
Joshua Harlow <harlowja@yahoo-inc.com>
|
|
50
51
|
Joshua Harlow <jxharlow@godaddy.com>
|