taskflow 5.11.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.
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 +80 -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 +4 -6
  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 +2 -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.11.0.dist-info → taskflow-6.0.0.dist-info}/AUTHORS +1 -0
  194. {taskflow-5.11.0.dist-info → taskflow-6.0.0.dist-info}/METADATA +2 -1
  195. taskflow-6.0.0.dist-info/RECORD +243 -0
  196. {taskflow-5.11.0.dist-info → taskflow-6.0.0.dist-info}/WHEEL +1 -1
  197. taskflow-6.0.0.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.11.0.dist-info/RECORD +0 -244
  201. taskflow-5.11.0.dist-info/pbr.json +0 -1
  202. {taskflow-5.11.0.dist-info → taskflow-6.0.0.dist-info}/LICENSE +0 -0
  203. {taskflow-5.11.0.dist-info → taskflow-6.0.0.dist-info}/entry_points.txt +0 -0
  204. {taskflow-5.11.0.dist-info → taskflow-6.0.0.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
@@ -31,7 +29,7 @@ from taskflow.utils import misc
31
29
  LOG = logging.getLogger(__name__)
32
30
 
33
31
 
34
- class Server(object):
32
+ class Server:
35
33
  """Server implementation that waits for incoming tasks requests."""
36
34
 
37
35
  def __init__(self, topic, exchange, executor, endpoints,
@@ -53,8 +51,8 @@ class Server(object):
53
51
  transport_options=transport_options,
54
52
  retry_options=retry_options)
55
53
  self._topic = topic
56
- self._endpoints = dict([(endpoint.name, endpoint)
57
- for endpoint in endpoints])
54
+ self._endpoints = {endpoint.name: endpoint
55
+ for endpoint in endpoints}
58
56
 
59
57
  def _delayed_process(self, func):
60
58
  """Runs the function using the instances executor (eventually).
@@ -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
@@ -30,7 +28,7 @@ LOG = logging.getLogger(__name__)
30
28
  # TODO(harlowja): this needs to be made better, once
31
29
  # https://blueprints.launchpad.net/taskflow/+spec/wbe-worker-info is finally
32
30
  # implemented we can go about using that instead.
33
- class TopicWorker(object):
31
+ class TopicWorker:
34
32
  """A (read-only) worker and its relevant information + useful methods."""
35
33
 
36
34
  _NO_IDENTITY = object()
@@ -72,14 +70,15 @@ class TopicWorker(object):
72
70
  def __repr__(self):
73
71
  r = reflection.get_class_name(self, fully_qualified=False)
74
72
  if self.identity is not self._NO_IDENTITY:
75
- r += "(identity=%s, tasks=%s, topic=%s)" % (self.identity,
76
- self.tasks, self.topic)
73
+ r += "(identity={}, tasks={}, topic={})".format(
74
+ self.identity, self.tasks, self.topic)
77
75
  else:
78
- r += "(identity=*, tasks=%s, topic=%s)" % (self.tasks, self.topic)
76
+ r += "(identity=*, tasks={}, topic={})".format(
77
+ self.tasks, self.topic)
79
78
  return r
80
79
 
81
80
 
82
- class ProxyWorkerFinder(object):
81
+ class ProxyWorkerFinder:
83
82
  """Requests and receives responses about workers topic+task details."""
84
83
 
85
84
  def __init__(self, uuid, proxy, topics,
@@ -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
@@ -33,7 +31,7 @@ from taskflow.utils import threading_utils as tu
33
31
  LOG = logging.getLogger(__name__)
34
32
 
35
33
 
36
- class Worker(object):
34
+ class Worker:
37
35
  """Worker that can be started on a remote host for handling tasks requests.
38
36
 
39
37
  :param url: broker url
@@ -88,13 +86,13 @@ class Worker(object):
88
86
  connection_details = self._server.connection_details
89
87
  transport = connection_details.transport
90
88
  if transport.driver_version:
91
- transport_driver = "%s v%s" % (transport.driver_name,
92
- transport.driver_version)
89
+ transport_driver = "{} v{}".format(transport.driver_name,
90
+ transport.driver_version)
93
91
  else:
94
92
  transport_driver = transport.driver_name
95
93
  try:
96
94
  hostname = socket.getfqdn()
97
- except socket.error:
95
+ except OSError:
98
96
  hostname = "???"
99
97
  try:
100
98
  pid = os.getpid()
@@ -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
@@ -111,7 +109,7 @@ def flow_watch(state, details):
111
109
 
112
110
 
113
111
  def task_watch(state, details):
114
- print('Task %s => %s' % (details.get('task_name'), state))
112
+ print('Task {} => {}'.format(details.get('task_name'), state))
115
113
 
116
114
 
117
115
  flow = lf.Flow("make-auto").add(
@@ -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
@@ -56,7 +54,7 @@ class LinkTask(task.Task):
56
54
  default_provides = 'executable'
57
55
 
58
56
  def __init__(self, executable_path, *args, **kwargs):
59
- super(LinkTask, self).__init__(*args, **kwargs)
57
+ super().__init__(*args, **kwargs)
60
58
  self._executable_path = executable_path
61
59
 
62
60
  def execute(self, **kwargs):
@@ -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
@@ -46,7 +44,7 @@ from taskflow import task
46
44
  # more uniform manner).
47
45
  class Provider(task.Task):
48
46
  def __init__(self, name, *args, **kwargs):
49
- super(Provider, self).__init__(name=name, **kwargs)
47
+ super().__init__(name=name, **kwargs)
50
48
  self._provide = args
51
49
 
52
50
  def execute(self):
@@ -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
@@ -54,7 +52,7 @@ from taskflow import task
54
52
  class Provider(task.Task):
55
53
 
56
54
  def __init__(self, name, *args, **kwargs):
57
- super(Provider, self).__init__(name=name, **kwargs)
55
+ super().__init__(name=name, **kwargs)
58
56
  self._provide = args
59
57
 
60
58
  def execute(self):
@@ -79,8 +77,8 @@ class Adder(task.Task):
79
77
  # this function needs to undo if some later operation fails.
80
78
  class Multiplier(task.Task):
81
79
  def __init__(self, name, multiplier, provides=None, rebind=None):
82
- super(Multiplier, self).__init__(name=name, provides=provides,
83
- rebind=rebind)
80
+ super().__init__(name=name, provides=provides,
81
+ rebind=rebind)
84
82
  self._multiplier = multiplier
85
83
 
86
84
  def execute(self, z):
@@ -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
@@ -45,7 +43,7 @@ def show_time(name):
45
43
  start = time.time()
46
44
  yield
47
45
  end = time.time()
48
- print(" -- %s took %0.3f seconds" % (name, end - start))
46
+ print(" -- {} took {:0.3f} seconds".format(name, end - start))
49
47
 
50
48
 
51
49
  # This affects how many volumes to create and how much time to *simulate*
@@ -85,8 +83,7 @@ class VolumeCreator(task.Task):
85
83
  # volume create can be resumed/revert, and is much easier to use for
86
84
  # audit and tracking purposes.
87
85
  base_name = reflection.get_callable_name(self)
88
- super(VolumeCreator, self).__init__(name="%s-%s" % (base_name,
89
- volume_id))
86
+ super().__init__(name="{}-{}".format(base_name, volume_id))
90
87
  self._volume_id = volume_id
91
88
 
92
89
  def execute(self):
@@ -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
@@ -44,7 +42,7 @@ from taskflow.types import notifier
44
42
 
45
43
  class PokeFutureListener(base.Listener):
46
44
  def __init__(self, engine, future, task_name):
47
- super(PokeFutureListener, self).__init__(
45
+ super().__init__(
48
46
  engine,
49
47
  task_listen_for=(notifier.Notifier.ANY,),
50
48
  flow_listen_for=[])
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2015 Hewlett-Packard Development Company, L.P.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -62,31 +60,24 @@ if __name__ == '__main__':
62
60
  any_distance = linear_flow.Flow("origin").add(DistanceTask())
63
61
  results = engines.run(any_distance)
64
62
  print(results)
65
- print("%s is near-enough to %s: %s" % (results['distance'],
66
- 0.0,
67
- is_near(results['distance'], 0.0)))
63
+ print("{} is near-enough to {}: {}".format(
64
+ results['distance'], 0.0, is_near(results['distance'], 0.0)))
68
65
 
69
66
  results = engines.run(any_distance, store={'a': Point(1, 1)})
70
67
  print(results)
71
- print("%s is near-enough to %s: %s" % (results['distance'],
72
- 1.4142,
73
- is_near(results['distance'],
74
- 1.4142)))
68
+ print("{} is near-enough to {}: {}".format(
69
+ results['distance'], 1.4142, is_near(results['distance'], 1.4142)))
75
70
 
76
71
  results = engines.run(any_distance, store={'a': Point(10, 10)})
77
72
  print(results)
78
- print("%s is near-enough to %s: %s" % (results['distance'],
79
- 14.14199,
80
- is_near(results['distance'],
81
- 14.14199)))
73
+ print("{} is near-enough to {}: {}".format(
74
+ results['distance'], 14.14199, is_near(results['distance'], 14.14199)))
82
75
 
83
76
  results = engines.run(any_distance,
84
77
  store={'a': Point(5, 5), 'b': Point(10, 10)})
85
78
  print(results)
86
- print("%s is near-enough to %s: %s" % (results['distance'],
87
- 7.07106,
88
- is_near(results['distance'],
89
- 7.07106)))
79
+ print("{} is near-enough to {}: {}".format(
80
+ results['distance'], 7.07106, is_near(results['distance'], 7.07106)))
90
81
 
91
82
  # For this we use the ability to override at task creation time the
92
83
  # optional arguments so that we don't need to continue to send them
@@ -97,13 +88,10 @@ if __name__ == '__main__':
97
88
  ten_distance.add(DistanceTask(inject={'a': Point(10, 10)}))
98
89
  results = engines.run(ten_distance, store={'b': Point(10, 10)})
99
90
  print(results)
100
- print("%s is near-enough to %s: %s" % (results['distance'],
101
- 0.0,
102
- is_near(results['distance'], 0.0)))
91
+ print("{} is near-enough to {}: {}".format(
92
+ results['distance'], 0.0, is_near(results['distance'], 0.0)))
103
93
 
104
94
  results = engines.run(ten_distance)
105
95
  print(results)
106
- print("%s is near-enough to %s: %s" % (results['distance'],
107
- 14.14199,
108
- is_near(results['distance'],
109
- 14.14199)))
96
+ print("{} is near-enough to {}: {}".format(
97
+ results['distance'], 14.14199, is_near(results['distance'], 14.14199)))
@@ -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
@@ -67,6 +65,6 @@ print("---------")
67
65
  for path in backend.memory.ls_r(backend.memory.root_path, absolute=True):
68
66
  value = backend.memory[path]
69
67
  if value:
70
- print("%s -> %s" % (path, value))
68
+ print("{} -> {}".format(path, value))
71
69
  else:
72
70
  print("%s" % (path))
@@ -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) 2013 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -52,7 +50,7 @@ def rm_path(persist_path):
52
50
  raise ValueError("Unknown how to `rm` path: %s" % (persist_path))
53
51
  try:
54
52
  rm_func(persist_path)
55
- except (IOError, OSError):
53
+ except OSError:
56
54
  pass
57
55
 
58
56
 
@@ -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
@@ -47,12 +45,12 @@ from taskflow.utils import misc
47
45
  # complete to 100% complete.
48
46
 
49
47
 
50
- class DB(object):
48
+ class DB:
51
49
  def query(self, sql):
52
50
  print("Querying with: %s" % (sql))
53
51
 
54
52
 
55
- class UrlCaller(object):
53
+ class UrlCaller:
56
54
  def __init__(self):
57
55
  self._send_time = 0.5
58
56
  self._chunks = 25
@@ -73,7 +71,7 @@ class UrlCaller(object):
73
71
  # that require access to a set of resources it is a common pattern to provide
74
72
  # a object (in this case this object) on construction of those tasks via the
75
73
  # task constructor.
76
- class ResourceFetcher(object):
74
+ class ResourceFetcher:
77
75
  def __init__(self):
78
76
  self._db_handle = None
79
77
  self._url_handle = None
@@ -93,7 +91,7 @@ class ResourceFetcher(object):
93
91
 
94
92
  class ExtractInputRequest(task.Task):
95
93
  def __init__(self, resources):
96
- super(ExtractInputRequest, self).__init__(provides="parsed_request")
94
+ super().__init__(provides="parsed_request")
97
95
  self._resources = resources
98
96
 
99
97
  def execute(self, request):
@@ -106,7 +104,7 @@ class ExtractInputRequest(task.Task):
106
104
 
107
105
  class MakeDBEntry(task.Task):
108
106
  def __init__(self, resources):
109
- super(MakeDBEntry, self).__init__()
107
+ super().__init__()
110
108
  self._resources = resources
111
109
 
112
110
  def execute(self, parsed_request):
@@ -120,7 +118,7 @@ class MakeDBEntry(task.Task):
120
118
 
121
119
  class ActivateDriver(task.Task):
122
120
  def __init__(self, resources):
123
- super(ActivateDriver, self).__init__(provides='sent_to')
121
+ super().__init__(provides='sent_to')
124
122
  self._resources = resources
125
123
  self._url = "http://blahblah.com"
126
124
 
@@ -138,8 +136,8 @@ class ActivateDriver(task.Task):
138
136
 
139
137
  def update_progress(self, progress, **kwargs):
140
138
  # Override the parent method to also print out the status.
141
- super(ActivateDriver, self).update_progress(progress, **kwargs)
142
- print("%s is %0.2f%% done" % (self.name, progress * 100))
139
+ super().update_progress(progress, **kwargs)
140
+ print("{} is {:0.2f}% done".format(self.name, progress * 100))
143
141
 
144
142
 
145
143
  class DeclareSuccess(task.Task):
@@ -148,7 +146,7 @@ class DeclareSuccess(task.Task):
148
146
  print("All data processed and sent to %s" % (sent_to))
149
147
 
150
148
 
151
- class DummyUser(object):
149
+ class DummyUser:
152
150
  def __init__(self, user, id_):
153
151
  self.user = user
154
152
  self.id = id_
@@ -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
@@ -99,7 +97,7 @@ print("Single threaded engine result %s" % result)
99
97
  for (name, value) in expected:
100
98
  actual = result.get(name)
101
99
  if actual != value:
102
- sys.stderr.write("%s != %s\n" % (actual, value))
100
+ sys.stderr.write("{} != {}\n".format(actual, value))
103
101
  unexpected += 1
104
102
 
105
103
  result = taskflow.engines.run(
@@ -109,7 +107,7 @@ print("Multi threaded engine result %s" % result)
109
107
  for (name, value) in expected:
110
108
  actual = result.get(name)
111
109
  if actual != value:
112
- sys.stderr.write("%s != %s\n" % (actual, value))
110
+ sys.stderr.write("{} != {}\n".format(actual, value))
113
111
  unexpected += 1
114
112
 
115
113
  if unexpected:
@@ -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
@@ -38,12 +36,12 @@ from taskflow import task
38
36
 
39
37
  class PrinterTask(task.Task):
40
38
  def __init__(self, name, show_name=True, inject=None):
41
- super(PrinterTask, self).__init__(name, inject=inject)
39
+ super().__init__(name, inject=inject)
42
40
  self._show_name = show_name
43
41
 
44
42
  def execute(self, output):
45
43
  if self._show_name:
46
- print("%s: %s" % (self.name, output))
44
+ print("{}: {}".format(self.name, output))
47
45
  else:
48
46
  print(output)
49
47
 
@@ -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
@@ -84,9 +82,9 @@ def dispatch_work(job):
84
82
  def safe_print(name, message, prefix=""):
85
83
  with STDOUT_LOCK:
86
84
  if prefix:
87
- print("%s %s: %s" % (prefix, name, message))
85
+ print("{} {}: {}".format(prefix, name, message))
88
86
  else:
89
- print("%s: %s" % (name, message))
87
+ print("{}: {}".format(name, message))
90
88
 
91
89
 
92
90
  def worker(ident, client, consumed):
@@ -138,7 +136,7 @@ def producer(ident, client):
138
136
  safe_print(name, "started")
139
137
  with backends.backend(name, SHARED_CONF.copy(), client=client) as board:
140
138
  for i in range(0, PRODUCER_UNITS):
141
- job_name = "%s-%s" % (name, i)
139
+ job_name = "{}-{}".format(name, i)
142
140
  details = {
143
141
  'color': random.choice(['red', 'blue']),
144
142
  }
@@ -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
@@ -47,7 +45,7 @@ class RowMultiplier(task.Task):
47
45
  """Performs a modification of an input row, creating a output row."""
48
46
 
49
47
  def __init__(self, name, index, row, multiplier):
50
- super(RowMultiplier, self).__init__(name=name)
48
+ super().__init__(name=name)
51
49
  self.index = index
52
50
  self.multiplier = multiplier
53
51
  self.row = row
@@ -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
@@ -58,7 +56,7 @@ class HiTask(task.Task):
58
56
 
59
57
  class ByeTask(task.Task):
60
58
  def __init__(self, blowup):
61
- super(ByeTask, self).__init__()
59
+ super().__init__()
62
60
  self._blowup = blowup
63
61
 
64
62
  def execute(self):
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2014 Ivan Melnikov <iv at altlinux dot org>
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -67,7 +65,7 @@ class CallTask(task.Task):
67
65
  """Task that calls person by number."""
68
66
 
69
67
  def execute(self, person, number):
70
- print('Calling %s %s.' % (person, number))
68
+ print('Calling {} {}.'.format(person, number))
71
69
 
72
70
  # This is how it works for one person:
73
71
 
@@ -84,7 +82,7 @@ taskflow.engines.run(simple_flow, store={'person': 'Josh'})
84
82
  # we use `rebind` argument of task constructor.
85
83
  def subflow_factory(prefix):
86
84
  def pr(what):
87
- return '%s-%s' % (prefix, what)
85
+ return '{}-{}'.format(prefix, what)
88
86
 
89
87
  return lf.Flow(pr('flow')).add(
90
88
  FetchNumberTask(pr('fetch'),
@@ -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
@@ -62,7 +60,7 @@ import example_utils as eu # noqa
62
60
 
63
61
  def print_task_states(flowdetail, msg):
64
62
  eu.print_wrapped(msg)
65
- print("Flow '%s' state: %s" % (flowdetail.name, flowdetail.state))
63
+ print("Flow '{}' state: {}".format(flowdetail.name, flowdetail.state))
66
64
  # Sort by these so that our test validation doesn't get confused by the
67
65
  # order in which the items in the flow detail can be in.
68
66
  items = sorted((td.name, td.version, td.state, td.results)
@@ -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
@@ -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
@@ -39,7 +37,7 @@ FINISHED_STATES = (states.SUCCESS, states.FAILURE, states.REVERTED)
39
37
 
40
38
 
41
39
  def resume(flowdetail, backend):
42
- print('Resuming flow %s %s' % (flowdetail.name, flowdetail.uuid))
40
+ print('Resuming flow {} {}'.format(flowdetail.name, flowdetail.uuid))
43
41
  engine = taskflow.engines.load_from_detail(flow_detail=flowdetail,
44
42
  backend=backend)
45
43
  engine.run()
@@ -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
@@ -38,6 +36,6 @@ import my_flows # noqa
38
36
  with example_utils.get_backend() as backend:
39
37
  engine = taskflow.engines.load_from_factory(my_flows.flow_factory,
40
38
  backend=backend)
41
- print('Running flow %s %s' % (engine.storage.flow_name,
42
- engine.storage.flow_uuid))
39
+ print('Running flow {} {}'.format(engine.storage.flow_name,
40
+ engine.storage.flow_uuid))
43
41
  engine.run()
@@ -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