22 Commits

Author SHA1 Message Date
Stephen Finucane
2a6420a3ed Add ruff
Change-Id: I2518e0cf928210acf9cfb2e5f4c19f973df64485
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2026-03-12 19:39:58 +00:00
Takashi Kajinami
2b5a92bd01 Drop redundant assertion method overrides
... and use the built-in ones instead.

Also replace assertDictEqual because assertEqual should select
an appropriate method automatically[1].

[1] https://docs.python.org/3.13/library/unittest.html

The list of type-specific methods automatically used by assertEqual()
are summarized in the following table. Note that it’s usually not
necessary to invoke these methods directly.

Change-Id: I4b7d3563e5a025cd3efa602a28c12865dcf3474d
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
2026-01-09 11:05:29 +00:00
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
0000c79203 Bump hacking
hacking 3.0.x is too old.

Change-Id: Idbc349cbd348fb73a45c68c5f5b884c6a877ef4f
2024-01-28 16:04:41 +09:00
Michael Johnson
2521e3ee00 Quote string representations
networkx 2.8.3 will raise errors if certain characters, such as a colon, in the node names and the string is not quoted.
This patch double quotes flow, node, and task string representations to make sure there are not issues with these characters occuring in the names.

Story: 2010083
Change-Id: Ib0941cddf14dde5d6b9f97fe0224d6e6f3975226
2022-06-10 11:45:32 +02:00
melissaml
cf327a2e2d Switch from unittest2 compat methods to Python 3.x methods
With the removal of Python 2.x we can remove the unittest2 compat
wrappers and switch to assertCountEqual instead of assertItemsEqual

We have been able to use them since then, because
testtools required unittest2, which still included it. With testtools
removing Python 2.7 support [3][4], we will lose support for
assertItemsEqual, so we should switch to use assertCountEqual.

[1] - https://bugs.python.org/issue17866
[2] - https://hg.python.org/cpython/rev/d9921cb6e3cd
[3] - testing-cabal/testtools#286
[4] - testing-cabal/testtools#277

Change-Id: Iaa8251a1e9965a00fe99b7a740a104c011260340
2020-07-05 20:04:04 +08:00
Vu Cong Tuan
db61fad6b2 Replace assertRaisesRegexp with assertRaisesRegex
assertRaisesRegexp was renamed to assertRaisesRegex in Py3.2
For more details, please check:
https://docs.python.org/3/library/
unittest.html#unittest.TestCase.assertRaisesRegex

Change-Id: I89cce19e80b04074aab9f49a76c7652acace78b3
Closes-Bug: #1436957
2017-06-03 13:40:12 +07: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
a79ca4883a For taskflow patterns don't show taskflow.patterns prefix
Showing the full name in flow __str__() isn't expecially
helpful and clutters up graphviz usage and similar so if a taskflow
built-in pattern is stringified just use the short name (that does
not start with taskflow.patterns instead of the full long name).

Change-Id: Icd8c26eab1e19d6ecf9c4e8e82e6d6902ce5b6ea
2016-01-05 15:38:43 -08:00
lin-hua-cheng
b3e3e05a02 Fix order of assertEqual for unit.patterns
First parameter should be the expected value.

Change-Id: I06140e4be87663136483d1e7be3bc471fbbbf92b
Partial-Bug: #1357117
2015-10-17 01:22:21 -07: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
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
Manish Godara
06ffceea77 Update Flow::__str__
The current implementation seems a little cryptic so updating it
to clearly indicate the atom count.

Change-Id: I4f97e458a4b80e33b3d6348a3ef632398586ed47
2015-02-17 14:18:57 -08: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
Christian Berendt
6132647fb7 Enabled hacking checks H305 and H307
* H305  imports not grouped correctly
* H307  like imports should be grouped together

Change-Id: If1dd9c89f65ede6959865a885777cb08c263eca0
2014-07-17 09:05:48 +02: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
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
09f0da99e3 Unit tests for unordered flow
This change adds unit tests that check unordered flow methods
without loading it into engine and executing it.

Change-Id: I665b6fe070759061edf7a7da4f117c0269c9c3cf
2014-03-21 15:26:01 +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