flexbe_behavior_engine icon indicating copy to clipboard operation
flexbe_behavior_engine copied to clipboard

__init__ list: inline comments prevent proper loading

Open Achllle opened this issue 6 years ago • 3 comments

I couldn't figure out why my input_keys and output_keys weren't getting loaded and it seemed like updates to the code didn't affect the states even after rebuilding the workspace, sourcing, and relaunching the app.

My state __init__ had something like this:

super(TheGreatestState, self).__init__(
	outcomes=['finished', 'failure'],
	input_keys=['dummy_out_key'],  # should dummy_out_key2 get added here?
	output_keys=['dummy_out_key'])

Finally I realized 'hey I wonder if the comment messes things up'. And when I deleted it, the app immediately updated to include the input and output keys!

AFAIK this shouldn't cause a problem, and at least should throw a warning or error. To check my own sanity I created a dummy class+method to test this and it worked fine with comments included.

Achllle avatar Jan 14 '20 22:01 Achllle

Thanks for reporting! It looks like this case is not accounted for by the regex-based state parser of the app. I will work on fixing this.

Recently, I added a new alternative state parser that you can manually select in the configuration. It is based on Python instead of regex expressions, so this issue should not show there. If you want, you can switch the state parser and try again in the meantime until this is fixed.

pschillinger avatar Jan 19 '20 10:01 pschillinger

Makes sense, I didn't think about that. The fix is lower priority imo than a parser error.

Achllle avatar Jan 19 '20 20:01 Achllle

I tried to add a comment myself and was actually not able to reproduce this issue, the state was still displayed correctly. Indeed, the example above matches the pattern: https://regex101.com/r/TldmoK/1

Is there anything else that changed and could be related? Also, I noticed that the regex requires a linebreak in the end, so the following is not recognized:

super(TheGreatestState, self).__init__(
	outcomes=['finished', 'failure'],
	input_keys=['dummy_out_key'],
	output_keys=['dummy_out_key'])  # comment here should not be an issue, but it is

This I will fix already.

pschillinger avatar Feb 01 '20 17:02 pschillinger