Files
deb-python-taskflow/taskflow/tests/unit/test_flow_dependencies.py
Rick van de Loo c7e8c868cd Allow same deps for requires and provides in task
This change removes the DependencyFailure that is raised when a task
requires the same dependency as it provides. Taskflow returns a
frozenset([]) instead of a frozenset() when more than one value with the
same name is in the store.

This prevents the need for an inconvenient rename function when you want
to update a store variable with a new value.

Example case:
class Inc(task.Task):
    def execute(self, a):
        return a + 1

class AwkwardRename(task.Task):
    def execute(self, b):
        return b

store = {
    'a': 1
}
f = linear_flow.Flow('inc-flow')
f.add(
    Inc('t1',
        provides='b',
        requires='a',
        ),
    AwkwardRename('t2',
                  provides='a',
                  requires='b'))

e = engines.load(f, store=store)
e.run()
print e.storage.fetch('a', many_handler=lambda x: x[-1])

Now with ability to have the same provides as requires:
class Inc(task.Task):
    def execute(self, a):
        return a + 1

store = {
    'a': 1
}
f = linear_flow.Flow('inc-flow')
f.add(
    Inc('t3',
        provides='a',
        requires='a'),
)

e = engines.load(f, store=store)
e.run()
print e.storage.fetch('a', many_handler=lambda x: x[-1])

Change-Id: I421e1ab33508c25baf78bd76df158bb6116d6fb0
2015-05-25 22:57:22 +10:00

18 KiB