149 Commits

Author SHA1 Message Date
Takashi Kajinami
80e1aadc49 Run pyupgrade to clean up Python 2 syntaxes
Update all .py source files by
 $ pyupgrade --py3-only $(git ls-files | grep ".py$")
to modernize the code according to Python 3 syntaxes.

pep8 errors are fixed by
 $ autopep8 --select=E127,E128,E501 --max-line-length 79 -r \
    --in-place taskflow

Also add the pyupgrade hook to pre-commit to avoid merging additional
Python 2 syntaxes.

Change-Id: Ifd0a0ade9789497482c7937bffd82c48acfb3d78
2025-04-02 15:23:12 +09:00
Takashi Kajinami
44f17d005f Remove six
This library no longer supports Python 2, thus usage of six can be
removed. This also removes workaround about pickle library used in
Python 2 only.

Change-Id: I19d298cf0f402d65f0b142dea0bf35cf992332a9
2022-05-18 16:12:37 +09:00
Michael Johnson
dc6495cfa1 Update TaskFlow for networkx 2.x
The networkx 2.x series has been out for two years now and supports
python 3.6 and greater[1]. This patch updates TaskFlow to require
a minimum of networkx 2.1. It also updates the code to support
recent deprecation expiration introduced in the 2.4 release.

[1] https://networkx.github.io/documentation/stable/news.html

Change-Id: Ife31d353ba80824ebc63c8b21ee90943badc8da3
2019-10-18 18:11:44 -07:00
Michal Arbet
d985c5a256 Fix code to support networkx > 1.0
With the release of NetworkX 2.0 the reporting API was
moved to view/iterator model. Many methods were moved from
reporting lists or dicts to iterating over the information.
Methods that used to return containers now return views and
methods that returned iterators have been removed in networkx.
Because of this change in NetworkX 2.0 , taskflow code
have to be changed also to support networkx > 2.0

Change-Id: I23c226f37bd85c1e38039fbcb302a2d0de49f333
Closes-Bug: #1778115
2018-07-11 13:11:51 +02:00
Pablo Iranzo Gómez
74221942ef Fix some misspellings in the function name and descriptions
Change-Id: I7e3451feb94b1f25b00c5e7b197bb6b527548306
2016-06-30 17:44:49 +02:00
Joshua Harlow
8e8156c488 Allow for alterations in decider 'area of influence'
Christmas came early.

Closes-Bug: #1479466

Change-Id: I931d826690c925f022dbfffe9afb7bf41345b1d0
2016-01-09 22:42:17 -08:00
Joshua Harlow
64583e075f Use graphs as the underlying structure of patterns
This unifies all the patterns to be graph based so
that they are more uniform and there underlying constraints
are more easy to understand (taskflow basically processes
graphs).

Change-Id: Ib2ab07c1c87165cf40a06508128010887f658391
2015-09-18 17:39:04 +00:00
Timofey Durakov
60a9e6a817 iter_nodes method added to flows
New method allows to iterate over flow node and
get access to node metadata during iteration.

Change-Id: Ib0fc77f0597961602fbc3b49ba09e4df815d8230
2015-08-28 17:54:25 +03:00
Joshua Harlow
5ff439299b Improve docstrings in graph flow to denote exceptions raised
Link the existing exceptions mentioned to there sphinx doc about
them and also adds a section about when the 'DependencyFailure'
exception is raised.

Also tweaks the class docstring a little, to make it easier to
understand.

Change-Id: Ie4b989444c5ad73660cc61c0c3b2b1702b669087
2015-08-05 17:36:44 -07:00
Joshua Harlow
65cecfedbd Add docs for u, v, decider on graph flow link method
The docstring is now quite important to know what the
params are (they are no longer as obvious due to the
decider addition) so add a useful docstring to that
method.

This also fixes how the targeted flow add was not passing
allow **kwargs as it should have been and removes the
duplicated docstrings that are in the child class (the
parent class docstrings are just fine).

Change-Id: Idacb7ee9f652fab4bdc762c1b49d7523e46e9a7b
2015-07-10 14:18:25 -07:00
Joshua Harlow
2b827e1e36 Add support for conditional execution
To make it possible to alter the runtime flow via a simple
conditional like structure make it possible to have the graph
flow link function take a decider that is expected to be some
callable that will decide (via a boolean return) whether the
edge should actually be traversed when running. When a decider
returns false; the affected + successors will be set into the
IGNORE state and they will be exempt from future runtime and
scheduling decisions.

Part of blueprint taskflow-conditional-execution

Change-Id: Iab0ee46f86d6b8e747911174d54a7295b3fa404d
2015-07-01 06:04:31 +00:00
Joshua Harlow
bb0af4f81d Use 'node' terminology instead of 'item' terminology
Since graphs are composed of 'nodes' it seems more
appropriate to use that terminology (which is known
to people with graph experience) instead of the non
descriptive and/or standard 'item' terminology.

Change-Id: I04a4521386d3cdf7e58fb9fa8cf26c00443c2cf6
2015-03-30 13:05:43 -07:00
Joshua Harlow
977d19caa3 Make the graph '_unsatisfied_requires' be a staticmethod
To make it possible for users to subclass this flow and
replace this method (if they so choose to) make it a static
method that is directed to the current module level function
and call into the staticmethod when used (users can override
staticmethods and change them in subclasses).

Change-Id: I747c45636596ca5a8ad81dabcbba12ab55ce77d7
2015-03-25 17:47:16 -07:00
Joshua Harlow
67f0f51464 Use ordered[set/dict] to retain ordering
Instead of using always using a set/dict which do not retain
use a ordered set and a ordered dict for requires, optional,
and provides and rebind mappings types so that the ordering
of these containers is maintained later when they are used.

These ordering can be useful depending on the atom type (such
as in a map and reduce tasks).

Partial-Bug: 1357117

Change-Id: I365d11bbba4aa221bc36ca15441acecf199b4d56
2015-03-11 18:12:06 +00:00
Joshua Harlow
3a8a78ee64 Use constants for link metadata keys
Instead of using strings (which can be easy to
mistype and get wrong), provide a set of constants
that can be used to attach and use these keys in
flows and at compilation.

This also helps make it more clear what the keys
do and where they are used.

Change-Id: I5283b27617961136a4582bbcfce4617f05e8dd1d
2014-10-18 13:24:12 -07:00
Joshua Harlow
d6ef68762e Relax the graph flow symbol constraints
In order to make it possible to have a symbol
tree we need to relax the constraints that are
being imposed by the graph flow.

Part of blueprint taskflow-improved-scoping

Change-Id: I2e14de2131c3ba4e3e4eb3108477583d0f02dae2
2014-09-08 20:55:45 +00:00
Joshua Harlow
76641d86b8 Relax the unordered flow symbol constraints
In order to make it possible to have a symbol
tree we need to relax and remove the constraints
that are being imposed by the unordered constraints
and later move those constraint checks and validations
into the engines compilation stage.

Part of blueprint taskflow-improved-scoping

Change-Id: I80718b4bc01fbf0dce6a95cd2fac7e6e2e1814d1
2014-09-08 20:55:41 +00:00
Joshua Harlow
2339bacaf7 Relax the linear flow symbol constraints
In order to make it possible to have a symbol
tree we need to relax and remove the constraints
that are being imposed by the linear constraints
and later move those constraint checks and validations
into the engines compilation stage.

Part of blueprint taskflow-improved-scoping

Change-Id: I6efdc821ff991e83572d89f56be5c678d007f9f8
2014-09-08 13:55:26 -07:00
Joshua Harlow
fa077c953f Revamp the symbol lookup mechanism
To complement the future changes in patterns we also want
to allow the execution of patterns to be affected in a similar
manner so that symbol lookup is no longer as confined as it was.

This change adds in the following:

- Symbol lookup by walking through an atoms contained scope/s.
- Better error messaging when symbols are not found.
- Adjusted & new tests (existing ones work).
- Better logging of the symbol lookup mechanism (helpful
  during debugging, although it is very verbose...)

Part of blueprint taskflow-improved-scoping

Change-Id: Id921a4abd9bf2b7b5c5a762337f8e90e8f1fe194
2014-09-08 13:00:25 -07:00
Joshua Harlow
e68d72f66e Be smarter about required flow symbols
Instead of blindly assuming all the symbols that
are provided automatically work for all flows even
if the flow has ordering constraints we should set
the base flow class requires property to be abstract
and provide flow specific properties that can do the
appropriate analysis to determine what the flows
unsatisfied symbol requirements actually are.

Part of blueprint taskflow-improved-scoping

Change-Id: Ie149c05b3305c5bfff9d9f2c05e7e064c3a6d0c7
2014-09-08 19:14:51 +00:00
Joshua Harlow
c558da07b6 Upgrade hacking version and fix some of the issues
Update hacking to the new requirements version and
fix about half of the new reported issues. The other
hacking issues are for now ignored until fixed by
adjusting our tox.ini file.

This commit fixes the following new hacking errors:

H405 - multi line docstring summary not separated
       with an empty line
E265 - block comment should start with '# '
F402 - import 'endpoint' from line 21 shadowed by
       loop variable

