{"action":"created","comment":{"url":"https://api.github.com/repos/googledatalab/pydatalab/pulls/comments/100940020","pull_request_review_id":21656794,"id":100940020,"diff_hunk":"@@ -68,6 +64,62 @@ def describe(self):\n     job_yaml = yaml.safe_dump(self._info, default_flow_style=False)\n     print job_yaml\n \n+  @staticmethod \n+  def submit_training(job_request, job_id=None):\n+    \"\"\"Submit a training job.\n+\n+    Args:\n+      job_request: the arguments of the training job in a dict. For example,\n+          {\n+            'package_uris':  'gs://my-bucket/iris/trainer-0.1.tar.gz',\n+            'python_module': 'trainer.task',\n+            'scale_tier': 'BASIC',\n+            'region': 'us-central1',\n+            'args': {\n+              'train_data_paths': ['gs://mubucket/data/features_train'],\n+              'eval_data_paths': ['gs://mubucket/data/features_eval'],\n+              'metadata_path': 'gs://mubucket/data/metadata.yaml',\n+              'output_path': 'gs://mubucket/data/mymodel/',\n+            }\n+          }\n+      job_id: id for the training job. If None, an id based on timestamp will be generated.\n+    Returns:\n+      A Job object representing the cloud training job.\n+    \"\"\"\n+    new_job_request = dict(job_request)\n+    # convert job_args from dict to list as service required.\n+    if 'args' in job_request and isinstance(job_request['args'], dict):\n+      job_args = job_request['args']\n+      args = []\n+      for k,v in job_args.iteritems():\n+        if isinstance(v, list):\n+          for item in v:\n+            args.append('--' + k)\n+            args.append(str(item))\n+        else:\n+          args.append('--' + k)\n+          args.append(str(v))\n+      new_job_request['args'] = args\n+    \n+    if job_id is None:\n+      job_id = datetime.datetime.now().strftime('%y%m%d_%H%M%S')\n+      if 'python_module' in new_job_request:\n+        job_id = new_job_request['python_module'].replace('.', '_') + \\\n+            '_' + job_id\n+        \n+    job = {\n+        'job_id': job_id,\n+        'training_input': new_job_request,\n+    }\n+    context = datalab.context.Context.default()\n+    cloudml = discovery.build('ml', 'v1beta1', credentials=context.credentials,\n+                              discoveryServiceUrl=_CLOUDML_DISCOVERY_URL)","path":"datalab/mlalpha/_job.py","position":64,"original_position":64,"commit_id":"d005a12ca85c3da617459116ee160e068c616ff6","original_commit_id":"d005a12ca85c3da617459116ee160e068c616ff6","user":{"login":"qimingj","id":13439553,"avatar_url":"https://avatars.githubusercontent.com/u/13439553?v=3","gravatar_id":"","url":"https://api.github.com/users/qimingj","html_url":"https://github.com/qimingj","followers_url":"https://api.github.com/users/qimingj/followers","following_url":"https://api.github.com/users/qimingj/following{/other_user}","gists_url":"https://api.github.com/users/qimingj/gists{/gist_id}","starred_url":"https://api.github.com/users/qimingj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qimingj/subscriptions","organizations_url":"https://api.github.com/users/qimingj/orgs","repos_url":"https://api.github.com/users/qimingj/repos","events_url":"https://api.github.com/users/qimingj/events{/privacy}","received_events_url":"https://api.github.com/users/qimingj/received_events","type":"User","site_admin":false},"body":"yes. That will be a separate change (from v1beta1 to v1).","created_at":"2017-02-14T01:12:09Z","updated_at":"2017-02-14T01:12:09Z","html_url":"https://github.com/googledatalab/pydatalab/pull/192#discussion_r100940020","pull_request_url":"https://api.github.com/repos/googledatalab/pydatalab/pulls/192","_links":{"self":{"href":"https://api.github.com/repos/googledatalab/pydatalab/pulls/comments/100940020"},"html":{"href":"https://github.com/googledatalab/pydatalab/pull/192#discussion_r100940020"},"pull_request":{"href":"https://api.github.com/repos/googledatalab/pydatalab/pulls/192"}}},"pull_request":{"url":"https://api.github.com/repos/googledatalab/pydatalab/pulls/192","id":106011565,"html_url":"https://github.com/googledatalab/pydatalab/pull/192","diff_url":"https://github.com/googledatalab/pydatalab/pull/192.diff","patch_url":"https://github.com/googledatalab/pydatalab/pull/192.patch","issue_url":"https://api.github.com/repos/googledatalab/pydatalab/issues/192","number":192,"state":"open","locked":false,"title":"Move cloud trainer and predictor from their own classes to Job and Model respectively.","user":{"login":"qimingj","id":13439553,"avatar_url":"https://avatars.githubusercontent.com/u/13439553?v=3","gravatar_id":"","url":"https://api.github.com/users/qimingj","html_url":"https://github.com/qimingj","followers_url":"https://api.github.com/users/qimingj/followers","following_url":"https://api.github.com/users/qimingj/following{/other_user}","gists_url":"https://api.github.com/users/qimingj/gists{/gist_id}","starred_url":"https://api.github.com/users/qimingj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qimingj/subscriptions","organizations_url":"https://api.github.com/users/qimingj/orgs","repos_url":"https://api.github.com/users/qimingj/repos","events_url":"https://api.github.com/users/qimingj/events{/privacy}","received_events_url":"https://api.github.com/users/qimingj/received_events","type":"User","site_admin":false},"body":"Cloud trainer and predictor will be cleaned up in a seperate change.","created_at":"2017-02-14T00:44:56Z","updated_at":"2017-02-14T01:12:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"101afe1278395eb15dd0b56f7485380ae9d99415","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/googledatalab/pydatalab/pulls/192/commits","review_comments_url":"https://api.github.com/repos/googledatalab/pydatalab/pulls/192/comments","review_comment_url":"https://api.github.com/repos/googledatalab/pydatalab/pulls/comments{/number}","comments_url":"https://api.github.com/repos/googledatalab/pydatalab/issues/192/comments","statuses_url":"https://api.github.com/repos/googledatalab/pydatalab/statuses/d005a12ca85c3da617459116ee160e068c616ff6","head":{"label":"googledatalab:cloudmlapi","ref":"cloudmlapi","sha":"d005a12ca85c3da617459116ee160e068c616ff6","user":{"login":"googledatalab","id":18582876,"avatar_url":"https://avatars.githubusercontent.com/u/18582876?v=3","gravatar_id":"","url":"https://api.github.com/users/googledatalab","html_url":"https://github.com/googledatalab","followers_url":"https://api.github.com/users/googledatalab/followers","following_url":"https://api.github.com/users/googledatalab/following{/other_user}","gists_url":"https://api.github.com/users/googledatalab/gists{/gist_id}","starred_url":"https://api.github.com/users/googledatalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googledatalab/subscriptions","organizations_url":"https://api.github.com/users/googledatalab/orgs","repos_url":"https://api.github.com/users/googledatalab/repos","events_url":"https://api.github.com/users/googledatalab/events{/privacy}","received_events_url":"https://api.github.com/users/googledatalab/received_events","type":"Organization","site_admin":false},"repo":{"id":58776721,"name":"pydatalab","full_name":"googledatalab/pydatalab","owner":{"login":"googledatalab","id":18582876,"avatar_url":"https://avatars.githubusercontent.com/u/18582876?v=3","gravatar_id":"","url":"https://api.github.com/users/googledatalab","html_url":"https://github.com/googledatalab","followers_url":"https://api.github.com/users/googledatalab/followers","following_url":"https://api.github.com/users/googledatalab/following{/other_user}","gists_url":"https://api.github.com/users/googledatalab/gists{/gist_id}","starred_url":"https://api.github.com/users/googledatalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googledatalab/subscriptions","organizations_url":"https://api.github.com/users/googledatalab/orgs","repos_url":"https://api.github.com/users/googledatalab/repos","events_url":"https://api.github.com/users/googledatalab/events{/privacy}","received_events_url":"https://api.github.com/users/googledatalab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/googledatalab/pydatalab","description":"Google Datalab Library","fork":false,"url":"https://api.github.com/repos/googledatalab/pydatalab","forks_url":"https://api.github.com/repos/googledatalab/pydatalab/forks","keys_url":"https://api.github.com/repos/googledatalab/pydatalab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/googledatalab/pydatalab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/googledatalab/pydatalab/teams","hooks_url":"https://api.github.com/repos/googledatalab/pydatalab/hooks","issue_events_url":"https://api.github.com/repos/googledatalab/pydatalab/issues/events{/number}","events_url":"https://api.github.com/repos/googledatalab/pydatalab/events","assignees_url":"https://api.github.com/repos/googledatalab/pydatalab/assignees{/user}","branches_url":"https://api.github.com/repos/googledatalab/pydatalab/branches{/branch}","tags_url":"https://api.github.com/repos/googledatalab/pydatalab/tags","blobs_url":"https://api.github.com/repos/googledatalab/pydatalab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/googledatalab/pydatalab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/googledatalab/pydatalab/git/refs{/sha}","trees_url":"https://api.github.com/repos/googledatalab/pydatalab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/googledatalab/pydatalab/statuses/{sha}","languages_url":"https://api.github.com/repos/googledatalab/pydatalab/languages","stargazers_url":"https://api.github.com/repos/googledatalab/pydatalab/stargazers","contributors_url":"https://api.github.com/repos/googledatalab/pydatalab/contributors","subscribers_url":"https://api.github.com/repos/googledatalab/pydatalab/subscribers","subscription_url":"https://api.github.com/repos/googledatalab/pydatalab/subscription","commits_url":"https://api.github.com/repos/googledatalab/pydatalab/commits{/sha}","git_commits_url":"https://api.github.com/repos/googledatalab/pydatalab/git/commits{/sha}","comments_url":"https://api.github.com/repos/googledatalab/pydatalab/comments{/number}","issue_comment_url":"https://api.github.com/repos/googledatalab/pydatalab/issues/comments{/number}","contents_url":"https://api.github.com/repos/googledatalab/pydatalab/contents/{+path}","compare_url":"https://api.github.com/repos/googledatalab/pydatalab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/googledatalab/pydatalab/merges","archive_url":"https://api.github.com/repos/googledatalab/pydatalab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/googledatalab/pydatalab/downloads","issues_url":"https://api.github.com/repos/googledatalab/pydatalab/issues{/number}","pulls_url":"https://api.github.com/repos/googledatalab/pydatalab/pulls{/number}","milestones_url":"https://api.github.com/repos/googledatalab/pydatalab/milestones{/number}","notifications_url":"https://api.github.com/repos/googledatalab/pydatalab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/googledatalab/pydatalab/labels{/name}","releases_url":"https://api.github.com/repos/googledatalab/pydatalab/releases{/id}","deployments_url":"https://api.github.com/repos/googledatalab/pydatalab/deployments","created_at":"2016-05-13T22:42:57Z","updated_at":"2017-02-02T01:37:58Z","pushed_at":"2017-02-14T00:44:57Z","git_url":"git://github.com/googledatalab/pydatalab.git","ssh_url":"git@github.com:googledatalab/pydatalab.git","clone_url":"https://github.com/googledatalab/pydatalab.git","svn_url":"https://github.com/googledatalab/pydatalab","homepage":null,"size":10085,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":38,"forks":14,"open_issues":38,"watchers":16,"default_branch":"master"}},"base":{"label":"googledatalab:cloudml","ref":"cloudml","sha":"70a2cfc2d83f490c7f80e55958f71d9c747ca71c","user":{"login":"googledatalab","id":18582876,"avatar_url":"https://avatars.githubusercontent.com/u/18582876?v=3","gravatar_id":"","url":"https://api.github.com/users/googledatalab","html_url":"https://github.com/googledatalab","followers_url":"https://api.github.com/users/googledatalab/followers","following_url":"https://api.github.com/users/googledatalab/following{/other_user}","gists_url":"https://api.github.com/users/googledatalab/gists{/gist_id}","starred_url":"https://api.github.com/users/googledatalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googledatalab/subscriptions","organizations_url":"https://api.github.com/users/googledatalab/orgs","repos_url":"https://api.github.com/users/googledatalab/repos","events_url":"https://api.github.com/users/googledatalab/events{/privacy}","received_events_url":"https://api.github.com/users/googledatalab/received_events","type":"Organization","site_admin":false},"repo":{"id":58776721,"name":"pydatalab","full_name":"googledatalab/pydatalab","owner":{"login":"googledatalab","id":18582876,"avatar_url":"https://avatars.githubusercontent.com/u/18582876?v=3","gravatar_id":"","url":"https://api.github.com/users/googledatalab","html_url":"https://github.com/googledatalab","followers_url":"https://api.github.com/users/googledatalab/followers","following_url":"https://api.github.com/users/googledatalab/following{/other_user}","gists_url":"https://api.github.com/users/googledatalab/gists{/gist_id}","starred_url":"https://api.github.com/users/googledatalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googledatalab/subscriptions","organizations_url":"https://api.github.com/users/googledatalab/orgs","repos_url":"https://api.github.com/users/googledatalab/repos","events_url":"https://api.github.com/users/googledatalab/events{/privacy}","received_events_url":"https://api.github.com/users/googledatalab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/googledatalab/pydatalab","description":"Google Datalab Library","fork":false,"url":"https://api.github.com/repos/googledatalab/pydatalab","forks_url":"https://api.github.com/repos/googledatalab/pydatalab/forks","keys_url":"https://api.github.com/repos/googledatalab/pydatalab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/googledatalab/pydatalab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/googledatalab/pydatalab/teams","hooks_url":"https://api.github.com/repos/googledatalab/pydatalab/hooks","issue_events_url":"https://api.github.com/repos/googledatalab/pydatalab/issues/events{/number}","events_url":"https://api.github.com/repos/googledatalab/pydatalab/events","assignees_url":"https://api.github.com/repos/googledatalab/pydatalab/assignees{/user}","branches_url":"https://api.github.com/repos/googledatalab/pydatalab/branches{/branch}","tags_url":"https://api.github.com/repos/googledatalab/pydatalab/tags","blobs_url":"https://api.github.com/repos/googledatalab/pydatalab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/googledatalab/pydatalab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/googledatalab/pydatalab/git/refs{/sha}","trees_url":"https://api.github.com/repos/googledatalab/pydatalab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/googledatalab/pydatalab/statuses/{sha}","languages_url":"https://api.github.com/repos/googledatalab/pydatalab/languages","stargazers_url":"https://api.github.com/repos/googledatalab/pydatalab/stargazers","contributors_url":"https://api.github.com/repos/googledatalab/pydatalab/contributors","subscribers_url":"https://api.github.com/repos/googledatalab/pydatalab/subscribers","subscription_url":"https://api.github.com/repos/googledatalab/pydatalab/subscription","commits_url":"https://api.github.com/repos/googledatalab/pydatalab/commits{/sha}","git_commits_url":"https://api.github.com/repos/googledatalab/pydatalab/git/commits{/sha}","comments_url":"https://api.github.com/repos/googledatalab/pydatalab/comments{/number}","issue_comment_url":"https://api.github.com/repos/googledatalab/pydatalab/issues/comments{/number}","contents_url":"https://api.github.com/repos/googledatalab/pydatalab/contents/{+path}","compare_url":"https://api.github.com/repos/googledatalab/pydatalab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/googledatalab/pydatalab/merges","archive_url":"https://api.github.com/repos/googledatalab/pydatalab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/googledatalab/pydatalab/downloads","issues_url":"https://api.github.com/repos/googledatalab/pydatalab/issues{/number}","pulls_url":"https://api.github.com/repos/googledatalab/pydatalab/pulls{/number}","milestones_url":"https://api.github.com/repos/googledatalab/pydatalab/milestones{/number}","notifications_url":"https://api.github.com/repos/googledatalab/pydatalab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/googledatalab/pydatalab/labels{/name}","releases_url":"https://api.github.com/repos/googledatalab/pydatalab/releases{/id}","deployments_url":"https://api.github.com/repos/googledatalab/pydatalab/deployments","created_at":"2016-05-13T22:42:57Z","updated_at":"2017-02-02T01:37:58Z","pushed_at":"2017-02-14T00:44:57Z","git_url":"git://github.com/googledatalab/pydatalab.git","ssh_url":"git@github.com:googledatalab/pydatalab.git","clone_url":"https://github.com/googledatalab/pydatalab.git","svn_url":"https://github.com/googledatalab/pydatalab","homepage":null,"size":10085,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":38,"forks":14,"open_issues":38,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/googledatalab/pydatalab/pulls/192"},"html":{"href":"https://github.com/googledatalab/pydatalab/pull/192"},"issue":{"href":"https://api.github.com/repos/googledatalab/pydatalab/issues/192"},"comments":{"href":"https://api.github.com/repos/googledatalab/pydatalab/issues/192/comments"},"review_comments":{"href":"https://api.github.com/repos/googledatalab/pydatalab/pulls/192/comments"},"review_comment":{"href":"https://api.github.com/repos/googledatalab/pydatalab/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/googledatalab/pydatalab/pulls/192/commits"},"statuses":{"href":"https://api.github.com/repos/googledatalab/pydatalab/statuses/d005a12ca85c3da617459116ee160e068c616ff6"}}}}
{"actor":{"display_login":"qimingj"}}