Closed spearsear closed 3 months ago
Hi @spearsear,
I could reproduce the error.
I agree that may_
and the actual transition should come to the same conclusion.
This is an MRE based on your provided example:
from transitions.extensions import HierarchicalMachine
from transitions.extensions.nesting import NestedState
NestedState.separator = "~"
states = [
'workflow_started',
{
'name': 'running_qtr_1',
'parallel': [
{
'name': 'running_jan',
'children': [
'jan_started', 'jan_succeeded'
],
'initial': 'jan_started'
},
{
'name': 'running_feb',
'children': [
'feb_started', 'feb_succeeded'
],
'initial': 'feb_started',
'transitions': [
['end_success_feb', 'feb_started', 'feb_succeeded'],
]
},
]
},
]
transitions = [
{'trigger': 'next', 'source': 'workflow_started', 'dest': 'running_qtr_1'}
]
initial_state = 'workflow_started'
machine = HierarchicalMachine(
states=states,
transitions=transitions,
initial=initial_state
)
machine.next()
print(f"current_state is: {machine.state}")
may_res = machine.may_end_success_feb()
res = machine.end_success_feb()
assert may_res == res
print(f"current_state is: {machine.state}")
Thank you for taking the time to report a bug! Your support is essential for the maintenance of this project. Please fill out the following fields to ease bug hunting and resolving this issue as soon as possible:
Describe the bug In parallel state of a hierarchical machine, the may_ function for a trigger returns False, yet it should return True, since the trigger indeed return True
I have a simple statemachine which runs a task for each month in quarter 1 parallelly, then run each month in quarter 2 parallelly. When it reach the parallell state of run_qtr1, may function of any trigger in quater1 should return True, yet it returns False. And I indeed can run the trigger function
Expected behavior may_ function for the triggers in parallel states should return True
Additional context Output of above code: