taskflow 5.12.0__py3-none-any.whl → 6.0.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.
Files changed (204) hide show
  1. taskflow/atom.py +3 -5
  2. taskflow/conductors/backends/__init__.py +0 -2
  3. taskflow/conductors/backends/impl_blocking.py +1 -3
  4. taskflow/conductors/backends/impl_executor.py +3 -6
  5. taskflow/conductors/backends/impl_nonblocking.py +1 -3
  6. taskflow/conductors/base.py +1 -3
  7. taskflow/deciders.py +0 -2
  8. taskflow/engines/__init__.py +0 -2
  9. taskflow/engines/action_engine/actions/base.py +1 -3
  10. taskflow/engines/action_engine/actions/retry.py +1 -3
  11. taskflow/engines/action_engine/actions/task.py +1 -3
  12. taskflow/engines/action_engine/builder.py +2 -4
  13. taskflow/engines/action_engine/compiler.py +9 -11
  14. taskflow/engines/action_engine/completer.py +5 -7
  15. taskflow/engines/action_engine/deciders.py +1 -3
  16. taskflow/engines/action_engine/engine.py +4 -26
  17. taskflow/engines/action_engine/executor.py +2 -4
  18. taskflow/engines/action_engine/runtime.py +1 -3
  19. taskflow/engines/action_engine/scheduler.py +3 -5
  20. taskflow/engines/action_engine/scopes.py +3 -5
  21. taskflow/engines/action_engine/selector.py +1 -3
  22. taskflow/engines/action_engine/traversal.py +0 -2
  23. taskflow/engines/base.py +1 -3
  24. taskflow/engines/helpers.py +0 -2
  25. taskflow/engines/worker_based/dispatcher.py +2 -4
  26. taskflow/engines/worker_based/endpoint.py +1 -3
  27. taskflow/engines/worker_based/engine.py +1 -4
  28. taskflow/engines/worker_based/executor.py +0 -2
  29. taskflow/engines/worker_based/protocol.py +1 -3
  30. taskflow/engines/worker_based/proxy.py +2 -4
  31. taskflow/engines/worker_based/server.py +3 -5
  32. taskflow/engines/worker_based/types.py +6 -7
  33. taskflow/engines/worker_based/worker.py +4 -6
  34. taskflow/examples/99_bottles.py +0 -2
  35. taskflow/examples/alphabet_soup.py +0 -2
  36. taskflow/examples/build_a_car.py +1 -3
  37. taskflow/examples/buildsystem.py +1 -3
  38. taskflow/examples/calculate_in_parallel.py +1 -3
  39. taskflow/examples/calculate_linear.py +3 -5
  40. taskflow/examples/create_parallel_volume.py +2 -5
  41. taskflow/examples/delayed_return.py +1 -3
  42. taskflow/examples/distance_calculator.py +12 -24
  43. taskflow/examples/dump_memory_backend.py +1 -3
  44. taskflow/examples/echo_listener.py +0 -2
  45. taskflow/examples/example_utils.py +1 -3
  46. taskflow/examples/fake_billing.py +9 -11
  47. taskflow/examples/graph_flow.py +2 -4
  48. taskflow/examples/hello_world.py +2 -4
  49. taskflow/examples/jobboard_produce_consume_colors.py +3 -5
  50. taskflow/examples/parallel_table_multiply.py +1 -3
  51. taskflow/examples/persistence_example.py +1 -3
  52. taskflow/examples/pseudo_scoping.py +2 -4
  53. taskflow/examples/resume_from_backend.py +1 -3
  54. taskflow/examples/resume_many_flows/my_flows.py +0 -2
  55. taskflow/examples/resume_many_flows/resume_all.py +1 -3
  56. taskflow/examples/resume_many_flows/run_flow.py +2 -4
  57. taskflow/examples/resume_many_flows.py +0 -2
  58. taskflow/examples/resume_vm_boot.py +12 -15
  59. taskflow/examples/resume_volume_create.py +3 -5
  60. taskflow/examples/retry_flow.py +0 -2
  61. taskflow/examples/reverting_linear.py +1 -3
  62. taskflow/examples/run_by_iter.py +0 -2
  63. taskflow/examples/run_by_iter_enumerate.py +1 -3
  64. taskflow/examples/share_engine_thread.py +2 -4
  65. taskflow/examples/simple_linear.py +0 -2
  66. taskflow/examples/simple_linear_listening.py +1 -3
  67. taskflow/examples/simple_linear_pass.py +0 -2
  68. taskflow/examples/simple_map_reduce.py +0 -2
  69. taskflow/examples/switch_graph_flow.py +1 -3
  70. taskflow/examples/timing_listener.py +1 -3
  71. taskflow/examples/tox_conductor.py +3 -5
  72. taskflow/examples/wbe_event_sender.py +0 -2
  73. taskflow/examples/wbe_mandelbrot.py +0 -2
  74. taskflow/examples/wbe_simple_linear.py +0 -2
  75. taskflow/examples/wrapped_exception.py +0 -2
  76. taskflow/exceptions.py +7 -9
  77. taskflow/flow.py +1 -3
  78. taskflow/formatters.py +22 -8
  79. taskflow/jobs/backends/__init__.py +0 -2
  80. taskflow/jobs/backends/impl_redis.py +22 -18
  81. taskflow/jobs/backends/impl_zookeeper.py +7 -8
  82. taskflow/jobs/base.py +5 -7
  83. taskflow/listeners/base.py +1 -3
  84. taskflow/listeners/capturing.py +1 -3
  85. taskflow/listeners/claims.py +1 -3
  86. taskflow/listeners/logging.py +10 -6
  87. taskflow/listeners/printing.py +1 -3
  88. taskflow/listeners/timing.py +10 -13
  89. taskflow/logging.py +0 -2
  90. taskflow/patterns/graph_flow.py +2 -4
  91. taskflow/patterns/linear_flow.py +4 -9
  92. taskflow/patterns/unordered_flow.py +4 -9
  93. taskflow/persistence/backends/__init__.py +1 -3
  94. taskflow/persistence/backends/impl_dir.py +3 -6
  95. taskflow/persistence/backends/impl_memory.py +6 -9
  96. taskflow/persistence/backends/impl_sqlalchemy.py +4 -6
  97. taskflow/persistence/backends/impl_zookeeper.py +2 -4
  98. taskflow/persistence/backends/sqlalchemy/alembic/env.py +0 -2
  99. taskflow/persistence/backends/sqlalchemy/alembic/versions/00af93df9d77_add_unique_into_all_indexes.py +74 -0
  100. taskflow/persistence/backends/sqlalchemy/alembic/versions/14b227d79a87_add_intention_column.py +0 -2
  101. taskflow/persistence/backends/sqlalchemy/alembic/versions/1c783c0c2875_replace_exception_an.py +0 -2
  102. taskflow/persistence/backends/sqlalchemy/alembic/versions/1cea328f0f65_initial_logbook_deta.py +0 -2
  103. taskflow/persistence/backends/sqlalchemy/alembic/versions/2ad4984f2864_switch_postgres_to_json_native.py +0 -2
  104. taskflow/persistence/backends/sqlalchemy/alembic/versions/3162c0f3f8e4_add_revert_results_and_revert_failure_.py +0 -2
  105. taskflow/persistence/backends/sqlalchemy/alembic/versions/589dccdf2b6e_rename_taskdetails_to_atomdetails.py +0 -2
  106. taskflow/persistence/backends/sqlalchemy/alembic/versions/84d6e888850_add_task_detail_type.py +0 -2
  107. taskflow/persistence/backends/sqlalchemy/tables.py +0 -2
  108. taskflow/persistence/base.py +2 -4
  109. taskflow/persistence/models.py +19 -24
  110. taskflow/persistence/path_based.py +1 -3
  111. taskflow/retry.py +12 -18
  112. taskflow/states.py +0 -2
  113. taskflow/storage.py +9 -11
  114. taskflow/task.py +15 -18
  115. taskflow/test.py +5 -5
  116. taskflow/tests/test_examples.py +0 -2
  117. taskflow/tests/unit/action_engine/test_builder.py +1 -3
  118. taskflow/tests/unit/action_engine/test_compile.py +4 -6
  119. taskflow/tests/unit/action_engine/test_creation.py +0 -21
  120. taskflow/tests/unit/action_engine/test_scoping.py +1 -3
  121. taskflow/tests/unit/jobs/base.py +1 -3
  122. taskflow/tests/unit/jobs/test_entrypoint.py +0 -2
  123. taskflow/tests/unit/jobs/test_redis_job.py +1 -3
  124. taskflow/tests/unit/jobs/test_zk_job.py +2 -4
  125. taskflow/tests/unit/patterns/test_graph_flow.py +18 -20
  126. taskflow/tests/unit/patterns/test_linear_flow.py +7 -9
  127. taskflow/tests/unit/patterns/test_unordered_flow.py +12 -14
  128. taskflow/tests/unit/persistence/base.py +2 -4
  129. taskflow/tests/unit/persistence/test_dir_persistence.py +2 -4
  130. taskflow/tests/unit/persistence/test_memory_persistence.py +2 -4
  131. taskflow/tests/unit/persistence/test_sql_persistence.py +8 -10
  132. taskflow/tests/unit/persistence/test_zk_persistence.py +2 -4
  133. taskflow/tests/unit/test_arguments_passing.py +3 -25
  134. taskflow/tests/unit/test_check_transition.py +3 -5
  135. taskflow/tests/unit/test_conductors.py +0 -2
  136. taskflow/tests/unit/test_deciders.py +1 -3
  137. taskflow/tests/unit/test_engine_helpers.py +0 -2
  138. taskflow/tests/unit/test_engines.py +19 -102
  139. taskflow/tests/unit/test_exceptions.py +4 -6
  140. taskflow/tests/unit/test_failure.py +10 -12
  141. taskflow/tests/unit/test_flow_dependencies.py +62 -64
  142. taskflow/tests/unit/test_formatters.py +0 -2
  143. taskflow/tests/unit/test_functor_task.py +1 -3
  144. taskflow/tests/unit/test_listeners.py +9 -11
  145. taskflow/tests/unit/test_mapfunctor_task.py +1 -3
  146. taskflow/tests/unit/test_notifier.py +1 -3
  147. taskflow/tests/unit/test_progress.py +2 -4
  148. taskflow/tests/unit/test_reducefunctor_task.py +1 -3
  149. taskflow/tests/unit/test_retries.py +1 -25
  150. taskflow/tests/unit/test_states.py +0 -2
  151. taskflow/tests/unit/test_storage.py +10 -12
  152. taskflow/tests/unit/test_suspend.py +2 -23
  153. taskflow/tests/unit/test_task.py +17 -19
  154. taskflow/tests/unit/test_types.py +4 -6
  155. taskflow/tests/unit/test_utils.py +9 -11
  156. taskflow/tests/unit/test_utils_async_utils.py +0 -2
  157. taskflow/tests/unit/test_utils_binary.py +12 -14
  158. taskflow/tests/unit/test_utils_iter_utils.py +1 -3
  159. taskflow/tests/unit/test_utils_kazoo_utils.py +0 -2
  160. taskflow/tests/unit/test_utils_threading_utils.py +1 -3
  161. taskflow/tests/unit/worker_based/test_creation.py +0 -2
  162. taskflow/tests/unit/worker_based/test_dispatcher.py +0 -2
  163. taskflow/tests/unit/worker_based/test_endpoint.py +2 -4
  164. taskflow/tests/unit/worker_based/test_executor.py +1 -3
  165. taskflow/tests/unit/worker_based/test_message_pump.py +0 -2
  166. taskflow/tests/unit/worker_based/test_pipeline.py +0 -2
  167. taskflow/tests/unit/worker_based/test_protocol.py +2 -4
  168. taskflow/tests/unit/worker_based/test_proxy.py +2 -4
  169. taskflow/tests/unit/worker_based/test_server.py +3 -5
  170. taskflow/tests/unit/worker_based/test_types.py +0 -2
  171. taskflow/tests/unit/worker_based/test_worker.py +1 -3
  172. taskflow/tests/utils.py +11 -15
  173. taskflow/types/entity.py +1 -3
  174. taskflow/types/failure.py +3 -6
  175. taskflow/types/graph.py +14 -18
  176. taskflow/types/latch.py +1 -3
  177. taskflow/types/notifier.py +6 -9
  178. taskflow/types/sets.py +2 -5
  179. taskflow/types/timing.py +1 -3
  180. taskflow/types/tree.py +6 -10
  181. taskflow/utils/async_utils.py +0 -2
  182. taskflow/utils/banner.py +8 -9
  183. taskflow/utils/eventlet_utils.py +0 -2
  184. taskflow/utils/iter_utils.py +0 -2
  185. taskflow/utils/kazoo_utils.py +7 -9
  186. taskflow/utils/kombu_utils.py +5 -7
  187. taskflow/utils/misc.py +4 -6
  188. taskflow/utils/persistence_utils.py +0 -2
  189. taskflow/utils/redis_utils.py +2 -4
  190. taskflow/utils/schema_utils.py +0 -2
  191. taskflow/utils/threading_utils.py +1 -3
  192. taskflow/version.py +1 -3
  193. {taskflow-5.12.0.dist-info → taskflow-6.0.1.dist-info}/AUTHORS +1 -0
  194. {taskflow-5.12.0.dist-info → taskflow-6.0.1.dist-info}/METADATA +1 -1
  195. taskflow-6.0.1.dist-info/RECORD +243 -0
  196. {taskflow-5.12.0.dist-info → taskflow-6.0.1.dist-info}/WHEEL +1 -1
  197. taskflow-6.0.1.dist-info/pbr.json +1 -0
  198. taskflow/engines/action_engine/process_executor.py +0 -720
  199. taskflow/tests/unit/action_engine/test_process_executor.py +0 -106
  200. taskflow-5.12.0.dist-info/RECORD +0 -244
  201. taskflow-5.12.0.dist-info/pbr.json +0 -1
  202. {taskflow-5.12.0.dist-info → taskflow-6.0.1.dist-info}/LICENSE +0 -0
  203. {taskflow-5.12.0.dist-info → taskflow-6.0.1.dist-info}/entry_points.txt +0 -0
  204. {taskflow-5.12.0.dist-info → taskflow-6.0.1.dist-info}/top_level.txt +0 -0
@@ -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
@@ -49,7 +47,7 @@ class CheckingClaimListener(base.Listener):
49
47
  """
50
48
 
51
49
  def __init__(self, engine, job, board, owner, on_job_loss=None):
52
- super(CheckingClaimListener, self).__init__(engine)
50
+ super().__init__(engine)
53
51
  self._job = job
54
52
  self._board = board
55
53
  self._owner = owner
@@ -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
@@ -46,7 +44,7 @@ class LoggingListener(base.DumpingListener):
46
44
  retry_listen_for=base.DEFAULT_LISTEN_FOR,
47
45
  log=None,
48
46
  level=logging.DEBUG):
49
- super(LoggingListener, self).__init__(
47
+ super().__init__(
50
48
  engine, task_listen_for=task_listen_for,
51
49
  flow_listen_for=flow_listen_for, retry_listen_for=retry_listen_for)
52
50
  self._logger = misc.pick_first_not_none(log, self._LOGGER, LOG)
@@ -110,8 +108,10 @@ class DynamicLoggingListener(base.Listener):
110
108
  retry_listen_for=base.DEFAULT_LISTEN_FOR,
111
109
  log=None, failure_level=logging.WARNING,
112
110
  level=logging.DEBUG, hide_inputs_outputs_of=(),
113
- fail_formatter=None):
114
- super(DynamicLoggingListener, self).__init__(
111
+ fail_formatter=None,
112
+ mask_inputs_keys=(),
113
+ mask_outputs_keys=()):
114
+ super().__init__(
115
115
  engine, task_listen_for=task_listen_for,
116
116
  flow_listen_for=flow_listen_for, retry_listen_for=retry_listen_for)
117
117
  self._failure_level = failure_level
@@ -127,11 +127,15 @@ class DynamicLoggingListener(base.Listener):
127
127
  states.REVERTED: self._failure_level,
128
128
  }
129
129
  self._hide_inputs_outputs_of = frozenset(hide_inputs_outputs_of)
130
+ self._mask_inputs_keys = frozenset(mask_inputs_keys)
131
+ self._mask_outputs_keys = frozenset(mask_outputs_keys)
130
132
  self._logger = misc.pick_first_not_none(log, self._LOGGER, LOG)
131
133
  if fail_formatter is None:
132
134
  self._fail_formatter = formatters.FailureFormatter(
133
135
  self._engine,
134
- hide_inputs_outputs_of=self._hide_inputs_outputs_of)
136
+ hide_inputs_outputs_of=self._hide_inputs_outputs_of,
137
+ mask_inputs_keys=self._mask_inputs_keys,
138
+ mask_outputs_keys=self._mask_outputs_keys)
135
139
  else:
136
140
  self._fail_formatter = fail_formatter
137
141
 
@@ -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
@@ -27,7 +25,7 @@ class PrintingListener(base.DumpingListener):
27
25
  flow_listen_for=base.DEFAULT_LISTEN_FOR,
28
26
  retry_listen_for=base.DEFAULT_LISTEN_FOR,
29
27
  stderr=False):
30
- super(PrintingListener, self).__init__(
28
+ super().__init__(
31
29
  engine, task_listen_for=task_listen_for,
32
30
  flow_listen_for=flow_listen_for, retry_listen_for=retry_listen_for)
33
31
  if stderr:
@@ -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
@@ -26,7 +24,7 @@ from taskflow import logging
26
24
  from taskflow import states
27
25
 
28
26
  STARTING_STATES = frozenset((states.RUNNING, states.REVERTING))
29
- FINISHED_STATES = frozenset((base.FINISH_STATES + (states.REVERTED,)))
27
+ FINISHED_STATES = frozenset(base.FINISH_STATES + (states.REVERTED,))
30
28
  WATCH_STATES = frozenset(itertools.chain(FINISHED_STATES, STARTING_STATES,
31
29
  [states.PENDING]))
32
30
 
@@ -48,13 +46,13 @@ class DurationListener(base.Listener):
48
46
  to task metadata with key ``'duration'``.
49
47
  """
50
48
  def __init__(self, engine):
51
- super(DurationListener, self).__init__(engine,
52
- task_listen_for=WATCH_STATES,
53
- flow_listen_for=WATCH_STATES)
49
+ super().__init__(engine,
50
+ task_listen_for=WATCH_STATES,
51
+ flow_listen_for=WATCH_STATES)
54
52
  self._timers = {co.TASK: {}, co.FLOW: {}}
55
53
 
56
54
  def deregister(self):
57
- super(DurationListener, self).deregister()
55
+ super().deregister()
58
56
  # There should be none that still exist at deregistering time, so log a
59
57
  # warning if there were any that somehow still got left behind...
60
58
  for item_type, timers in self._timers.items():
@@ -105,23 +103,22 @@ class PrintingDurationListener(DurationListener):
105
103
  """Listener that prints the duration as well as recording it."""
106
104
 
107
105
  def __init__(self, engine, printer=None):
108
- super(PrintingDurationListener, self).__init__(engine)
106
+ super().__init__(engine)
109
107
  if printer is None:
110
108
  self._printer = _printer
111
109
  else:
112
110
  self._printer = printer
113
111
 
114
112
  def _record_ending(self, timer, item_type, item_name, state):
115
- super(PrintingDurationListener, self)._record_ending(
113
+ super()._record_ending(
116
114
  timer, item_type, item_name, state)
117
115
  self._printer("It took %s '%s' %0.2f seconds to"
118
116
  " finish." % (item_type, item_name, timer.elapsed()))
119
117
 
120
118
  def _receiver(self, item_type, item_name, state):
121
- super(PrintingDurationListener, self)._receiver(item_type,
122
- item_name, state)
119
+ super()._receiver(item_type, item_name, state)
123
120
  if state in STARTING_STATES:
124
- self._printer("'%s' %s started." % (item_name, item_type))
121
+ self._printer("'{}' {} started.".format(item_name, item_type))
125
122
 
126
123
 
127
124
  class EventTimeListener(base.Listener):
@@ -139,7 +136,7 @@ class EventTimeListener(base.Listener):
139
136
  task_listen_for=base.DEFAULT_LISTEN_FOR,
140
137
  flow_listen_for=base.DEFAULT_LISTEN_FOR,
141
138
  retry_listen_for=base.DEFAULT_LISTEN_FOR):
