{"action":"created","comment":{"url":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/comments/39230751","id":39230751,"diff_hunk":"@@ -365,15 +370,86 @@ def prepare( self, ec2_keypair_globs, instance_type=None, image_ref=None,\n             raise UserError( \"The first key pair name can't be a glob.\" )\n         self.ec2_keypairs = ec2_keypairs\n         self.ec2_keypair_globs = ec2_keypair_globs\n-\n         kwargs = dict( instance_type=instance_type,\n                        key_name=ec2_keypairs[ 0 ].name,\n                        placement=self.ctx.availability_zone,\n                        security_groups=security_groups,\n-                       instance_profile_arn=self._get_instance_profile_arn( ) )\n+                       instance_profile_arn=self._get_instance_profile_arn( ))\n+\n         self._populate_instance_creation_args( image, kwargs )\n+        if options['price'] != None:\n+            assert spot_support is True\n+            # this means we are using a spot bid. We need a couple additional kwargs\n+            self._optimize_bid(instance_type, options, kwargs)\n+\n+            kwargs['price']=options['price']\n+\n+            kwargs['launch_group']=self.ctx.namespace.replace(\"/\",\"\")+\"_launch_group\"\n+            try: # There is no min/max count parameter for request_spot_instances, just count\n+                kwargs['count']=kwargs['max_count']\n+                del kwargs['max_count']\n+                del kwargs['min_count']\n+            except KeyError:\n+                pass\n         self.instance_creation_args = kwargs\n \n+    def _choose_zone(self, bid, spot_data):\n+        # returns the zone to put your spot request based on:\n+        #    1) zones with prices currently under the bid\n+        #    2) zones with the most stable price\n+\n+        ZoneTuple = namedtuple(\"ZoneTuple\", [\"name\",\"price_deviation\"])\n+        def _sort_zones(bid, spot_data, zones):\n+            # returns two lists of tuples of form: [ (zone.name, std_deviation)...]\n+            # one for zones over the bid price and one for zones under bid price. Each are sorted by\n+            # increasing standard deviation values\n+            markets_under_bid, markets_over_bid = [], []\n+            for zone in zones:\n+                zlist = filter(lambda spot_history: spot_history.availability_zone == zone.name, spot_data)\n+                std_deviation = numpy.std([spot_history.price for spot_history in zlist])","path":"core/src/cgcloud/core/box.py","position":65,"original_position":65,"commit_id":"843afb56b8eb9fdfe980094484bad4ac4cef9bb0","original_commit_id":"843afb56b8eb9fdfe980094484bad4ac4cef9bb0","user":{"login":"hannes-ucsc","id":5143256,"avatar_url":"https://avatars.githubusercontent.com/u/5143256?v=3","gravatar_id":"","url":"https://api.github.com/users/hannes-ucsc","html_url":"https://github.com/hannes-ucsc","followers_url":"https://api.github.com/users/hannes-ucsc/followers","following_url":"https://api.github.com/users/hannes-ucsc/following{/other_user}","gists_url":"https://api.github.com/users/hannes-ucsc/gists{/gist_id}","starred_url":"https://api.github.com/users/hannes-ucsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hannes-ucsc/subscriptions","organizations_url":"https://api.github.com/users/hannes-ucsc/orgs","repos_url":"https://api.github.com/users/hannes-ucsc/repos","events_url":"https://api.github.com/users/hannes-ucsc/events{/privacy}","received_events_url":"https://api.github.com/users/hannes-ucsc/received_events","type":"User","site_admin":false},"body":"I know its bad but I'd add a utility method to cgcloud-lib that does this, instead of using numpy. Just because it's such a big dependency.","created_at":"2015-09-11T00:24:49Z","updated_at":"2015-09-11T00:24:49Z","html_url":"https://github.com/BD2KGenomics/cgcloud/pull/33#discussion_r39230751","pull_request_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/33","_links":{"self":{"href":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/comments/39230751"},"html":{"href":"https://github.com/BD2KGenomics/cgcloud/pull/33#discussion_r39230751"},"pull_request":{"href":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/33"}}},"pull_request":{"url":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/33","id":38402135,"html_url":"https://github.com/BD2KGenomics/cgcloud/pull/33","diff_url":"https://github.com/BD2KGenomics/cgcloud/pull/33.diff","patch_url":"https://github.com/BD2KGenomics/cgcloud/pull/33.patch","issue_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/issues/33","number":33,"state":"open","locked":false,"title":"Add spot market support","user":{"login":"cket","id":10136261,"avatar_url":"https://avatars.githubusercontent.com/u/10136261?v=3","gravatar_id":"","url":"https://api.github.com/users/cket","html_url":"https://github.com/cket","followers_url":"https://api.github.com/users/cket/followers","following_url":"https://api.github.com/users/cket/following{/other_user}","gists_url":"https://api.github.com/users/cket/gists{/gist_id}","starred_url":"https://api.github.com/users/cket/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cket/subscriptions","organizations_url":"https://api.github.com/users/cket/orgs","repos_url":"https://api.github.com/users/cket/repos","events_url":"https://api.github.com/users/cket/events{/privacy}","received_events_url":"https://api.github.com/users/cket/received_events","type":"User","site_admin":false},"body":"Added flag --spot-bid to Creation Command class. Makes sure the bid is reasonable by averaging the last week's spot price for the requested instance, and insuring that the bid less than double that average. Checks that the instance you request is available on the spot market. Works with any command that inherits from CreationCommand including create, recreate, and create-mesos-cluster. ","created_at":"2015-06-24T02:26:14Z","updated_at":"2015-09-11T00:24:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"81125858d4190b5dcf4c89d4566c33a74ad6dfff","assignee":{"login":"cket","id":10136261,"avatar_url":"https://avatars.githubusercontent.com/u/10136261?v=3","gravatar_id":"","url":"https://api.github.com/users/cket","html_url":"https://github.com/cket","followers_url":"https://api.github.com/users/cket/followers","following_url":"https://api.github.com/users/cket/following{/other_user}","gists_url":"https://api.github.com/users/cket/gists{/gist_id}","starred_url":"https://api.github.com/users/cket/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cket/subscriptions","organizations_url":"https://api.github.com/users/cket/orgs","repos_url":"https://api.github.com/users/cket/repos","events_url":"https://api.github.com/users/cket/events{/privacy}","received_events_url":"https://api.github.com/users/cket/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/33/commits","review_comments_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/33/comments","review_comment_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/issues/33/comments","statuses_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/statuses/843afb56b8eb9fdfe980094484bad4ac4cef9bb0","head":{"label":"BD2KGenomics:spot_market_support","ref":"spot_market_support","sha":"843afb56b8eb9fdfe980094484bad4ac4cef9bb0","user":{"login":"BD2KGenomics","id":8701293,"avatar_url":"https://avatars.githubusercontent.com/u/8701293?v=3","gravatar_id":"","url":"https://api.github.com/users/BD2KGenomics","html_url":"https://github.com/BD2KGenomics","followers_url":"https://api.github.com/users/BD2KGenomics/followers","following_url":"https://api.github.com/users/BD2KGenomics/following{/other_user}","gists_url":"https://api.github.com/users/BD2KGenomics/gists{/gist_id}","starred_url":"https://api.github.com/users/BD2KGenomics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BD2KGenomics/subscriptions","organizations_url":"https://api.github.com/users/BD2KGenomics/orgs","repos_url":"https://api.github.com/users/BD2KGenomics/repos","events_url":"https://api.github.com/users/BD2KGenomics/events{/privacy}","received_events_url":"https://api.github.com/users/BD2KGenomics/received_events","type":"Organization","site_admin":false},"repo":{"id":36099221,"name":"cgcloud","full_name":"BD2KGenomics/cgcloud","owner":{"login":"BD2KGenomics","id":8701293,"avatar_url":"https://avatars.githubusercontent.com/u/8701293?v=3","gravatar_id":"","url":"https://api.github.com/users/BD2KGenomics","html_url":"https://github.com/BD2KGenomics","followers_url":"https://api.github.com/users/BD2KGenomics/followers","following_url":"https://api.github.com/users/BD2KGenomics/following{/other_user}","gists_url":"https://api.github.com/users/BD2KGenomics/gists{/gist_id}","starred_url":"https://api.github.com/users/BD2KGenomics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BD2KGenomics/subscriptions","organizations_url":"https://api.github.com/users/BD2KGenomics/orgs","repos_url":"https://api.github.com/users/BD2KGenomics/repos","events_url":"https://api.github.com/users/BD2KGenomics/events{/privacy}","received_events_url":"https://api.github.com/users/BD2KGenomics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BD2KGenomics/cgcloud","description":"Image and VM management for Jenkins, Spark and Mesos clusters in EC2","fork":false,"url":"https://api.github.com/repos/BD2KGenomics/cgcloud","forks_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/forks","keys_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/teams","hooks_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/hooks","issue_events_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/issues/events{/number}","events_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/events","assignees_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/assignees{/user}","branches_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/branches{/branch}","tags_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/tags","blobs_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/git/refs{/sha}","trees_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/statuses/{sha}","languages_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/languages","stargazers_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/stargazers","contributors_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/contributors","subscribers_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/subscribers","subscription_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/subscription","commits_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/commits{/sha}","git_commits_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/git/commits{/sha}","comments_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/comments{/number}","issue_comment_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/issues/comments{/number}","contents_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/contents/{+path}","compare_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/merges","archive_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/downloads","issues_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/issues{/number}","pulls_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls{/number}","milestones_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/milestones{/number}","notifications_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/labels{/name}","releases_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/releases{/id}","created_at":"2015-05-22T23:17:45Z","updated_at":"2015-07-27T02:44:30Z","pushed_at":"2015-09-11T00:12:10Z","git_url":"git://github.com/BD2KGenomics/cgcloud.git","ssh_url":"git@github.com:BD2KGenomics/cgcloud.git","clone_url":"https://github.com/BD2KGenomics/cgcloud.git","svn_url":"https://github.com/BD2KGenomics/cgcloud","homepage":null,"size":2150,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":30,"forks":1,"open_issues":30,"watchers":1,"default_branch":"master"}},"base":{"label":"BD2KGenomics:master","ref":"master","sha":"a1ed642fbe34fa12c59a232fc435649525814be4","user":{"login":"BD2KGenomics","id":8701293,"avatar_url":"https://avatars.githubusercontent.com/u/8701293?v=3","gravatar_id":"","url":"https://api.github.com/users/BD2KGenomics","html_url":"https://github.com/BD2KGenomics","followers_url":"https://api.github.com/users/BD2KGenomics/followers","following_url":"https://api.github.com/users/BD2KGenomics/following{/other_user}","gists_url":"https://api.github.com/users/BD2KGenomics/gists{/gist_id}","starred_url":"https://api.github.com/users/BD2KGenomics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BD2KGenomics/subscriptions","organizations_url":"https://api.github.com/users/BD2KGenomics/orgs","repos_url":"https://api.github.com/users/BD2KGenomics/repos","events_url":"https://api.github.com/users/BD2KGenomics/events{/privacy}","received_events_url":"https://api.github.com/users/BD2KGenomics/received_events","type":"Organization","site_admin":false},"repo":{"id":36099221,"name":"cgcloud","full_name":"BD2KGenomics/cgcloud","owner":{"login":"BD2KGenomics","id":8701293,"avatar_url":"https://avatars.githubusercontent.com/u/8701293?v=3","gravatar_id":"","url":"https://api.github.com/users/BD2KGenomics","html_url":"https://github.com/BD2KGenomics","followers_url":"https://api.github.com/users/BD2KGenomics/followers","following_url":"https://api.github.com/users/BD2KGenomics/following{/other_user}","gists_url":"https://api.github.com/users/BD2KGenomics/gists{/gist_id}","starred_url":"https://api.github.com/users/BD2KGenomics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BD2KGenomics/subscriptions","organizations_url":"https://api.github.com/users/BD2KGenomics/orgs","repos_url":"https://api.github.com/users/BD2KGenomics/repos","events_url":"https://api.github.com/users/BD2KGenomics/events{/privacy}","received_events_url":"https://api.github.com/users/BD2KGenomics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BD2KGenomics/cgcloud","description":"Image and VM management for Jenkins, Spark and Mesos clusters in EC2","fork":false,"url":"https://api.github.com/repos/BD2KGenomics/cgcloud","forks_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/forks","keys_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/teams","hooks_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/hooks","issue_events_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/issues/events{/number}","events_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/events","assignees_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/assignees{/user}","branches_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/branches{/branch}","tags_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/tags","blobs_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/git/refs{/sha}","trees_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/statuses/{sha}","languages_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/languages","stargazers_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/stargazers","contributors_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/contributors","subscribers_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/subscribers","subscription_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/subscription","commits_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/commits{/sha}","git_commits_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/git/commits{/sha}","comments_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/comments{/number}","issue_comment_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/issues/comments{/number}","contents_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/contents/{+path}","compare_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/merges","archive_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/downloads","issues_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/issues{/number}","pulls_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls{/number}","milestones_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/milestones{/number}","notifications_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/labels{/name}","releases_url":"https://api.github.com/repos/BD2KGenomics/cgcloud/releases{/id}","created_at":"2015-05-22T23:17:45Z","updated_at":"2015-07-27T02:44:30Z","pushed_at":"2015-09-11T00:12:10Z","git_url":"git://github.com/BD2KGenomics/cgcloud.git","ssh_url":"git@github.com:BD2KGenomics/cgcloud.git","clone_url":"https://github.com/BD2KGenomics/cgcloud.git","svn_url":"https://github.com/BD2KGenomics/cgcloud","homepage":null,"size":2150,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":30,"forks":1,"open_issues":30,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/33"},"html":{"href":"https://github.com/BD2KGenomics/cgcloud/pull/33"},"issue":{"href":"https://api.github.com/repos/BD2KGenomics/cgcloud/issues/33"},"comments":{"href":"https://api.github.com/repos/BD2KGenomics/cgcloud/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BD2KGenomics/cgcloud/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/BD2KGenomics/cgcloud/statuses/843afb56b8eb9fdfe980094484bad4ac4cef9bb0"}}}}