Title: Fetch with as_dict=True raises a confusing error when the attribute list is specified. · Issue #391 · datajoint/datajoint-python · GitHub
Open Graph Title: Fetch with as_dict=True raises a confusing error when the attribute list is specified. · Issue #391 · datajoint/datajoint-python
X Title: Fetch with as_dict=True raises a confusing error when the attribute list is specified. · Issue #391 · datajoint/datajoint-python
Description: When using fetch(1), as_dict works only in certain cases. Some examples: In [73]: reso.schema.jobs Out[73]: *table_name *key_hash status error_message user host pid connection_id timestamp key error_stack +------------+ +------------+ +-...
Open Graph Description: When using fetch(1), as_dict works only in certain cases. Some examples: In [73]: reso.schema.jobs Out[73]: *table_name *key_hash status error_message user host pid connection_id timestamp key erro...
X Description: When using fetch(1), as_dict works only in certain cases. Some examples: In [73]: reso.schema.jobs Out[73]: *table_name *key_hash status error_message user host pid connection_id timestamp key erro...
Opengraph URL: https://github.com/datajoint/datajoint-python/issues/391
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fetch with as_dict=True raises a confusing error when the attribute list is specified.","articleBody":"When using fetch(1), as_dict works only in certain cases. Some examples:\r\n\r\n```\r\nIn [73]: reso.schema.jobs\r\nOut[73]: \r\n*table_name *key_hash status error_message user host pid connection_id timestamp key error_stack \r\n+------------+ +------------+ +----------+ +------------+ +------------+ +------------+ +------+ +------------+ +------------+ +--------+ +------------+\r\n__segmentation 30fff7922ea185 reserved ecobost@10.28. d6f4e9bc8ab8 2482 1221199 2017-11-13 21: \u003cBLOB\u003e \u003cBLOB\u003e \r\n (1 tuples)\r\n\r\nIn [74]: reso.schema.jobs.fetch1(as_dict=True)\r\nOut[74]: \r\nOrderedDict([('table_name', '__segmentation'),\r\n ('key_hash', '30fff7922ea18543ea1f298418673640'),\r\n ('status', 'reserved'),\r\n ('key', rec.array([(1, 1, 1, 3, 3, 10577, 1)], \r\n dtype=[('scan_idx', 'O'), ('channel', 'O'), ('session', 'O'), ('segmentation_method', 'O'), ('field', 'O'), ('animal_id', 'O'), ('pipe_version', 'O')])),\r\n ('error_message', ''),\r\n ('error_stack', None),\r\n ('user', 'ecobost@10.28.2.115'),\r\n ('host', 'd6f4e9bc8ab8'),\r\n ('pid', 2482),\r\n ('connection_id', 1221199),\r\n ('timestamp', datetime.datetime(2017, 11, 13, 21, 51, 5))])\r\n\r\nIn [75]: reso.schema.jobs.fetch1('status', 'pid')\r\nOut[75]: ('reserved', 2482)\r\n\r\nIn [76]: reso.schema.jobs.fetch1('status', 'pid', as_dict=True) # does not return a dict\r\nOut[76]: ('reserved', 2482)\r\n\r\nIn [77]: type(_)\r\nOut[77]: tuple\r\n```\r\n\r\nAnd with fetch, it just fails\r\n```\r\nIn [86]: reso.schema.jobs.fetch('status', 'pid')\r\nOut[86]: [array(['reserved'], dtype=object), array([2482])]\r\n\r\nIn [88]: reso.schema.jobs.fetch('status', 'pid', as_dict=True)\r\n---------------------------------------------------------------------------\r\nTypeError Traceback (most recent call last)\r\n\u003cipython-input-79-e0ee9a14edc6\u003e in \u003cmodule\u003e()\r\n----\u003e 1 reso.schema.jobs.fetch('status', 'pid', as_dict=True)\r\n\r\n/usr/local/lib/python3.5/dist-packages/datajoint/fetch.py in __call__(self, *attrs, **kwargs)\r\n 208 list(to_dicts(result[self._relation.primary_key]))\r\n 209 if attribute is PRIMARY_KEY else result[attribute]\r\n--\u003e 210 for attribute in attrs]\r\n 211 ret = return_values[0] if len(attrs) == 1 else return_values\r\n 212 \r\n\r\n/usr/local/lib/python3.5/dist-packages/datajoint/fetch.py in \u003clistcomp\u003e(.0)\r\n 208 list(to_dicts(result[self._relation.primary_key]))\r\n 209 if attribute is PRIMARY_KEY else result[attribute]\r\n--\u003e 210 for attribute in attrs]\r\n 211 ret = return_values[0] if len(attrs) == 1 else return_values\r\n 212 \r\n\r\nTypeError: list indices must be integers or slices, not str\r\n```","author":{"url":"https://github.com/ecobost","@type":"Person","name":"ecobost"},"datePublished":"2017-11-14T04:42:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/391/datajoint-python/issues/391"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c58d22c5-968e-97aa-35a0-5cda64e9074e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84D6:3D3A2:9F5678:D735CB:6A4D7141 |
| html-safe-nonce | 20f0c0ada10d78bff1013d905598c8e84aec9528a79ec566996e3441c35b02eb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEQ2OjNEM0EyOjlGNTY3ODpENzM1Q0I6NkE0RDcxNDEiLCJ2aXNpdG9yX2lkIjoiMTIyOTY2MzQ0OTQ1OTI5MDQzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | eac4f38c86f5904bbc85096a2dcf5dd43d125a3588f1eb0ad2be913ac19cfb6f |
| hovercard-subject-tag | issue:273665914 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/datajoint/datajoint-python/391/issue_layout |
| twitter:image | https://opengraph.githubassets.com/50a70fb0384d935decaca29fe88b0f2336ac7c539c4740ce13bf3f81c1266621/datajoint/datajoint-python/issues/391 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/50a70fb0384d935decaca29fe88b0f2336ac7c539c4740ce13bf3f81c1266621/datajoint/datajoint-python/issues/391 |
| og:image:alt | When using fetch(1), as_dict works only in certain cases. Some examples: In [73]: reso.schema.jobs Out[73]: *table_name *key_hash status error_message user host pid connection_id timestamp key erro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ecobost |
| hostname | github.com |
| expected-hostname | github.com |
| None | c78260c7b3f4ac4b0356c8208537f05406a3a2d46a9ec3f735b372dcc519c39e |
| turbo-cache-control | no-preview |
| go-import | github.com/datajoint/datajoint-python git https://github.com/datajoint/datajoint-python.git |
| octolytics-dimension-user_id | 2375501 |
| octolytics-dimension-user_login | datajoint |
| octolytics-dimension-repository_id | 5866704 |
| octolytics-dimension-repository_nwo | datajoint/datajoint-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 5866704 |
| octolytics-dimension-repository_network_root_nwo | datajoint/datajoint-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 399fff412f48461d435721c009efc17ea44be72f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width