142
- super(EventTimeListener, self).__init__(
139
+ super().__init__(
143
140
  engine, task_listen_for=task_listen_for,
144
141
  flow_listen_for=flow_listen_for, retry_listen_for=retry_listen_for)
145
142
 
taskflow/logging.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
@@ -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
@@ -66,7 +64,7 @@ class Flow(flow.Flow):
66
64
  """
67
65
 
68
66
  def __init__(self, name, retry=None):
69
- super(Flow, self).__init__(name, retry)
67
+ super().__init__(name, retry)
70
68
  self._graph = gr.DiGraph(name=name)
71
69
  self._graph.freeze()
72
70
 
@@ -332,7 +330,7 @@ class TargetedFlow(Flow):
332
330
  """
333
331
 
334
332
  def __init__(self, *args, **kwargs):
335
- super(TargetedFlow, self).__init__(*args, **kwargs)
333
+ super().__init__(*args, **kwargs)
336
334
  self._subgraph = None
337
335
  self._target = None
338
336
 
@@ -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
@@ -36,7 +34,7 @@ class Flow(flow.Flow):
36
34
  """
37
35
 
38
36
  def __init__(self, name, retry=None):
39
- super(Flow, self).__init__(name, retry)
37
+ super().__init__(name, retry)
40
38
  self._graph = gr.OrderedDiGraph(name=name)
41
39
  self._last_item = self._no_last_item
42
40
 
@@ -55,8 +53,7 @@ class Flow(flow.Flow):
55
53
  return len(self._graph)
56
54
 
57
55
  def __iter__(self):
58
- for item in self._graph.nodes:
59
- yield item
56
+ yield from self._graph.nodes
60
57
 
61
58
  @property
62
59
  def requires(self):
@@ -71,9 +68,7 @@ class Flow(flow.Flow):
71
68
  return frozenset(requires)
72
69
 
73
70
  def iter_nodes(self):
74
- for (n, n_data) in self._graph.nodes(data=True):
75
- yield (n, n_data)
71
+ yield from self._graph.nodes(data=True)
76
72
 
77
73
  def iter_links(self):
78
- for (u, v, e_data) in self._graph.edges(data=True):
79
- yield (u, v, e_data)
74
+ yield from self._graph.edges(data=True)
@@ -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
@@ -26,7 +24,7 @@ class Flow(flow.Flow):
26
24
  """
27
25
 
28
26
  def __init__(self, name, retry=None):
29
- super(Flow, self).__init__(name, retry)
27
+ super().__init__(name, retry)
30
28
  self._graph = gr.Graph(name=name)
31
29
 
32
30
  def add(self, *items):
@@ -40,16 +38,13 @@ class Flow(flow.Flow):
40
38
  return len(self._graph)
41
39
 
42
40
  def __iter__(self):
43
- for item in self._graph:
44
- yield item
41
+ yield from self._graph
45
42
 
46
43
  def iter_links(self):
47
- for (u, v, e_data) in self._graph.edges(data=True):
48
- yield (u, v, e_data)
44
+ yield from self._graph.edges(data=True)
49
45
 
50
46
  def iter_nodes(self):
51
- for n, n_data in self._graph.nodes(data=True):
52
- yield (n, n_data)
47
+ yield from self._graph.nodes(data=True)
53
48
 
54
49
  @property
55
50
  def requires(self):
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2013 Rackspace Hosting Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -64,7 +62,7 @@ def fetch(conf, namespace=BACKEND_NAMESPACE, **kwargs):
64
62
  invoke_kwds=kwargs)
