inveniosoftware-contrib / workflow

Simple Pythonic Workflows
https://workflow.readthedocs.io
Other
152 stars 46 forks source link

KeyError: 'previous_data' #39

Open gas0189 opened 8 years ago

gas0189 commented 8 years ago

When I run the 'Loops and interrupts' example in doc I got a error: Traceback (most recent call last): File "C:\Python35-32\lib\site-packages\workflow\engine.py", line 542, in _process e.class.name AttributeError: type object 'TransitionActions' has no attribute 'KeyError'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.5\helpers\pydev\pydevd.py", line 2411, in globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.5\helpers\pydev\pydevd.py", line 1802, in run new data: [0] new data: [0, 1] launch(file, globals, locals) # execute the script File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.5\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "D:/4delete/demo_workflow2/demo_control_wf.py", line 84, in my_engine.process([[], [0, 1], [0, 1, 0, 1]]) # handle multi-tokens in same workflow one-by-one. File "C:\Python35-32\lib\site-packages\workflow\engine.py", line 390, in process self._process(objects) File "C:\Python35-32\lib\site-packages\workflow\engine.py", line 547, in _process obj, self, callbacks, exc_info File "C:\Python35-32\lib\site-packages\workflow\engine.py", line 970, in Exception reraise(_exc_info) File "C:\Python35-32\lib\site-packages\six.py", line 686, in reraise raise value File "C:\Python35-32\lib\site-packages\workflow\engine.py", line 529, in _process self.run_callbacks(callbacks, objects, obj) File "C:\Python35-32\lib\site-packages\workflow\engine.py", line 465, in run_callbacks indent + 1) File "C:\Python35-32\lib\site-packages\workflow\engine.py", line 481, in run_callbacks self.execute_callback(callback_func, obj) File "C:\Python35-32\lib\site-packages\workflow\engine.py", line 564, in execute_callback callback(obj, self) File "C:\Python35-32\lib\site-packages\workflow\patterns\controlflow.py", line 326, in _for eng.extra_data["_Iterators"][step]["previous_data"]) *_KeyError: 'previous_data'**

Finally I catched the bug in 'controlflow.py' LINE303: the follow code block MUST be out of 'if step not in eng.extra_data["_Iterators"]:'

    # Store previous data
    if 'current_data' in eng.extra_data["_Iterators"][step]:
        eng.extra_data["_Iterators"][step]["previous_data"] = \
            eng.extra_data["_Iterators"][step]["current_data"]

Is that right?

PXke commented 8 years ago

@gas0189 thanks for bug report.

PXke commented 8 years ago

Dear @gas0189,

I will have a patch available tonight ( Europe )

Best regards.

kaplun commented 7 years ago

Hi @PXke, any news about your fix?

hyunny88 commented 7 years ago

I resolved this issue.

controllflow lineno.324

else: if "previous_data" in eng.extra_data["_Iterators"][step]: setter(obj, eng, step, eng.extra_data["_Iterators"][step]["previous_data"])

fangkyo commented 7 years ago

Hi @kaplun, 2.1.3 was just released on 2017-09-12 but I found this issue still exists in the new version. The FOR loop still doesn't work. Do you have any plan to fix it since @PXke didn't merge her/his change.

Thanks,

qiwihui commented 6 years ago

Hi @PXke any update for this issue?