Change-Id: I6bae61591fb988cc17fa79e21cb5f1508d22781c
2014-06-13 19:27:17 -07:00
Ivan A. Melnikov
095650653d Put provides and requires code to basic Flow
Code that calculates provides and requires for flow is almost
identical for all patterns, so this change makes it completely
identical and puts it to the base class. Other patterns are
still allowed to override these properties for sake of customization
or optimization.

Change-Id: I6e875e863047b5287ec727fc9a491f252f144ecf
2014-05-07 11:17:50 +04:00
Joshua Harlow
5ca61f956e Add a directed graph type (new types module)
Most of the utility graph functions we have can
be connected to a directed graph class that itself
derives (and adds on to) the networkx base class.

Doing this allows for functionality that isn't exposed
in networkx to be exposed in our subclass (which is a
useful pattern to have).

It also makes it possible (if ever needed) to replace
the networkx usage in taskflow with something else if
this ever becomes a major request.

Change-Id: I0a825d5637236d7b5dbdbda0d426adb0183d5ba3
2014-04-20 17:28:27 -07:00
Joshua Harlow
1ba21b7e43 Fix spelling mistake
Change-Id: Ic3ae069565f0f9e25f243eead105e1b97fe437fc
2014-03-26 16:23:34 -07:00
Joshua Harlow
a570aead53 Adjust the exception hierachy
Group the exceptions into the following groups
  * Storage
  * Jobs
  * Execution
  * Other (wrapped failure here)

This grouping makes it easier to understand where
one type of exception should be used vs using another
type of exception.

Backwards incompatible changes:
  * StorageError -> StorageFailure
  * AlreadyExists -> Duplicate
  * WrappedFailure now inherits from Exception
    and not directly from TaskFlowException since it
    wraps arbitrary other exceptions and is not
    specific to taskflow.

Cleanups:
  * JobNotFound -> NotFound
  * EmptyFlow -> Empty
  * JobAlreadyExists -> AlreadyExists
  * InvariantViolation (X)
  * ConnectionFailure (X)

Change-Id: I0e1e81b513fbbc7adb8bfaa1244993e345ab70d3
2014-03-24 20:42:30 -07:00
Jenkins
ce12f36e56 Merge "Rework graph flow unit tests" 2014-03-24 11:03:10 +00:00
Jenkins
27f866e381 Merge "Linear flow: mark links and rework unit tests" 2014-03-24 11:00:33 +00:00
Jenkins
dc180afb94 Merge "Drop indexing operator from linear flow" 2014-03-23 03:34:10 +00:00
Jenkins
816315e29d Merge "Removed copyright from empty files" 2014-03-23 03:32:34 +00:00
Ivan A. Melnikov
261d69a759 Rework graph flow unit tests
This commit adds unit tests that check graph flow methods without
executing or flattening it. Now-redundant tests from other test
suites are deleted.

Change-Id: I8dafe0f9b295428831eddb3f9fd48f042d2f1ffc
2014-03-22 19:22:00 +04:00
Ivan A. Melnikov
3c18637399 Linear flow: mark links and rework unit tests
- add 'invariant': True to all links produced by linear flow;
- write new unit tests for basic functionality of linear flow
  pattern;
- remove some simple now-redundant unit tests from
  test_flow_dependencies.

Change-Id: I1f4fa8a1dfc61485555a10e8d0629a67aab1997f
2014-03-21 14:26:24 +04:00
Ivan A. Melnikov
63d01d9a19 Drop indexing operator from linear flow
It is not needed. Also, using it complicates transitioning
to another pattern (e.g. graph flow) and encourages bad
programming practices.

Change-Id: I9d0a4646a27df1a11ed436f26a0cb074b717647e
2014-03-21 13:06:36 +04:00
Ivan A. Melnikov
1011df951e Iteration over links in flow interface
In addition to iteration over its children (atoms or subflows) each
pattern now provides iter_links() method that iterates over
dependency links. This allows engines to treat all patterns
in the same way instead knowing what structure each pattern expresses.

Change-Id: I52cb5b0b501eefc8eb56a9ef5303aeb318013e11
2014-03-21 11:11:15 +04:00
Anastasia Karpinska
1222bda50d Add retry to Flow patterns
Implement dependency checks when adding items to flows:
- retry can't be depended on tasks from it's subflow.
- retry can't provide same values as tasks or other retries

Change-Id: Iffa8e673fd2de39407ae22cd38ad523d484cbba7
2014-03-14 11:49:10 +02:00
Ivan A. Melnikov
8adec345e2 Remove extra quote symbol
Three quotes is just enough to open multiline string literal.

Change-Id: I15d489f1a76be81a05b2378ef35120ee84d5eb04
2014-03-13 12:30:21 +04:00
yangxurong
e0ca45b7d4 Removed copyright from empty files
According to policy change in HACKING:
http://docs.openstack.org/developer/hacking/#openstack-licensing
empty files should no longer contain copyright notices.

