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
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
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
Just like it's useful to be able to translate a execution
graph into a dot diagram, the same usefulness can be helpful
for the engine scoping hierarchy that is created, to make
it easily possible to do this provide a tree method that
converts itself (and its children) into a direct graph which
can then easily be exported as a dot diagram (and then
rendered as needed).
Change-Id: I0addc2dee4cdce03ee5f33832a419303abc77db4
When a tree node is frozen it should not be possible to remove nodes
from it or cause that tree node to disassociate itself from its parent,
so make sure that the appropriate decorator is used to ensure this
can not happen (and add tests that verify an exception is raised when
mutations are attempted).
Change-Id: I27e4af7b891ea3fd1826d5a5e71e808ad5af7647
We can just use the non-recursive depth first iteration
of nodes when scanning for atoms to select for a given
scope level instead of using recursive calls to achieve
the same effect.
This makes it possible to have large and heavily nested
flows that are not restricted by the python stack limit.
Change-Id: I0d18565680f777adbdfca9d4983636c6b3e848da
This adjusted variant creates the same output but is hopefully
easier to understand and follow than the recursive version.
This version is also not limited by the python stack limit which
is a general good thing to avoid being limited by.
It also adds a bunch of tests to make sure the format is as expected
under various tree structures.
Change-Id: I2ae42c7c1bf72794800929250bcf6ccbe658230b
Allow providing a node to string function that will be activated
when the root node pformat routine needs to format a node into
a string (for viewing purposes); this allows for subclasses or
other users of nodes to provide there own function that they can
specialize as they see fit (without duplicating the pformat
routine itself).
To start use it to print out the node link target in the fake
in-memory filesystem when a link is encountered.
Change-Id: I33b8f1ec8d30d72ae35971e35f5edd84a9145db7
When a node desires to be removed from its parent (or
a parent wants to remove a child) it is quite useful
to provide functions that do just this so that nodes
can remove themselves or there children when this kind
of usage is desired.
Change-Id: I0071e9a7e15219e0cb7b92779e4f5a08596e5d34
When a local search is preferred allow for it
to be done by passing in a 'only_direct' option,
also allows passing in a 'include_self' option
to ignore/include the current node when finding.
The defaults of 'include_self' and 'only_direct'
work just as they did prior to this change, so that
the addition does not affect current usage(s) of
this method.
Change-Id: I89fb476bee32144092ea141ca3b971118ab633be
Since quite a few of the types check for being
frozen and disallow mutations on there instances
we can take advantage of a common decorator that
checks the frozen attribute and raises instead
of duplicating the same logic at the start of
the mutating methods.
Change-Id: I8c81a26d2d39bb9da4f68d64e07f67ac26ee0b08
Partial-Bug: #1374202
Documents what the function parameters are, what
is the type of the parameters passed what return
values are, how it is used and what they should
provide for it when using a method/class or deriving
from an existing class.
Change-Id: Ie81b3a446c9fee2dad9411efa28dad8d455b06ba
To complement the DFS iterator that we provide in our
tree helper/type class add a BFS iterator as well so that
when/if we extract this module to elsewhere we can have
a nice featureful (and hopefully useful) set of iterators
for folks to use.
Change-Id: I1bc10c25bb62a5ffc85863f3f894d5469db95ff6
When the dfs iteration is requested to start at the provided
nodes children make sure that we create the stack in the same
way as we do its children to ensure that the DFS iteration
order is maintained correctly in this situation.
Change-Id: I9d5e3a46b4d2349ab1662a634d635b2052be4a55
To match the table type (which also uses class constants
for pformatting) have the tree type also use class constants
in its pformat method; this makes it easier to understand
what the constants are (and allows them to change if needed)
by associating 'useful' variable names to them...
Change-Id: I0a392542d2572e12718972a9f74ecf838918699d
To at least try to support things like windows it's better
if we can make an attempt to use the platform neutral
characters for line separator(s) where appropriate.
Change-Id: Icc533ed4d4c94f461b7f19600b74146221f17b18
Instead of creating a temporary list of the node using
its __iter__() function and then reversing that list just
use the natively provided reverse_iter() method instead
that reduces this wasteful list copying and creating in
the first place.
Also does the same in the pformat() function which was
needlessly creating a temporary list of children nodes
instead of just using the nodes __iter__() functionality
directly.
Change-Id: Ice4001e6d014d2c0a1f7d8b916c60370fd5443a7
Instead of dynamically replacing the existing method
with a new method, just have the existing method check
if the node has been frozen and immediately abort, this
workers better with decorators, subclassing...
This also unifies how freezing is done across all types
that support it, ensuring that the frozen attribute can
be set by users (if they so choose).
Change-Id: I1e6c6568b7f91765d654d25ca6e68e9b568603fc
Also makes some docstring adjustments to make sure
the documentation looks readable (especially the
inline examples).
Part of blueprint top-level-types
Change-Id: Ic6f02ce92449ee23aa9be8645edd8f6f11ee18ab
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
A tree module will be very useful for tracking tree
structures in taskflow. So to encourage development and
usage of such structures add a type module and helper
classes that can be used perform tree operations on
tree structures.
Change-Id: I63c0653d051aeb4d1ea8a55f0e25fc25ff9e37f1