{"action":"created","issue":{"url":"https://api.github.com/repos/gems-uff/noworkflow/issues/80","repository_url":"https://api.github.com/repos/gems-uff/noworkflow","labels_url":"https://api.github.com/repos/gems-uff/noworkflow/issues/80/labels{/name}","comments_url":"https://api.github.com/repos/gems-uff/noworkflow/issues/80/comments","events_url":"https://api.github.com/repos/gems-uff/noworkflow/issues/80/events","html_url":"https://github.com/gems-uff/noworkflow/issues/80","id":131745596,"number":80,"title":"Error while using Tracer","user":{"login":"braganholo","id":1494494,"avatar_url":"https://avatars.githubusercontent.com/u/1494494?v=3","gravatar_id":"","url":"https://api.github.com/users/braganholo","html_url":"https://github.com/braganholo","followers_url":"https://api.github.com/users/braganholo/followers","following_url":"https://api.github.com/users/braganholo/following{/other_user}","gists_url":"https://api.github.com/users/braganholo/gists{/gist_id}","starred_url":"https://api.github.com/users/braganholo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/braganholo/subscriptions","organizations_url":"https://api.github.com/users/braganholo/orgs","repos_url":"https://api.github.com/users/braganholo/repos","events_url":"https://api.github.com/users/braganholo/events{/privacy}","received_events_url":"https://api.github.com/users/braganholo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/gems-uff/noworkflow/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-05T20:19:13Z","updated_at":"2016-02-06T20:52:05Z","closed_at":"2016-02-06T20:46:27Z","body":"I tried to execute noWorkflow with Tracer, and got an error. It runs with no error if I don't use the Tracer (now run simulate_data_collection.py)\r\n\r\nRamster:simulate_data_collection vanessa$ now run -e Tracer simulate_data_collection.py\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 149, in trace_call\r\n    self.argument_captor.capture(frame, activation)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/argument_captors.py\", line 212, in capture\r\n    act_arg = order[j]\r\nIndexError: list index out of range\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 149, in trace_call\r\n    self.argument_captor.capture(frame, activation)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/argument_captors.py\", line 212, in capture\r\n    act_arg = order[j]\r\nIndexError: list index out of range\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 382, in trace_line\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 382, in trace_line\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 382, in trace_line\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 382, in trace_line\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 145, in trace_call\r\n    self.activation_stack[-1]\r\nIndexError: list index out of range\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 382, in trace_line\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 145, in trace_call\r\n    self.activation_stack[-1]\r\nIndexError: list index out of range\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 182, in trace_return\r\n    self.close_activation(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 288, in close_activation\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 382, in trace_line\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 145, in trace_call\r\n    self.activation_stack[-1]\r\nIndexError: list index out of range\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 382, in trace_line\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 182, in trace_return\r\n    self.close_activation(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 288, in close_activation\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 182, in trace_return\r\n    self.close_activation(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 288, in close_activation\r\nTraceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 201, in tracer\r\n    super(Profiler, self).tracer(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 53, in tracer\r\n    self.event_map[event](frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 182, in trace_return\r\n    self.close_activation(frame, event, arg)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/slicing.py\", line 288, in close_activation\r\nlist index out of range\r\n[now] the execution finished with an uncaught exception. Traceback (most recent call last):\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/__init__.py\", line 54, in collect_provenance\r\n    exec(metascript.compiled, metascript.namespace)\r\n  File \"/Users/vanessa/workspace/yw-prototypes/src/main/resources/examples/simulate_data_collection/simulate_data_collection.py\", line 273, in <module>\r\n    simulate_data_collection(cassette_id, sample_score_cutoff)\r\n  File \"/Users/vanessa/workspace/yw-prototypes/src/main/resources/examples/simulate_data_collection/simulate_data_collection.py\", line 34, in simulate_data_collection\r\n    with run_logger(log_file_name=\"run/run_log.txt\") as run_log:\r\n  File \"/Users/vanessa/workspace/yw-prototypes/src/main/resources/examples/simulate_data_collection/simulate_data_collection.py\", line 227, in __init__\r\n    self.log_file = open(log_file_name, 'wt') if log_file_name is not None else None\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/base.py\", line 101, in open\r\n    self.add_file_access(file_access)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 88, in add_file_access\r\n    activation = self._current_activation(ignore_open=True)\r\n  File \"/Users/vanessa/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/noworkflow/now/prov_execution/profiler.py\", line 78, in _current_activation\r\n    if astack[-1] is not None:\r\nIndexError: list index out of range"},"comment":{"url":"https://api.github.com/repos/gems-uff/noworkflow/issues/comments/180862880","html_url":"https://github.com/gems-uff/noworkflow/issues/80#issuecomment-180862880","issue_url":"https://api.github.com/repos/gems-uff/noworkflow/issues/80","id":180862880,"user":{"login":"JoaoFelipe","id":327789,"avatar_url":"https://avatars.githubusercontent.com/u/327789?v=3","gravatar_id":"","url":"https://api.github.com/users/JoaoFelipe","html_url":"https://github.com/JoaoFelipe","followers_url":"https://api.github.com/users/JoaoFelipe/followers","following_url":"https://api.github.com/users/JoaoFelipe/following{/other_user}","gists_url":"https://api.github.com/users/JoaoFelipe/gists{/gist_id}","starred_url":"https://api.github.com/users/JoaoFelipe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoaoFelipe/subscriptions","organizations_url":"https://api.github.com/users/JoaoFelipe/orgs","repos_url":"https://api.github.com/users/JoaoFelipe/repos","events_url":"https://api.github.com/users/JoaoFelipe/events{/privacy}","received_events_url":"https://api.github.com/users/JoaoFelipe/received_events","type":"User","site_admin":false},"created_at":"2016-02-06T20:52:05Z","updated_at":"2016-02-06T20:52:05Z","body":"It seems to be a bug related to a for loop inside a with.\r\nI could reproduce it with the following code:\r\n```python\r\nclass ContextManager:\r\n\r\n    def __enter__(self):\r\n        return 2\r\n\r\n    def __exit__(self, *args, **kwargs):\r\n        pass\r\n\r\ndef func():\r\n    context = ContextManager()\r\n\r\n    with context as value:\r\n        for i in range(value):\r\n            print(i)\r\n\r\nfunc()\r\n```\r\n\r\nIt occurs because we try to get the calls by lineno and lasti on the bytecode.\r\nWITH_CLEANUP opcode results in a call to __exit__.\r\nBy capturing line and lasti of WITH_CLEANUP, we can usually detect the calls. However, in this specific case, the loop mess up with the the lineno, and it fails to obtain the definition of with from the bytecode.\r\nThe best way to match the run-time \"with\" and the bytecode WITH_CLEANUP would be using only the lasti in the code object. \r\nSince I don't know how to identify the code object in the disassembly, and it would require some time to replace references from lines to code objects, I'll keep the current solution, but silently ignore calls with messed up linenos.\r\nFor now, it will be fine. If we improve some collection on with statements (to capture exceptions, for instance), it may be a problem. Hopefully, we will only do that after #84 "}}