Change-Id: I1f825add9036623ef626b48c66206ac2b452c592
Partial-Bug: #1262424
2014-02-22 17:16:29 +08:00
yangxurong
17bf3db06a Remove extraneous vim configuration comments
Remove line containing

comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4

Change-Id: I7581cc88b8de433d5609ed06c6570b0b45c13573
Closes-Bug:#1229324
2014-02-14 16:56:50 +08:00
skudriashev
aea1f401eb Doc strings and comments clean-up
* Added missing period for doc strings
* Correct syntax errors
* Remove H402 from flake8 ignore list

Change-Id: Ia8592bf99378e3658d6cca2ceb148bf9eb0b5de8
2014-01-26 23:08:39 +02:00
Jenkins
8c7696967e Merge "Skip invariant checking and adding when nothing provided" 2014-01-24 12:54:04 +00:00
Ivan A. Melnikov
9d0b16e7fb Exceptions cleanup
Most TaskFlow exception don't have 'Exception' suffix in their names, so
we drop it from the few that have it, for sake of consistency and more
concise and expressive code.

MissingDependencies parent object is changed from InvalidState to
InvariantViolation, which is more appropriate.

Unused ClosedException is dropped.

Breaking change: any client code that used renamed exceptions,
ClosedException or relied on catching MissingDependencies as
InvariantViolationException is affected.

Change-Id: I649b7760d382ccb6df333bdffd667ba6b67a431e
2014-01-14 14:06:33 +04:00
Anastasia Karpinska
14f229ae1e Check tasks should not provide same values
Check is added to linear_flow and unordered_flow patterns that
there are no two child items provide same values.

Unit tests added.

Change-Id: I7a293d58a962de37ba2fd1dd989bf0a218417430
Closes-Bug: #1264995
2014-01-02 14:21:15 +02:00
Joshua Harlow
f6e5d295e4 Skip invariant checking and adding when nothing provided
Change-Id: Icc3dca675820d331fb1d6e8f3a5a4169d1b2d113
2013-12-31 10:19:44 -08:00
Joshua Harlow
bdf1bf18dc Don't forget to return self
To retain the functionality where we can chain
function calls to add, link we need to return the
object we are acting on (instead of none).

Change-Id: Iadf0f9d3a21b6d079c1edd29063196180f5222ed
2013-12-06 19:52:52 -08:00
Ivan A. Melnikov
db556f9f67 Targeted graph flow pattern
This change adds graph flow like pattern that is able to ignore graph
nodes (not even add them to flow) if they are not needed to run certain
task.

Implements blueprint targeted-graph-flow
Change-Id: I57d5a1c0598bd032d77e2a262b2d9644418ce3f6
2013-12-02 19:07:30 +04:00
Ivan A. Melnikov
568843f8ad Remove uuid from taskflow.flow.Flow
In a way our resumption works it may not correspond uuid from flow
details, and so it is hardly useful.

Change-Id: I090d017e2f0f8475594af94a2430a34e6ed1ce70
2013-10-15 10:52:05 +04:00
Joshua Harlow
ee83a3ff6f Pattern comment additions/adjustments
Change-Id: I3154d1c228474d8699f3ae4d0be2fb46406a2f41
2013-10-12 23:13:10 -07:00
Joshua Harlow
2dc03b7333 Add reasons as to why the edges were created
Reasons are useful for later analysis when running
as to why the edge between two nodes was created so
when linking items in the graph it would be nice to
assign a reason.

Change-Id: I2185cf5fb3c2c07c0f5536d3b210080c6f61d5dd
2013-10-07 15:39:44 -07:00
Joshua Harlow
57f5b8cea4 Allow access by index
Since a linear flow is a linear set of tasks or subflows
we can easily add in an accessor that can fetch these
items by index which is useful for indexing for any
post-add operations.

Change-Id: Ib1690584a08e24fae29285225e6c519b06ce2ddd
2013-10-04 18:22:21 -07:00
Joshua Harlow
26a70ea5df Don't allow mutating operations on the underlying graph
Instead of allowing a direct graph return of the underlying
graph_flow graph we should return a frozen version instead so that
users of the returned value can not mutate the graph without going
through the graph_flow pattern (which could have undesired and
harmful side-effects if this occurs).

Change-Id: I38b35119d6e7bd7387b8ab467eba53aee5500629
2013-09-30 00:02:04 +00:00
Anastasia Karpinska
a333c48523 Task decorator was removed and examples updated
Change-Id: Ie49fe6c2f48a18130d1fd2a3aa5485cd8cee4ed4
2013-09-23 13:54:28 +04:00