Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'previous_data' #39

Open
gas0189 opened this issue Oct 24, 2016 · 6 comments · May be fixed by #40
Open

KeyError: 'previous_data' #39

gas0189 opened this issue Oct 24, 2016 · 6 comments · May be fixed by #40
Assignees

Comments

@gas0189
Copy link

gas0189 commented Oct 24, 2016

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
Copy link

PXke commented Oct 24, 2016

@gas0189 thanks for bug report.

@PXke
Copy link

PXke commented Oct 24, 2016

Dear @gas0189,

I will have a patch available tonight ( Europe )

Best regards.

PXke added a commit to PXke/workflow that referenced this issue Oct 25, 2016
* FIX: Saves previous data if an iteration has been done.  (closes inveniosoftware-contrib#39)
PXke added a commit to PXke/workflow that referenced this issue Oct 25, 2016
* FIX Saves previous data if an iteration has been done (closes inveniosoftware-contrib#39).

* FIX Calls the correct function when the list of item to iterate is
  generated.

* FIX Handles special case where the list of item to iterate is
  empty.

* NEW Adds unit tests covering 100% of FOR pattern.

Signed-off-by: Guillaume Lastecoueres <[email protected]>
@PXke PXke linked a pull request Oct 25, 2016 that will close this issue
@kaplun
Copy link
Member

kaplun commented Jan 9, 2017

Hi @PXke, any news about your fix?

@hyunny88
Copy link

hyunny88 commented Jan 25, 2017

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
Copy link

fangkyo commented Sep 15, 2017

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
Copy link

qiwihui commented Jan 8, 2018

Hi @PXke any update for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants