{"action":"created","issue":{"url":"https://api.github.com/repos/wtsi-hgi/python-baton-wrapper/issues/44","repository_url":"https://api.github.com/repos/wtsi-hgi/python-baton-wrapper","labels_url":"https://api.github.com/repos/wtsi-hgi/python-baton-wrapper/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/wtsi-hgi/python-baton-wrapper/issues/44/comments","events_url":"https://api.github.com/repos/wtsi-hgi/python-baton-wrapper/issues/44/events","html_url":"https://github.com/wtsi-hgi/python-baton-wrapper/issues/44","id":175528293,"number":44,"title":"Bug in _BatonIrodsMetadataMapper -- index out of range","user":{"login":"irinaColgiu","id":218259,"avatar_url":"https://avatars.githubusercontent.com/u/218259?v=3","gravatar_id":"","url":"https://api.github.com/users/irinaColgiu","html_url":"https://github.com/irinaColgiu","followers_url":"https://api.github.com/users/irinaColgiu/followers","following_url":"https://api.github.com/users/irinaColgiu/following{/other_user}","gists_url":"https://api.github.com/users/irinaColgiu/gists{/gist_id}","starred_url":"https://api.github.com/users/irinaColgiu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irinaColgiu/subscriptions","organizations_url":"https://api.github.com/users/irinaColgiu/orgs","repos_url":"https://api.github.com/users/irinaColgiu/repos","events_url":"https://api.github.com/users/irinaColgiu/events{/privacy}","received_events_url":"https://api.github.com/users/irinaColgiu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-07T15:09:12Z","updated_at":"2016-09-07T15:33:32Z","closed_at":null,"body":"I am pretty sure this is a bug, though i haven't investigated it very thoroughly. So you iterate with _i_ which takes values in the range of (0, nr_of_ AVUs (called metadata_for_paths in the code)), and then you attempt to access the _i_-th element of the paths. \r\n```python\r\n        for i in range(len(metadata_for_paths)):\r\n            entity = self._create_entity_with_path(paths[i])\r\n```\r\nThis is obviously only going to work when you test with nr_of_avus = nr_of_paths, otherwise if there is 1 path and 3 AVUs one gets a IndexError:\r\n\r\n```python\r\n  File \"/nfs/users/nfs_i/ic4/Projects/python3/serapis/ENV/lib/python3.5/site-packages/baton/_baton/baton_metadata_mappers.py\", line 82, in remove\r\n    self._modify(paths, metadata, BATON_METAMOD_OPERATION_REMOVE)\r\n  File \"/nfs/users/nfs_i/ic4/Projects/python3/serapis/ENV/lib/python3.5/site-packages/baton/_baton/baton_metadata_mappers.py\", line 104, in _modify\r\n    entity = self._create_entity_with_path(paths[i])\r\nIndexError: list index out of range\r\n```\r\n\r\nfrom:\r\nhttps://github.com/wtsi-hgi/python-baton-wrapper/blob/master/baton/_baton/baton_metadata_mappers.py#L87-L88"},"comment":{"url":"https://api.github.com/repos/wtsi-hgi/python-baton-wrapper/issues/comments/245319882","html_url":"https://github.com/wtsi-hgi/python-baton-wrapper/issues/44#issuecomment-245319882","issue_url":"https://api.github.com/repos/wtsi-hgi/python-baton-wrapper/issues/44","id":245319882,"user":{"login":"colin-nolan","id":1138107,"avatar_url":"https://avatars.githubusercontent.com/u/1138107?v=3","gravatar_id":"","url":"https://api.github.com/users/colin-nolan","html_url":"https://github.com/colin-nolan","followers_url":"https://api.github.com/users/colin-nolan/followers","following_url":"https://api.github.com/users/colin-nolan/following{/other_user}","gists_url":"https://api.github.com/users/colin-nolan/gists{/gist_id}","starred_url":"https://api.github.com/users/colin-nolan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colin-nolan/subscriptions","organizations_url":"https://api.github.com/users/colin-nolan/orgs","repos_url":"https://api.github.com/users/colin-nolan/repos","events_url":"https://api.github.com/users/colin-nolan/events{/privacy}","received_events_url":"https://api.github.com/users/colin-nolan/received_events","type":"User","site_admin":false},"created_at":"2016-09-07T15:33:32Z","updated_at":"2016-09-07T15:33:32Z","body":"Either a single `IrodsMetadata` collection is supplied for all paths, or a separate collection is supplied for each path, i.e.:\r\n```python\r\nself.mapper.add([\"/path_1\", \"/path_2\"], metadata_for_path_1_and_2)\r\n# Or\r\nself.mapper.add([\"/path_1\", \"/path_2\"], [metadata_for_path_1, metadata_for_path_2])\r\n```\r\n\r\nIf the mapper is used correctly, the `len(paths) == len(metadata_for_paths)` assertion always passes. However, to help in case where it's not, e.g.\r\n```python\r\n# Wrong!\r\nself.mapper.add([\"/path_1\", \"/path_2\", \"/path_3\"], [metadata_for_path_1, metadata_for_path_2])\r\n```\r\nI'll add a check so that a more informative exception is raised than the `IndexError` that you pointed out. "}}
{"actor":{"display_login":"colin-nolan"}}