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
|
@@ -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
|
|
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 =
|
|
57
|
-
|
|
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
|
|
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
|
|
76
|
-
|
|
73
|
+
r += "(identity={}, tasks={}, topic={})".format(
|
|
74
|
+
self.identity, self.tasks, self.topic)
|
|
77
75
|
else:
|
|
78
|
-
r += "(identity=*, tasks
|
|
76
|
+
r += "(identity=*, tasks={}, topic={})".format(
|
|
77
|
+
self.tasks, self.topic)
|
|
79
78
|
return r
|
|
80
79
|
|
|
81
80
|
|
|
82
|
-
class ProxyWorkerFinder
|
|
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
|
|
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 = "
|
|
92
|
-
|
|
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
|
|
95
|
+
except OSError:
|
|
98
96
|
hostname = "???"
|
|
99
97
|
try:
|
|
100
98
|
pid = os.getpid()
|
taskflow/examples/99_bottles.py
CHANGED
taskflow/examples/build_a_car.py
CHANGED
|
@@ -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
|
|
112
|
+
print('Task {} => {}'.format(details.get('task_name'), state))
|
|
115
113
|
|
|
116
114
|
|
|
117
115
|
flow = lf.Flow("make-auto").add(
|
taskflow/examples/buildsystem.py
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
83
|
-
|
|
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(" --
|
|
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(
|
|
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(
|
|
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("
|
|
66
|
-
|
|
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("
|
|
72
|
-
|
|
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("
|
|
79
|
-
|
|
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("
|
|
87
|
-
|
|
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("
|
|
101
|
-
|
|
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("
|
|
107
|
-
|
|
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("
|
|
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) 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
|
|
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
|
|
48
|
+
class DB:
|
|
51
49
|
def query(self, sql):
|
|
52
50
|
print("Querying with: %s" % (sql))
|
|
53
51
|
|
|
54
52
|
|
|
55
|
-
class UrlCaller
|
|
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
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
142
|
-
print("
|
|
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
|
|
149
|
+
class DummyUser:
|
|
152
150
|
def __init__(self, user, id_):
|
|
153
151
|
self.user = user
|
|
154
152
|
self.id = id_
|
taskflow/examples/graph_flow.py
CHANGED
|
@@ -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("
|
|
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("
|
|
110
|
+
sys.stderr.write("{} != {}\n".format(actual, value))
|
|
113
111
|
unexpected += 1
|
|
114
112
|
|
|
115
113
|
if unexpected:
|
taskflow/examples/hello_world.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
|
|
@@ -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(
|
|
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("
|
|
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("
|
|
85
|
+
print("{} {}: {}".format(prefix, name, message))
|
|
88
86
|
else:
|
|
89
|
-
print("
|
|
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 = "
|
|
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(
|
|
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(
|
|
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
|
|
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 '
|
|
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 '
|
|
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
|
|
@@ -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
|
|
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
|
|
42
|
-
|
|
39
|
+
print('Running flow {} {}'.format(engine.storage.flow_name,
|
|
40
|
+
engine.storage.flow_uuid))
|
|
43
41
|
engine.run()
|