{"action":"created","comment":{"url":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/comments/38428393","id":38428393,"diff_hunk":"@@ -345,34 +468,69 @@ def insert_event(descriptor, time, seq_num, data, timestamps=None, uid=None):\n     (not stored, but exchanged) timestamps is optional. If not included,\n     data is expected to include (value, timestamp) tuples.\n     \"\"\"\n-    if timestamps is not None and set(data.keys()) != set(timestamps.keys()):\n-        raise ValueError(\"The fields in 'data' and 'timestamps' must match.\")\n-    if timestamps is not None:\n-        # new Document exchange format\n-        val_ts_tuple = _transform_data(data, timestamps)\n-    else:\n-        # old Document exchange format\n-        val_ts_tuple = data\n+    val_ts_tuple = _transform_data(data, timestamps)\n \n     # Allow caller to beg forgiveness rather than ask permission w.r.t\n     # EventDescriptor creation.\n     if descriptor is None:\n         raise EventDescriptorIsNoneError()\n-\n-    if uid is None:\n-        uid = str(uuid.uuid4())\n-\n-    descriptor = _get_mongo_document(descriptor, EventDescriptor)\n-    event = Event(descriptor_id=descriptor, uid=uid,\n+    descriptor = event_desc_given_uid(descriptor)\n+    desc_oid = _EVENTDESC_UID_to_OID_MAP[descriptor['uid']]\n+    event = Event(descriptor_id=desc_oid, uid=uid,\n                   data=val_ts_tuple, time=time, seq_num=seq_num)\n \n-    event = _replace_event_data_key_dots(event, direction='in')\n     event.save(validate=True, write_concern={\"w\": 1})\n+\n     logger.debug(\"Inserted Event with uid %s referencing \"\n                  \"EventDescriptor with uid %s\", event.uid,\n                  descriptor.uid)\n     return uid\n \n+BAD_KEYS_FMT = \"\"\"Event documents are malformed, the keys on 'data' and\n+'timestamps do not match:\\n data: {}\\ntimestamps:{}\"\"\"\n+\n+\n+@_ensure_connection\n+def bulk_insert_events(event_descriptor, events, validate=False):\n+    \"\"\"Bulk insert many events\n+\n+    Parameters\n+    ----------\n+    event_descriptor : str\n+        The event descriptor uid that these events are associated with\n+\n+    events : iterable\n+       iterable of dicts matching the bs.Event schema\n+\n+    \"\"\"\n+\n+    descriptor = event_desc_given_uid(event_descriptor)","path":"metadatastore/commands.py","position":517,"original_position":517,"commit_id":"f3653e4604d542578bd5b79b4703b0772ea666f8","original_commit_id":"f3653e4604d542578bd5b79b4703b0772ea666f8","user":{"login":"arkilic","id":5132155,"avatar_url":"https://avatars.githubusercontent.com/u/5132155?v=3","gravatar_id":"","url":"https://api.github.com/users/arkilic","html_url":"https://github.com/arkilic","followers_url":"https://api.github.com/users/arkilic/followers","following_url":"https://api.github.com/users/arkilic/following{/other_user}","gists_url":"https://api.github.com/users/arkilic/gists{/gist_id}","starred_url":"https://api.github.com/users/arkilic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arkilic/subscriptions","organizations_url":"https://api.github.com/users/arkilic/orgs","repos_url":"https://api.github.com/users/arkilic/repos","events_url":"https://api.github.com/users/arkilic/events{/privacy}","received_events_url":"https://api.github.com/users/arkilic/received_events","type":"User","site_admin":false},"body":"Yes, apparently, they recently changed the behavior. Unless document returned is a few MB(which is never the case for us), this shld make no difference. Thx for giving it a shot!","created_at":"2015-09-01T14:56:11Z","updated_at":"2015-09-01T14:56:11Z","html_url":"https://github.com/NSLS-II/metadatastore/pull/167#discussion_r38428393","pull_request_url":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/167","_links":{"self":{"href":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/comments/38428393"},"html":{"href":"https://github.com/NSLS-II/metadatastore/pull/167#discussion_r38428393"},"pull_request":{"href":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/167"}}},"pull_request":{"url":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/167","id":43823479,"html_url":"https://github.com/NSLS-II/metadatastore/pull/167","diff_url":"https://github.com/NSLS-II/metadatastore/pull/167.diff","patch_url":"https://github.com/NSLS-II/metadatastore/pull/167.patch","issue_url":"https://api.github.com/repos/NSLS-II/metadatastore/issues/167","number":167,"state":"open","locked":false,"title":"WIP: Prf bulk entry","user":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars.githubusercontent.com/u/199813?v=3","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"body":"more violence to come","created_at":"2015-08-31T23:47:11Z","updated_at":"2015-09-01T14:56:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"af7a37ec4e310be4fcafb4cd8e248b68850ffcbc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/167/commits","review_comments_url":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/167/comments","review_comment_url":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NSLS-II/metadatastore/issues/167/comments","statuses_url":"https://api.github.com/repos/NSLS-II/metadatastore/statuses/f3653e4604d542578bd5b79b4703b0772ea666f8","head":{"label":"tacaswell:prf_bulk_entry","ref":"prf_bulk_entry","sha":"f3653e4604d542578bd5b79b4703b0772ea666f8","user":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars.githubusercontent.com/u/199813?v=3","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"repo":{"id":22179373,"name":"metadataStore","full_name":"tacaswell/metadataStore","owner":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars.githubusercontent.com/u/199813?v=3","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tacaswell/metadataStore","description":"NSLS2 Beamlines MetadataStore implemented in MongoDB","fork":true,"url":"https://api.github.com/repos/tacaswell/metadataStore","forks_url":"https://api.github.com/repos/tacaswell/metadataStore/forks","keys_url":"https://api.github.com/repos/tacaswell/metadataStore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tacaswell/metadataStore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tacaswell/metadataStore/teams","hooks_url":"https://api.github.com/repos/tacaswell/metadataStore/hooks","issue_events_url":"https://api.github.com/repos/tacaswell/metadataStore/issues/events{/number}","events_url":"https://api.github.com/repos/tacaswell/metadataStore/events","assignees_url":"https://api.github.com/repos/tacaswell/metadataStore/assignees{/user}","branches_url":"https://api.github.com/repos/tacaswell/metadataStore/branches{/branch}","tags_url":"https://api.github.com/repos/tacaswell/metadataStore/tags","blobs_url":"https://api.github.com/repos/tacaswell/metadataStore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tacaswell/metadataStore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tacaswell/metadataStore/git/refs{/sha}","trees_url":"https://api.github.com/repos/tacaswell/metadataStore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tacaswell/metadataStore/statuses/{sha}","languages_url":"https://api.github.com/repos/tacaswell/metadataStore/languages","stargazers_url":"https://api.github.com/repos/tacaswell/metadataStore/stargazers","contributors_url":"https://api.github.com/repos/tacaswell/metadataStore/contributors","subscribers_url":"https://api.github.com/repos/tacaswell/metadataStore/subscribers","subscription_url":"https://api.github.com/repos/tacaswell/metadataStore/subscription","commits_url":"https://api.github.com/repos/tacaswell/metadataStore/commits{/sha}","git_commits_url":"https://api.github.com/repos/tacaswell/metadataStore/git/commits{/sha}","comments_url":"https://api.github.com/repos/tacaswell/metadataStore/comments{/number}","issue_comment_url":"https://api.github.com/repos/tacaswell/metadataStore/issues/comments{/number}","contents_url":"https://api.github.com/repos/tacaswell/metadataStore/contents/{+path}","compare_url":"https://api.github.com/repos/tacaswell/metadataStore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tacaswell/metadataStore/merges","archive_url":"https://api.github.com/repos/tacaswell/metadataStore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tacaswell/metadataStore/downloads","issues_url":"https://api.github.com/repos/tacaswell/metadataStore/issues{/number}","pulls_url":"https://api.github.com/repos/tacaswell/metadataStore/pulls{/number}","milestones_url":"https://api.github.com/repos/tacaswell/metadataStore/milestones{/number}","notifications_url":"https://api.github.com/repos/tacaswell/metadataStore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tacaswell/metadataStore/labels{/name}","releases_url":"https://api.github.com/repos/tacaswell/metadataStore/releases{/id}","created_at":"2014-07-23T21:36:27Z","updated_at":"2015-04-06T20:45:11Z","pushed_at":"2015-09-01T03:55:09Z","git_url":"git://github.com/tacaswell/metadataStore.git","ssh_url":"git@github.com:tacaswell/metadataStore.git","clone_url":"https://github.com/tacaswell/metadataStore.git","svn_url":"https://github.com/tacaswell/metadataStore","homepage":"","size":653,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"NSLS-II:master","ref":"master","sha":"ab34a2db4c1276cd4f6d0b16af2af8a7a7c3a9ce","user":{"login":"NSLS-II","id":8700262,"avatar_url":"https://avatars.githubusercontent.com/u/8700262?v=3","gravatar_id":"","url":"https://api.github.com/users/NSLS-II","html_url":"https://github.com/NSLS-II","followers_url":"https://api.github.com/users/NSLS-II/followers","following_url":"https://api.github.com/users/NSLS-II/following{/other_user}","gists_url":"https://api.github.com/users/NSLS-II/gists{/gist_id}","starred_url":"https://api.github.com/users/NSLS-II/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NSLS-II/subscriptions","organizations_url":"https://api.github.com/users/NSLS-II/orgs","repos_url":"https://api.github.com/users/NSLS-II/repos","events_url":"https://api.github.com/users/NSLS-II/events{/privacy}","received_events_url":"https://api.github.com/users/NSLS-II/received_events","type":"Organization","site_admin":false},"repo":{"id":20021829,"name":"metadatastore","full_name":"NSLS-II/metadatastore","owner":{"login":"NSLS-II","id":8700262,"avatar_url":"https://avatars.githubusercontent.com/u/8700262?v=3","gravatar_id":"","url":"https://api.github.com/users/NSLS-II","html_url":"https://github.com/NSLS-II","followers_url":"https://api.github.com/users/NSLS-II/followers","following_url":"https://api.github.com/users/NSLS-II/following{/other_user}","gists_url":"https://api.github.com/users/NSLS-II/gists{/gist_id}","starred_url":"https://api.github.com/users/NSLS-II/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NSLS-II/subscriptions","organizations_url":"https://api.github.com/users/NSLS-II/orgs","repos_url":"https://api.github.com/users/NSLS-II/repos","events_url":"https://api.github.com/users/NSLS-II/events{/privacy}","received_events_url":"https://api.github.com/users/NSLS-II/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NSLS-II/metadatastore","description":"NSLS2 Beamlines MetadataStore prototype implemented in MongoDB","fork":false,"url":"https://api.github.com/repos/NSLS-II/metadatastore","forks_url":"https://api.github.com/repos/NSLS-II/metadatastore/forks","keys_url":"https://api.github.com/repos/NSLS-II/metadatastore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NSLS-II/metadatastore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NSLS-II/metadatastore/teams","hooks_url":"https://api.github.com/repos/NSLS-II/metadatastore/hooks","issue_events_url":"https://api.github.com/repos/NSLS-II/metadatastore/issues/events{/number}","events_url":"https://api.github.com/repos/NSLS-II/metadatastore/events","assignees_url":"https://api.github.com/repos/NSLS-II/metadatastore/assignees{/user}","branches_url":"https://api.github.com/repos/NSLS-II/metadatastore/branches{/branch}","tags_url":"https://api.github.com/repos/NSLS-II/metadatastore/tags","blobs_url":"https://api.github.com/repos/NSLS-II/metadatastore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NSLS-II/metadatastore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NSLS-II/metadatastore/git/refs{/sha}","trees_url":"https://api.github.com/repos/NSLS-II/metadatastore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NSLS-II/metadatastore/statuses/{sha}","languages_url":"https://api.github.com/repos/NSLS-II/metadatastore/languages","stargazers_url":"https://api.github.com/repos/NSLS-II/metadatastore/stargazers","contributors_url":"https://api.github.com/repos/NSLS-II/metadatastore/contributors","subscribers_url":"https://api.github.com/repos/NSLS-II/metadatastore/subscribers","subscription_url":"https://api.github.com/repos/NSLS-II/metadatastore/subscription","commits_url":"https://api.github.com/repos/NSLS-II/metadatastore/commits{/sha}","git_commits_url":"https://api.github.com/repos/NSLS-II/metadatastore/git/commits{/sha}","comments_url":"https://api.github.com/repos/NSLS-II/metadatastore/comments{/number}","issue_comment_url":"https://api.github.com/repos/NSLS-II/metadatastore/issues/comments{/number}","contents_url":"https://api.github.com/repos/NSLS-II/metadatastore/contents/{+path}","compare_url":"https://api.github.com/repos/NSLS-II/metadatastore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NSLS-II/metadatastore/merges","archive_url":"https://api.github.com/repos/NSLS-II/metadatastore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NSLS-II/metadatastore/downloads","issues_url":"https://api.github.com/repos/NSLS-II/metadatastore/issues{/number}","pulls_url":"https://api.github.com/repos/NSLS-II/metadatastore/pulls{/number}","milestones_url":"https://api.github.com/repos/NSLS-II/metadatastore/milestones{/number}","notifications_url":"https://api.github.com/repos/NSLS-II/metadatastore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NSLS-II/metadatastore/labels{/name}","releases_url":"https://api.github.com/repos/NSLS-II/metadatastore/releases{/id}","created_at":"2014-05-21T13:17:44Z","updated_at":"2015-05-20T20:47:43Z","pushed_at":"2015-09-01T03:55:09Z","git_url":"git://github.com/NSLS-II/metadatastore.git","ssh_url":"git@github.com:NSLS-II/metadatastore.git","clone_url":"https://github.com/NSLS-II/metadatastore.git","svn_url":"https://github.com/NSLS-II/metadatastore","homepage":"","size":2832,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":11,"forks":9,"open_issues":11,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/167"},"html":{"href":"https://github.com/NSLS-II/metadatastore/pull/167"},"issue":{"href":"https://api.github.com/repos/NSLS-II/metadatastore/issues/167"},"comments":{"href":"https://api.github.com/repos/NSLS-II/metadatastore/issues/167/comments"},"review_comments":{"href":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/167/comments"},"review_comment":{"href":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NSLS-II/metadatastore/pulls/167/commits"},"statuses":{"href":"https://api.github.com/repos/NSLS-II/metadatastore/statuses/f3653e4604d542578bd5b79b4703b0772ea666f8"}}}}