{"action":"created","comment":{"url":"https://api.github.com/repos/PanDAWMS/dkb/pulls/comments/153705308","pull_request_review_id":79750242,"id":153705308,"diff_hunk":"@@ -0,0 +1,123 @@\n+#!/bin/env python\n+import json\n+import re\n+import sys\n+import os\n+try:\n+    import pyAMI.client\n+    import pyAMI.atlas.api as AtlasAPI\n+    import pyAMI.config\n+except ImportError:\n+    sys.stderr.write(\"Unable to find pyAMI client.\")\n+    sys.exit(1)\n+\n+base_dir = os.path.abspath(os.path.dirname(__file__))\n+\n+try:\n+    dkb_dir = os.path.join(base_dir, os.pardir)\n+    sys.path.append(dkb_dir)\n+    import pyDKB\n+except Exception, err:\n+    sys.stderr.write(\"(ERROR) Failed to import pyDKB library: %s\\n\" % err)\n+    sys.exit(1)\n+\n+ami_client = None\n+PHYS_VALUES = [{\"ami\": \"genFiltEff\", \"es\": \"gen_filt_eff\"},\n+              {\"ami\": \"crossSection\", \"es\": \"cross_section\"},\n+              {\"ami\": \"crossSectionRef\", \"es\": \"cross_section_ref\"},\n+              {\"ami\": \"kFactor\", \"es\": \"k_factor\"}]\n+\n+def main(argv):\n+\n+    stage = pyDKB.dataflow.stage.JSONProcessorStage()\n+\n+    stage.add_argument('--userkey', help='PEM key file', required=True)\n+    stage.add_argument('--usercert', help='PEM certificate file', required=True)\n+\n+    exit_code = 0\n+    try:\n+        stage.parse_args(argv)\n+        stage.process = process\n+        init_ami_client(stage.ARGS.userkey, stage.ARGS.usercert)\n+        stage.run()\n+    except (pyDKB.dataflow.exceptions.DataflowException, RuntimeError), err:\n+        if str(err):\n+            str_err = str(err).replace(\"\\n\", \"\\n(==) \")\n+            sys.stderr.write(\"(ERROR) %s\\n\" % str_err)\n+        exit_code = 2\n+    finally:\n+        stage.stop()\n+\n+    sys.exit(exit_code)\n+\n+def init_ami_client(userkey, usercert):\n+    \"\"\"\n+    Initialisation of AMI client into the global variable\n+    :param userkey: user key pem file\n+    :param usercert: user certificate pem file\n+    :return:\n+    \"\"\"\n+    global ami_client\n+    try:\n+        ami_client = pyAMI.client.Client('atlas', key_file=userkey, cert_file=usercert)\n+        AtlasAPI.init()\n+    except:\n+        sys.stderr.write(\n+            \"Could not establish pyAMI session. Are you sure you have a valid certificate?\")\n+        sys.exit(1)\n+\n+def process(stage, message):\n+\n+    str = amiPhysValues(message.content())\n+    stage.output(pyDKB.dataflow.messages.JSONMessage(amiPhysValues(message.content())))\n+","path":"Utils/Dataflow/092_datasetInfoAMI/amiDatasets.py","position":73,"original_position":73,"commit_id":"d315fef3d67649d22334a5ae48b4a58bf0326943","original_commit_id":"32b88097a6f5e3330d14a52a029188c18ea46e32","user":{"login":"mgolosova","id":10220547,"avatar_url":"https://avatars1.githubusercontent.com/u/10220547?v=4","gravatar_id":"","url":"https://api.github.com/users/mgolosova","html_url":"https://github.com/mgolosova","followers_url":"https://api.github.com/users/mgolosova/followers","following_url":"https://api.github.com/users/mgolosova/following{/other_user}","gists_url":"https://api.github.com/users/mgolosova/gists{/gist_id}","starred_url":"https://api.github.com/users/mgolosova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgolosova/subscriptions","organizations_url":"https://api.github.com/users/mgolosova/orgs","repos_url":"https://api.github.com/users/mgolosova/repos","events_url":"https://api.github.com/users/mgolosova/events{/privacy}","received_events_url":"https://api.github.com/users/mgolosova/received_events","type":"User","site_admin":false},"body":"Two comments in a row:\r\n* `str` is a Python keyword (namely the type), so reusing it as a variable name you can invite unpredictable behaviour in the code (say, in conditions like `if type(x) is str`);\r\n* `amiPhysValues()` is called twice","created_at":"2017-11-29T06:56:42Z","updated_at":"2017-11-29T06:56:42Z","html_url":"https://github.com/PanDAWMS/dkb/pull/89#discussion_r153705308","pull_request_url":"https://api.github.com/repos/PanDAWMS/dkb/pulls/89","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/PanDAWMS/dkb/pulls/comments/153705308"},"html":{"href":"https://github.com/PanDAWMS/dkb/pull/89#discussion_r153705308"},"pull_request":{"href":"https://api.github.com/repos/PanDAWMS/dkb/pulls/89"}}},"pull_request":{"url":"https://api.github.com/repos/PanDAWMS/dkb/pulls/89","id":155093057,"html_url":"https://github.com/PanDAWMS/dkb/pull/89","diff_url":"https://github.com/PanDAWMS/dkb/pull/89.diff","patch_url":"https://github.com/PanDAWMS/dkb/pull/89.patch","issue_url":"https://api.github.com/repos/PanDAWMS/dkb/issues/89","number":89,"state":"open","locked":false,"title":"Dataflow ami2es maria","user":{"login":"maria-grigorieva","id":1815067,"avatar_url":"https://avatars1.githubusercontent.com/u/1815067?v=4","gravatar_id":"","url":"https://api.github.com/users/maria-grigorieva","html_url":"https://github.com/maria-grigorieva","followers_url":"https://api.github.com/users/maria-grigorieva/followers","following_url":"https://api.github.com/users/maria-grigorieva/following{/other_user}","gists_url":"https://api.github.com/users/maria-grigorieva/gists{/gist_id}","starred_url":"https://api.github.com/users/maria-grigorieva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maria-grigorieva/subscriptions","organizations_url":"https://api.github.com/users/maria-grigorieva/orgs","repos_url":"https://api.github.com/users/maria-grigorieva/repos","events_url":"https://api.github.com/users/maria-grigorieva/events{/privacy}","received_events_url":"https://api.github.com/users/maria-grigorieva/received_events","type":"User","site_admin":false},"body":"- Implemented the addition of AMI parameters in stage 092_datasetInfoAMI\r\n- updated ES mapping with parent-child relations between tasks and datasets","created_at":"2017-11-28T14:55:24Z","updated_at":"2017-11-29T06:56:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a77dbafd3ac38c423e4808513242325531d820c","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/PanDAWMS/dkb/pulls/89/commits","review_comments_url":"https://api.github.com/repos/PanDAWMS/dkb/pulls/89/comments","review_comment_url":"https://api.github.com/repos/PanDAWMS/dkb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PanDAWMS/dkb/issues/89/comments","statuses_url":"https://api.github.com/repos/PanDAWMS/dkb/statuses/d315fef3d67649d22334a5ae48b4a58bf0326943","head":{"label":"PanDAWMS:dataflow-ami2es-maria","ref":"dataflow-ami2es-maria","sha":"d315fef3d67649d22334a5ae48b4a58bf0326943","user":{"login":"PanDAWMS","id":6588296,"avatar_url":"https://avatars0.githubusercontent.com/u/6588296?v=4","gravatar_id":"","url":"https://api.github.com/users/PanDAWMS","html_url":"https://github.com/PanDAWMS","followers_url":"https://api.github.com/users/PanDAWMS/followers","following_url":"https://api.github.com/users/PanDAWMS/following{/other_user}","gists_url":"https://api.github.com/users/PanDAWMS/gists{/gist_id}","starred_url":"https://api.github.com/users/PanDAWMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PanDAWMS/subscriptions","organizations_url":"https://api.github.com/users/PanDAWMS/orgs","repos_url":"https://api.github.com/users/PanDAWMS/repos","events_url":"https://api.github.com/users/PanDAWMS/events{/privacy}","received_events_url":"https://api.github.com/users/PanDAWMS/received_events","type":"Organization","site_admin":false},"repo":{"id":89468107,"name":"dkb","full_name":"PanDAWMS/dkb","owner":{"login":"PanDAWMS","id":6588296,"avatar_url":"https://avatars0.githubusercontent.com/u/6588296?v=4","gravatar_id":"","url":"https://api.github.com/users/PanDAWMS","html_url":"https://github.com/PanDAWMS","followers_url":"https://api.github.com/users/PanDAWMS/followers","following_url":"https://api.github.com/users/PanDAWMS/following{/other_user}","gists_url":"https://api.github.com/users/PanDAWMS/gists{/gist_id}","starred_url":"https://api.github.com/users/PanDAWMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PanDAWMS/subscriptions","organizations_url":"https://api.github.com/users/PanDAWMS/orgs","repos_url":"https://api.github.com/users/PanDAWMS/repos","events_url":"https://api.github.com/users/PanDAWMS/events{/privacy}","received_events_url":"https://api.github.com/users/PanDAWMS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PanDAWMS/dkb","description":"Data Knowledge Base for HENP experiments","fork":false,"url":"https://api.github.com/repos/PanDAWMS/dkb","forks_url":"https://api.github.com/repos/PanDAWMS/dkb/forks","keys_url":"https://api.github.com/repos/PanDAWMS/dkb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PanDAWMS/dkb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PanDAWMS/dkb/teams","hooks_url":"https://api.github.com/repos/PanDAWMS/dkb/hooks","issue_events_url":"https://api.github.com/repos/PanDAWMS/dkb/issues/events{/number}","events_url":"https://api.github.com/repos/PanDAWMS/dkb/events","assignees_url":"https://api.github.com/repos/PanDAWMS/dkb/assignees{/user}","branches_url":"https://api.github.com/repos/PanDAWMS/dkb/branches{/branch}","tags_url":"https://api.github.com/repos/PanDAWMS/dkb/tags","blobs_url":"https://api.github.com/repos/PanDAWMS/dkb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PanDAWMS/dkb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PanDAWMS/dkb/git/refs{/sha}","trees_url":"https://api.github.com/repos/PanDAWMS/dkb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PanDAWMS/dkb/statuses/{sha}","languages_url":"https://api.github.com/repos/PanDAWMS/dkb/languages","stargazers_url":"https://api.github.com/repos/PanDAWMS/dkb/stargazers","contributors_url":"https://api.github.com/repos/PanDAWMS/dkb/contributors","subscribers_url":"https://api.github.com/repos/PanDAWMS/dkb/subscribers","subscription_url":"https://api.github.com/repos/PanDAWMS/dkb/subscription","commits_url":"https://api.github.com/repos/PanDAWMS/dkb/commits{/sha}","git_commits_url":"https://api.github.com/repos/PanDAWMS/dkb/git/commits{/sha}","comments_url":"https://api.github.com/repos/PanDAWMS/dkb/comments{/number}","issue_comment_url":"https://api.github.com/repos/PanDAWMS/dkb/issues/comments{/number}","contents_url":"https://api.github.com/repos/PanDAWMS/dkb/contents/{+path}","compare_url":"https://api.github.com/repos/PanDAWMS/dkb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PanDAWMS/dkb/merges","archive_url":"https://api.github.com/repos/PanDAWMS/dkb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PanDAWMS/dkb/downloads","issues_url":"https://api.github.com/repos/PanDAWMS/dkb/issues{/number}","pulls_url":"https://api.github.com/repos/PanDAWMS/dkb/pulls{/number}","milestones_url":"https://api.github.com/repos/PanDAWMS/dkb/milestones{/number}","notifications_url":"https://api.github.com/repos/PanDAWMS/dkb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PanDAWMS/dkb/labels{/name}","releases_url":"https://api.github.com/repos/PanDAWMS/dkb/releases{/id}","deployments_url":"https://api.github.com/repos/PanDAWMS/dkb/deployments","created_at":"2017-04-26T10:22:17Z","updated_at":"2017-05-26T11:13:20Z","pushed_at":"2017-11-28T14:55:25Z","git_url":"git://github.com/PanDAWMS/dkb.git","ssh_url":"git@github.com:PanDAWMS/dkb.git","clone_url":"https://github.com/PanDAWMS/dkb.git","svn_url":"https://github.com/PanDAWMS/dkb","homepage":"","size":36675,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":23,"license":null,"forks":3,"open_issues":23,"watchers":0,"default_branch":"master"}},"base":{"label":"PanDAWMS:dataflow-ami2es","ref":"dataflow-ami2es","sha":"ebd458276ee28b3dd425704a125d67ebd84165d8","user":{"login":"PanDAWMS","id":6588296,"avatar_url":"https://avatars0.githubusercontent.com/u/6588296?v=4","gravatar_id":"","url":"https://api.github.com/users/PanDAWMS","html_url":"https://github.com/PanDAWMS","followers_url":"https://api.github.com/users/PanDAWMS/followers","following_url":"https://api.github.com/users/PanDAWMS/following{/other_user}","gists_url":"https://api.github.com/users/PanDAWMS/gists{/gist_id}","starred_url":"https://api.github.com/users/PanDAWMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PanDAWMS/subscriptions","organizations_url":"https://api.github.com/users/PanDAWMS/orgs","repos_url":"https://api.github.com/users/PanDAWMS/repos","events_url":"https://api.github.com/users/PanDAWMS/events{/privacy}","received_events_url":"https://api.github.com/users/PanDAWMS/received_events","type":"Organization","site_admin":false},"repo":{"id":89468107,"name":"dkb","full_name":"PanDAWMS/dkb","owner":{"login":"PanDAWMS","id":6588296,"avatar_url":"https://avatars0.githubusercontent.com/u/6588296?v=4","gravatar_id":"","url":"https://api.github.com/users/PanDAWMS","html_url":"https://github.com/PanDAWMS","followers_url":"https://api.github.com/users/PanDAWMS/followers","following_url":"https://api.github.com/users/PanDAWMS/following{/other_user}","gists_url":"https://api.github.com/users/PanDAWMS/gists{/gist_id}","starred_url":"https://api.github.com/users/PanDAWMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PanDAWMS/subscriptions","organizations_url":"https://api.github.com/users/PanDAWMS/orgs","repos_url":"https://api.github.com/users/PanDAWMS/repos","events_url":"https://api.github.com/users/PanDAWMS/events{/privacy}","received_events_url":"https://api.github.com/users/PanDAWMS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PanDAWMS/dkb","description":"Data Knowledge Base for HENP experiments","fork":false,"url":"https://api.github.com/repos/PanDAWMS/dkb","forks_url":"https://api.github.com/repos/PanDAWMS/dkb/forks","keys_url":"https://api.github.com/repos/PanDAWMS/dkb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PanDAWMS/dkb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PanDAWMS/dkb/teams","hooks_url":"https://api.github.com/repos/PanDAWMS/dkb/hooks","issue_events_url":"https://api.github.com/repos/PanDAWMS/dkb/issues/events{/number}","events_url":"https://api.github.com/repos/PanDAWMS/dkb/events","assignees_url":"https://api.github.com/repos/PanDAWMS/dkb/assignees{/user}","branches_url":"https://api.github.com/repos/PanDAWMS/dkb/branches{/branch}","tags_url":"https://api.github.com/repos/PanDAWMS/dkb/tags","blobs_url":"https://api.github.com/repos/PanDAWMS/dkb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PanDAWMS/dkb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PanDAWMS/dkb/git/refs{/sha}","trees_url":"https://api.github.com/repos/PanDAWMS/dkb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PanDAWMS/dkb/statuses/{sha}","languages_url":"https://api.github.com/repos/PanDAWMS/dkb/languages","stargazers_url":"https://api.github.com/repos/PanDAWMS/dkb/stargazers","contributors_url":"https://api.github.com/repos/PanDAWMS/dkb/contributors","subscribers_url":"https://api.github.com/repos/PanDAWMS/dkb/subscribers","subscription_url":"https://api.github.com/repos/PanDAWMS/dkb/subscription","commits_url":"https://api.github.com/repos/PanDAWMS/dkb/commits{/sha}","git_commits_url":"https://api.github.com/repos/PanDAWMS/dkb/git/commits{/sha}","comments_url":"https://api.github.com/repos/PanDAWMS/dkb/comments{/number}","issue_comment_url":"https://api.github.com/repos/PanDAWMS/dkb/issues/comments{/number}","contents_url":"https://api.github.com/repos/PanDAWMS/dkb/contents/{+path}","compare_url":"https://api.github.com/repos/PanDAWMS/dkb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PanDAWMS/dkb/merges","archive_url":"https://api.github.com/repos/PanDAWMS/dkb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PanDAWMS/dkb/downloads","issues_url":"https://api.github.com/repos/PanDAWMS/dkb/issues{/number}","pulls_url":"https://api.github.com/repos/PanDAWMS/dkb/pulls{/number}","milestones_url":"https://api.github.com/repos/PanDAWMS/dkb/milestones{/number}","notifications_url":"https://api.github.com/repos/PanDAWMS/dkb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PanDAWMS/dkb/labels{/name}","releases_url":"https://api.github.com/repos/PanDAWMS/dkb/releases{/id}","deployments_url":"https://api.github.com/repos/PanDAWMS/dkb/deployments","created_at":"2017-04-26T10:22:17Z","updated_at":"2017-05-26T11:13:20Z","pushed_at":"2017-11-28T14:55:25Z","git_url":"git://github.com/PanDAWMS/dkb.git","ssh_url":"git@github.com:PanDAWMS/dkb.git","clone_url":"https://github.com/PanDAWMS/dkb.git","svn_url":"https://github.com/PanDAWMS/dkb","homepage":"","size":36675,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":23,"license":null,"forks":3,"open_issues":23,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PanDAWMS/dkb/pulls/89"},"html":{"href":"https://github.com/PanDAWMS/dkb/pull/89"},"issue":{"href":"https://api.github.com/repos/PanDAWMS/dkb/issues/89"},"comments":{"href":"https://api.github.com/repos/PanDAWMS/dkb/issues/89/comments"},"review_comments":{"href":"https://api.github.com/repos/PanDAWMS/dkb/pulls/89/comments"},"review_comment":{"href":"https://api.github.com/repos/PanDAWMS/dkb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PanDAWMS/dkb/pulls/89/commits"},"statuses":{"href":"https://api.github.com/repos/PanDAWMS/dkb/statuses/d315fef3d67649d22334a5ae48b4a58bf0326943"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"mgolosova"}}