{"action":"created","comment":{"url":"https://api.github.com/repos/Kitware/HPCCloud/pulls/comments/72517093","id":72517093,"diff_hunk":"@@ -0,0 +1,290 @@\n+#!/usr/bin/env python\n+# -*- coding: utf-8 -*-\n+\n+###############################################################################\n+#  Copyright 2016 Kitware Inc.\n+#\n+#  Licensed under the Apache License, Version 2.0 ( the \"License\" );\n+#  you may not use this file except in compliance with the License.\n+#  You may obtain a copy of the License at\n+#\n+#    http://www.apache.org/licenses/LICENSE-2.0\n+#\n+#  Unless required by applicable law or agreed to in writing, software\n+#  distributed under the License is distributed on an \"AS IS\" BASIS,\n+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+#  See the License for the specific language governing permissions and\n+#  limitations under the License.\n+###############################################################################\n+import tempfile\n+import json\n+import os\n+import subprocess\n+import shutil\n+from ConfigParser import SafeConfigParser\n+from jsonpath_rw import parse\n+from bson.objectid import ObjectId\n+\n+import cumulus.taskflow\n+from cumulus.tasks.job import download_job_input_folders, submit_job\n+from cumulus.tasks.job import monitor_job, monitor_jobs\n+from cumulus.tasks.job import upload_job_output_to_folder\n+from cumulus.tasks.job import terminate_job\n+from cumulus.transport.files.download import download_path_from_cluster\n+from girder.utility.model_importer import ModelImporter\n+from girder.api.rest import getCurrentUser\n+from girder.constants import AccessType\n+from girder_client import GirderClient, HttpError\n+\n+from hpccloud.taskflow.utility import *\n+\n+class NwChemTaskFlow(cumulus.taskflow.TaskFlow):\n+    \"\"\"\n+    {\n+        \"input\": {\n+            \"folder\": {\n+                \"id\": <the id of the folder containing input files>\n+            },\n+            \"geometry\": {\n+                \"id\": <the file id of the geometry file>\n+            }\n+        },\n+        \"output\": {\n+            \"folder\": {\n+                \"id\": <id of folder to upload output into>\n+            }\n+        },\n+        \"cluster\": {\n+            \"_id\": <id of cluster to run on>\n+        }\n+    }\n+    \"\"\"\n+    NWCHEM_IMAGE = {\n+        'name': 'NWChem_ParaView-5.0.1',\n+        'owner': '695977956746'\n+    }\n+\n+    def start(self, *args, **kwargs):\n+        user = getCurrentUser()\n+        # Load the cluster\n+        # TODO: should this be in a common class?\n+        cluster_id = parse('cluster._id').find(kwargs)\n+        if cluster_id:\n+            cluster_id = cluster_id[0].value\n+            model = ModelImporter.model('cluster', 'cumulus')\n+            cluster = model.load(cluster_id, user=user, level=AccessType.ADMIN)\n+            cluster = model.filter(cluster, user, passphrase=False)\n+            kwargs['cluster'] = cluster\n+\n+        profile_id = parse('cluster.profileId').find(kwargs)\n+        if profile_id:\n+            profile_id = profile_id[0].value\n+            model = ModelImporter.model('aws', 'cumulus')\n+            profile = model.load(profile_id, user=user, level=AccessType.ADMIN)\n+            kwargs['profile'] = profile\n+\n+        kwargs['image_spec'] = self.NWCHEM_IMAGE\n+        kwargs['next'] = setup_input.s()\n+\n+        super(NwChemTaskFlow, self).start(\n+            setup_cluster.s(\n+                self, *args, **kwargs))\n+\n+    def terminate(self):\n+        self.run_task(nwchem_terminate.s())\n+\n+    def delete(self):\n+        for job in self.get('meta', {}).get('jobs', []):\n+            job_id = job['_id']\n+            client = _create_girder_client(\n+            self.girder_api_url, self.girder_token)\n+            client.delete('jobs/%s' % job_id)\n+\n+            try:\n+                client.get('jobs/%s' % job_id)\n+            except HttpError as e:\n+                if e.status != 404:\n+                    self.logger.error('Unable to delete job: %s' % job_id)\n+\n+\n+# TODO: move to common class\n+def _create_girder_client(girder_api_url, girder_token):","path":"server/taskflows/hpccloud/taskflow/nwchem.py","position":111,"original_position":111,"commit_id":"9c0645727a760a12161c36e741fbe83e12547df6","original_commit_id":"9c0645727a760a12161c36e741fbe83e12547df6","user":{"login":"cjh1","id":1031053,"avatar_url":"https://avatars.githubusercontent.com/u/1031053?v=3","gravatar_id":"","url":"https://api.github.com/users/cjh1","html_url":"https://github.com/cjh1","followers_url":"https://api.github.com/users/cjh1/followers","following_url":"https://api.github.com/users/cjh1/following{/other_user}","gists_url":"https://api.github.com/users/cjh1/gists{/gist_id}","starred_url":"https://api.github.com/users/cjh1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjh1/subscriptions","organizations_url":"https://api.github.com/users/cjh1/orgs","repos_url":"https://api.github.com/users/cjh1/repos","events_url":"https://api.github.com/users/cjh1/events{/privacy}","received_events_url":"https://api.github.com/users/cjh1/received_events","type":"User","site_admin":false},"body":"We already have this function [here](https://github.com/Kitware/HPCCloud/blob/master/server/taskflows/hpccloud/taskflow/utility/__init__.py#L42-L46)","created_at":"2016-07-27T20:30:33Z","updated_at":"2016-07-27T20:30:33Z","html_url":"https://github.com/Kitware/HPCCloud/pull/456#discussion_r72517093","pull_request_url":"https://api.github.com/repos/Kitware/HPCCloud/pulls/456","_links":{"self":{"href":"https://api.github.com/repos/Kitware/HPCCloud/pulls/comments/72517093"},"html":{"href":"https://github.com/Kitware/HPCCloud/pull/456#discussion_r72517093"},"pull_request":{"href":"https://api.github.com/repos/Kitware/HPCCloud/pulls/456"}}},"pull_request":{"url":"https://api.github.com/repos/Kitware/HPCCloud/pulls/456","id":79091345,"html_url":"https://github.com/Kitware/HPCCloud/pull/456","diff_url":"https://github.com/Kitware/HPCCloud/pull/456.diff","patch_url":"https://github.com/Kitware/HPCCloud/pull/456.patch","issue_url":"https://api.github.com/repos/Kitware/HPCCloud/issues/456","number":456,"state":"open","locked":false,"title":"[WIP] NWChem taskflow","user":{"login":"chetnieter","id":4336975,"avatar_url":"https://avatars.githubusercontent.com/u/4336975?v=3","gravatar_id":"","url":"https://api.github.com/users/chetnieter","html_url":"https://github.com/chetnieter","followers_url":"https://api.github.com/users/chetnieter/followers","following_url":"https://api.github.com/users/chetnieter/following{/other_user}","gists_url":"https://api.github.com/users/chetnieter/gists{/gist_id}","starred_url":"https://api.github.com/users/chetnieter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chetnieter/subscriptions","organizations_url":"https://api.github.com/users/chetnieter/orgs","repos_url":"https://api.github.com/users/chetnieter/repos","events_url":"https://api.github.com/users/chetnieter/events{/privacy}","received_events_url":"https://api.github.com/users/chetnieter/received_events","type":"User","site_admin":false},"body":"New taskflow for running NWChem simulations. ","created_at":"2016-07-27T20:24:17Z","updated_at":"2016-07-27T20:30:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"53c7bb5554b66f589566554b8f67dda832cbd919","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Kitware/HPCCloud/pulls/456/commits","review_comments_url":"https://api.github.com/repos/Kitware/HPCCloud/pulls/456/comments","review_comment_url":"https://api.github.com/repos/Kitware/HPCCloud/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Kitware/HPCCloud/issues/456/comments","statuses_url":"https://api.github.com/repos/Kitware/HPCCloud/statuses/9c0645727a760a12161c36e741fbe83e12547df6","head":{"label":"Kitware:nwchem-taskflow","ref":"nwchem-taskflow","sha":"9c0645727a760a12161c36e741fbe83e12547df6","user":{"login":"Kitware","id":87549,"avatar_url":"https://avatars.githubusercontent.com/u/87549?v=3","gravatar_id":"","url":"https://api.github.com/users/Kitware","html_url":"https://github.com/Kitware","followers_url":"https://api.github.com/users/Kitware/followers","following_url":"https://api.github.com/users/Kitware/following{/other_user}","gists_url":"https://api.github.com/users/Kitware/gists{/gist_id}","starred_url":"https://api.github.com/users/Kitware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kitware/subscriptions","organizations_url":"https://api.github.com/users/Kitware/orgs","repos_url":"https://api.github.com/users/Kitware/repos","events_url":"https://api.github.com/users/Kitware/events{/privacy}","received_events_url":"https://api.github.com/users/Kitware/received_events","type":"Organization","site_admin":false},"repo":{"id":40924266,"name":"HPCCloud","full_name":"Kitware/HPCCloud","owner":{"login":"Kitware","id":87549,"avatar_url":"https://avatars.githubusercontent.com/u/87549?v=3","gravatar_id":"","url":"https://api.github.com/users/Kitware","html_url":"https://github.com/Kitware","followers_url":"https://api.github.com/users/Kitware/followers","following_url":"https://api.github.com/users/Kitware/following{/other_user}","gists_url":"https://api.github.com/users/Kitware/gists{/gist_id}","starred_url":"https://api.github.com/users/Kitware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kitware/subscriptions","organizations_url":"https://api.github.com/users/Kitware/orgs","repos_url":"https://api.github.com/users/Kitware/repos","events_url":"https://api.github.com/users/Kitware/events{/privacy}","received_events_url":"https://api.github.com/users/Kitware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Kitware/HPCCloud","description":"A Cloud/Web-Based Simulation  Environment","fork":false,"url":"https://api.github.com/repos/Kitware/HPCCloud","forks_url":"https://api.github.com/repos/Kitware/HPCCloud/forks","keys_url":"https://api.github.com/repos/Kitware/HPCCloud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kitware/HPCCloud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kitware/HPCCloud/teams","hooks_url":"https://api.github.com/repos/Kitware/HPCCloud/hooks","issue_events_url":"https://api.github.com/repos/Kitware/HPCCloud/issues/events{/number}","events_url":"https://api.github.com/repos/Kitware/HPCCloud/events","assignees_url":"https://api.github.com/repos/Kitware/HPCCloud/assignees{/user}","branches_url":"https://api.github.com/repos/Kitware/HPCCloud/branches{/branch}","tags_url":"https://api.github.com/repos/Kitware/HPCCloud/tags","blobs_url":"https://api.github.com/repos/Kitware/HPCCloud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kitware/HPCCloud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kitware/HPCCloud/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kitware/HPCCloud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kitware/HPCCloud/statuses/{sha}","languages_url":"https://api.github.com/repos/Kitware/HPCCloud/languages","stargazers_url":"https://api.github.com/repos/Kitware/HPCCloud/stargazers","contributors_url":"https://api.github.com/repos/Kitware/HPCCloud/contributors","subscribers_url":"https://api.github.com/repos/Kitware/HPCCloud/subscribers","subscription_url":"https://api.github.com/repos/Kitware/HPCCloud/subscription","commits_url":"https://api.github.com/repos/Kitware/HPCCloud/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kitware/HPCCloud/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kitware/HPCCloud/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kitware/HPCCloud/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kitware/HPCCloud/contents/{+path}","compare_url":"https://api.github.com/repos/Kitware/HPCCloud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kitware/HPCCloud/merges","archive_url":"https://api.github.com/repos/Kitware/HPCCloud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kitware/HPCCloud/downloads","issues_url":"https://api.github.com/repos/Kitware/HPCCloud/issues{/number}","pulls_url":"https://api.github.com/repos/Kitware/HPCCloud/pulls{/number}","milestones_url":"https://api.github.com/repos/Kitware/HPCCloud/milestones{/number}","notifications_url":"https://api.github.com/repos/Kitware/HPCCloud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kitware/HPCCloud/labels{/name}","releases_url":"https://api.github.com/repos/Kitware/HPCCloud/releases{/id}","deployments_url":"https://api.github.com/repos/Kitware/HPCCloud/deployments","created_at":"2015-08-17T19:55:03Z","updated_at":"2016-05-04T21:43:06Z","pushed_at":"2016-07-27T20:24:17Z","git_url":"git://github.com/Kitware/HPCCloud.git","ssh_url":"git@github.com:Kitware/HPCCloud.git","clone_url":"https://github.com/Kitware/HPCCloud.git","svn_url":"https://github.com/Kitware/HPCCloud","homepage":"","size":8797,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":49,"forks":3,"open_issues":49,"watchers":4,"default_branch":"master"}},"base":{"label":"Kitware:master","ref":"master","sha":"f58986659ce4fc310edc758819c949d154fe7189","user":{"login":"Kitware","id":87549,"avatar_url":"https://avatars.githubusercontent.com/u/87549?v=3","gravatar_id":"","url":"https://api.github.com/users/Kitware","html_url":"https://github.com/Kitware","followers_url":"https://api.github.com/users/Kitware/followers","following_url":"https://api.github.com/users/Kitware/following{/other_user}","gists_url":"https://api.github.com/users/Kitware/gists{/gist_id}","starred_url":"https://api.github.com/users/Kitware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kitware/subscriptions","organizations_url":"https://api.github.com/users/Kitware/orgs","repos_url":"https://api.github.com/users/Kitware/repos","events_url":"https://api.github.com/users/Kitware/events{/privacy}","received_events_url":"https://api.github.com/users/Kitware/received_events","type":"Organization","site_admin":false},"repo":{"id":40924266,"name":"HPCCloud","full_name":"Kitware/HPCCloud","owner":{"login":"Kitware","id":87549,"avatar_url":"https://avatars.githubusercontent.com/u/87549?v=3","gravatar_id":"","url":"https://api.github.com/users/Kitware","html_url":"https://github.com/Kitware","followers_url":"https://api.github.com/users/Kitware/followers","following_url":"https://api.github.com/users/Kitware/following{/other_user}","gists_url":"https://api.github.com/users/Kitware/gists{/gist_id}","starred_url":"https://api.github.com/users/Kitware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kitware/subscriptions","organizations_url":"https://api.github.com/users/Kitware/orgs","repos_url":"https://api.github.com/users/Kitware/repos","events_url":"https://api.github.com/users/Kitware/events{/privacy}","received_events_url":"https://api.github.com/users/Kitware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Kitware/HPCCloud","description":"A Cloud/Web-Based Simulation  Environment","fork":false,"url":"https://api.github.com/repos/Kitware/HPCCloud","forks_url":"https://api.github.com/repos/Kitware/HPCCloud/forks","keys_url":"https://api.github.com/repos/Kitware/HPCCloud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kitware/HPCCloud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kitware/HPCCloud/teams","hooks_url":"https://api.github.com/repos/Kitware/HPCCloud/hooks","issue_events_url":"https://api.github.com/repos/Kitware/HPCCloud/issues/events{/number}","events_url":"https://api.github.com/repos/Kitware/HPCCloud/events","assignees_url":"https://api.github.com/repos/Kitware/HPCCloud/assignees{/user}","branches_url":"https://api.github.com/repos/Kitware/HPCCloud/branches{/branch}","tags_url":"https://api.github.com/repos/Kitware/HPCCloud/tags","blobs_url":"https://api.github.com/repos/Kitware/HPCCloud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kitware/HPCCloud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kitware/HPCCloud/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kitware/HPCCloud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kitware/HPCCloud/statuses/{sha}","languages_url":"https://api.github.com/repos/Kitware/HPCCloud/languages","stargazers_url":"https://api.github.com/repos/Kitware/HPCCloud/stargazers","contributors_url":"https://api.github.com/repos/Kitware/HPCCloud/contributors","subscribers_url":"https://api.github.com/repos/Kitware/HPCCloud/subscribers","subscription_url":"https://api.github.com/repos/Kitware/HPCCloud/subscription","commits_url":"https://api.github.com/repos/Kitware/HPCCloud/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kitware/HPCCloud/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kitware/HPCCloud/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kitware/HPCCloud/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kitware/HPCCloud/contents/{+path}","compare_url":"https://api.github.com/repos/Kitware/HPCCloud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kitware/HPCCloud/merges","archive_url":"https://api.github.com/repos/Kitware/HPCCloud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kitware/HPCCloud/downloads","issues_url":"https://api.github.com/repos/Kitware/HPCCloud/issues{/number}","pulls_url":"https://api.github.com/repos/Kitware/HPCCloud/pulls{/number}","milestones_url":"https://api.github.com/repos/Kitware/HPCCloud/milestones{/number}","notifications_url":"https://api.github.com/repos/Kitware/HPCCloud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kitware/HPCCloud/labels{/name}","releases_url":"https://api.github.com/repos/Kitware/HPCCloud/releases{/id}","deployments_url":"https://api.github.com/repos/Kitware/HPCCloud/deployments","created_at":"2015-08-17T19:55:03Z","updated_at":"2016-05-04T21:43:06Z","pushed_at":"2016-07-27T20:24:17Z","git_url":"git://github.com/Kitware/HPCCloud.git","ssh_url":"git@github.com:Kitware/HPCCloud.git","clone_url":"https://github.com/Kitware/HPCCloud.git","svn_url":"https://github.com/Kitware/HPCCloud","homepage":"","size":8797,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":49,"forks":3,"open_issues":49,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Kitware/HPCCloud/pulls/456"},"html":{"href":"https://github.com/Kitware/HPCCloud/pull/456"},"issue":{"href":"https://api.github.com/repos/Kitware/HPCCloud/issues/456"},"comments":{"href":"https://api.github.com/repos/Kitware/HPCCloud/issues/456/comments"},"review_comments":{"href":"https://api.github.com/repos/Kitware/HPCCloud/pulls/456/comments"},"review_comment":{"href":"https://api.github.com/repos/Kitware/HPCCloud/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Kitware/HPCCloud/pulls/456/commits"},"statuses":{"href":"https://api.github.com/repos/Kitware/HPCCloud/statuses/9c0645727a760a12161c36e741fbe83e12547df6"}}}}
{"actor":{"display_login":"cjh1"}}