65
63
  return mgr.driver
66
64
  except RuntimeError as e:
67
- raise exc.NotFound("Could not find backend %s: %s" % (backend, e))
65
+ raise exc.NotFound("Could not find backend {}: {}".format(backend, e))
68
66
 
69
67
 
70
68
  @contextlib.contextmanager
@@ -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
  #
@@ -17,7 +15,6 @@
17
15
 
18
16
  import contextlib
19
17
  import errno
20
- import io
21
18
  import os
22
19
  import shutil
23
20
 
@@ -69,7 +66,7 @@ class DirBackend(path_based.PathBasedBackend):
69
66
  """
70
67
 
71
68
  def __init__(self, conf):
72
- super(DirBackend, self).__init__(conf)
69
+ super().__init__(conf)
73
70
  max_cache_size = self._conf.get('max_cache_size')
74
71
  if max_cache_size is not None:
75
72
  max_cache_size = int(max_cache_size)
@@ -100,7 +97,7 @@ class Connection(path_based.PathBasedConnection):
100
97
  mtime = os.path.getmtime(filename)
101
98
  cache_info = self.backend.file_cache.setdefault(filename, {})
102
99
  if not cache_info or mtime > cache_info.get('mtime', 0):
103
- with io.open(filename, 'r', encoding=self.backend.encoding) as fp:
100
+ with open(filename, encoding=self.backend.encoding) as fp:
104
101
  cache_info['data'] = fp.read()
105
102
  cache_info['mtime'] = mtime
106
103
  return cache_info['data']
@@ -108,7 +105,7 @@ class Connection(path_based.PathBasedConnection):
108
105
  def _write_to(self, filename, contents):
109
106
  contents = misc.binary_encode(contents,
110
107
  encoding=self.backend.encoding)
111
- with io.open(filename, 'wb') as fp:
108
+ with open(filename, 'wb') as fp:
112
109
  fp.write(contents)
113
110
  self.backend.file_cache.pop(filename, None)
114
111
 
@@ -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
  #
@@ -31,10 +29,10 @@ class FakeInode(tree.Node):
31
29
  """A in-memory filesystem inode-like object."""
32
30
 
33
31
  def __init__(self, item, path, value=None):
34
- super(FakeInode, self).__init__(item, path=path, value=value)
32
+ super().__init__(item, path=path, value=value)
35
33
 
36
34
 
37
- class FakeFilesystem(object):
35
+ class FakeFilesystem:
38
36
  """An in-memory filesystem-like structure.
39
37
 
40
38
  This filesystem uses posix style paths **only** so users must be careful
@@ -249,8 +247,7 @@ class FakeFilesystem(object):
249
247
  parts = path.split(pp.sep)[1:]
250
248
  if include_root:
251
249
  parts.insert(0, self._root.item)
252
- for piece in parts:
253
- yield piece
250
+ yield from parts
254
251
 
255
252
  def __delitem__(self, path):
256
253
  self.delete(path, recursive=True)
@@ -258,7 +255,7 @@ class FakeFilesystem(object):
258
255
  @staticmethod
259
256
  def _stringify_node(node):
260
257
  if 'target' in node.metadata:
261
- return "%s (link to %s)" % (node.item, node.metadata['target'])
258
+ return "{} (link to {})".format(node.item, node.metadata['target'])
262
259
  else:
263
260
  return str(node.item)
264
261
 
@@ -309,7 +306,7 @@ class MemoryBackend(path_based.PathBasedBackend):
309
306
  DEFAULT_PATH = pp.sep
310
307
 
311
308
  def __init__(self, conf=None):
312
- super(MemoryBackend, self).__init__(conf)
309
+ super().__init__(conf)
313
310
  self.memory = FakeFilesystem(deep_copy=self._conf.get('deep_copy',
314
311
  True))
315
312
  self.lock = fasteners.ReaderWriterLock()
@@ -323,7 +320,7 @@ class MemoryBackend(path_based.PathBasedBackend):
323
320
 
324
321
  class Connection(path_based.PathBasedConnection):
325
322
  def __init__(self, backend):
326
- super(Connection, self).__init__(backend)
323
+ super().__init__(backend)
327
324
  self.upgrade()
328
325
 
329
326
  @contextlib.contextmanager
@@ -179,7 +179,7 @@ def _ping_listener(dbapi_conn, connection_rec, connection_proxy):
179
179
  raise
180
180
 
181
181
 
182
- class _Alchemist(object):
182
+ class _Alchemist:
183
183
  """Internal <-> external row <-> objects + other helper functions.
184
184
 
185
185
  NOTE(harlowja): for internal usage only.
@@ -235,7 +235,7 @@ class SQLAlchemyBackend(base.Backend):
235
235
  }
236
236
  """
237
237
  def __init__(self, conf, engine=None):
238
- super(SQLAlchemyBackend, self).__init__(conf)
238
+ super().__init__(conf)
239
239
  if engine is not None:
240
240
  self._engine = engine
241
241
  self._owns_engine = False
@@ -581,8 +581,7 @@ class Connection(base.Connection):
581
581
  exc.raise_with_cause(exc.StorageFailure,
582
582
  "Failed getting flow details in"
583
583
  " logbook '%s'" % book_uuid)
584
- for flow_details in gathered:
585
- yield flow_details
584
+ yield from gathered
586
585
 
587
586
  def get_flow_details(self, fd_uuid, lazy=False):
588
587
  try:
@@ -631,8 +630,7 @@ class Connection(base.Connection):
631
630
  exc.raise_with_cause(exc.StorageFailure,
632
631
  "Failed getting atom details in flow"
633
632
  " detail '%s'" % fd_uuid)
634
- for atom_details in gathered:
635
- yield atom_details
633
+ yield from gathered
636
634
 
637
635
  def close(self):
638
636
  pass
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2014 AT&T Labs All Rights Reserved.
4
2
  # Copyright (C) 2015 Rackspace Hosting All Rights Reserved.
5
3
  #
@@ -56,7 +54,7 @@ class ZkBackend(path_based.PathBasedBackend):
56
54
  DEFAULT_PATH = '/taskflow'
57
55
 
58
56
  def __init__(self, conf, client=None):
59
- super(ZkBackend, self).__init__(conf)
57
+ super().__init__(conf)
60
58
  if not paths.isabs(self._path):
61
59
  raise ValueError("Zookeeper path must be absolute")
62
60
  if client is not None:
@@ -87,7 +85,7 @@ class ZkBackend(path_based.PathBasedBackend):
87
85
 
88
86
  class ZkConnection(path_based.PathBasedConnection):
89
87
  def __init__(self, backend, client, conf):
90
- super(ZkConnection, self).__init__(backend)
88
+ super().__init__(backend)
91
89
  self._conf = conf
92
90
  self._client = client
93
91
  with self._exc_wrapper():
@@ -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
@@ -0,0 +1,74 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+ # not use this file except in compliance with the License. You may obtain
3
+ # a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+ # License for the specific language governing permissions and limitations
11
+ # under the License.
12
+
13
+ """Add unique into all indexes
14
+
15
+ Revision ID: 00af93df9d77
16
+ Revises: 40fc8c914bd2
17
+ Create Date: 2025-02-28 15:44:37.066720
18
+
19
+ """
20
+
21
+ # revision identifiers, used by Alembic.
22
+ revision = '00af93df9d77'
23
+ down_revision = '40fc8c914bd2'
24
+
25
+ from alembic import op
26
+
27
+
28
+ def upgrade():
29
+ bind = op.get_bind()
30
+ engine = bind.engine
31
+ if engine.name == 'mysql':
32
+ with op.batch_alter_table("logbooks") as batch_op:
33
+ batch_op.drop_index("logbook_uuid_idx")
34
+ batch_op.create_index(
35
+ index_name="logbook_uuid_idx",
36
+ columns=['uuid'],
37
+ unique=True)
38
+
39
+ with op.batch_alter_table("flowdetails") as batch_op:
40
+ batch_op.drop_index("flowdetails_uuid_idx")
41
+ batch_op.create_index(
42
+ index_name="flowdetails_uuid_idx",
43
+ columns=['uuid'],
44
+ unique=True)
45
+
46
+ with op.batch_alter_table("atomdetails") as batch_op:
47
+ batch_op.drop_index("taskdetails_uuid_idx")
48
+ batch_op.create_index(
49
+ index_name="taskdetails_uuid_idx",
50
+ columns=['uuid'],
51
+ unique=True)
52
+
53
+
54
+ def downgrade():
55
+ bind = op.get_bind()
56
+ engine = bind.engine
57
+ if engine.name == 'mysql':
58
+ with op.batch_alter_table("logbooks") as batch_op:
59
+ batch_op.drop_index("logbook_uuid_idx")
60
+ batch_op.create_index(
61
+ index_name="logbook_uuid_idx",
62
+ columns=['uuid'])
63
+
64
+ with op.batch_alter_table("flowdetails") as batch_op:
65
+ batch_op.drop_index("flowdetails_uuid_idx")
66
+ batch_op.create_index(
67
+ index_name="flowdetails_uuid_idx",
68
+ columns=['uuid'])
69
+
70
+ with op.batch_alter_table("atomdetails") as batch_op:
71
+ batch_op.drop_index("taskdetails_uuid_idx")
72
+ batch_op.create_index(
73
+ index_name="taskdetails_uuid_idx",
74
+ columns=['uuid'])
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2012-2013 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2012-2013 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2012-2013 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2012-2013 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -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
@@ -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
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2012-2013 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -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
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2013 Rackspace Hosting 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 abc
19
17
  from taskflow.persistence import models
20
18
 
21
19
 
22
- class Backend(object, metaclass=abc.ABCMeta):
20
+ class Backend(metaclass=abc.ABCMeta):
23
21
  """Base class for persistence backends."""
24
22
 
25
23
  def __init__(self, conf):
@@ -39,7 +37,7 @@ class Backend(object, metaclass=abc.ABCMeta):
39
37
  """Closes any resources this backend has open."""
40
38
 
41
39
 
42
- class Connection(object, metaclass=abc.ABCMeta):
40
+ class Connection(metaclass=abc.ABCMeta):
43
41
  """Base class for backend connections."""
44
42
 
45
43
  @property