{"action":"created","comment":{"url":"https://api.github.com/repos/spotify/scio/pulls/comments/144915322","pull_request_review_id":69638995,"id":144915322,"diff_hunk":"@@ -0,0 +1,124 @@\n+/*\n+ * Copyright 2017 Spotify AB.\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,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package com.spotify.scio.runners.dataflow\n+\n+import java.util.Collections\n+\n+import com.google.api.services.dataflow.model.{Job, JobMetrics}\n+import com.spotify.scio.metrics.Metrics\n+import com.spotify.scio.{RunnerResult, ScioResult}\n+import org.apache.beam.runners.dataflow.options.DataflowPipelineOptions\n+import org.apache.beam.runners.dataflow.{DataflowClient, DataflowPipelineJob}\n+import org.apache.beam.sdk.options.PipelineOptionsFactory\n+import org.apache.beam.sdk.runners.AppliedPTransform\n+import org.apache.beam.sdk.transforms.PTransform\n+import org.apache.beam.sdk.values.{PInput, POutput}\n+import org.apache.beam.sdk.{Pipeline, PipelineResult}\n+\n+import scala.collection.JavaConverters._\n+import scala.concurrent.Future\n+\n+/** Represent a Dataflow runner specific result. */\n+class DataflowResult(val internal: DataflowPipelineJob) extends RunnerResult {\n+\n+  def this(internal: PipelineResult) = this(internal.asInstanceOf[DataflowPipelineJob])\n+\n+  private val client = DataflowResult.getOptions(internal.getProjectId).getDataflowClient\n+\n+  /** Get Dataflow [[Job]]. */\n+  lazy val getJob: Job = client.projects().jobs()\n+    .get(internal.getProjectId, internal.getJobId)\n+    .setView(\"JOB_VIEW_ALL\")\n+    .execute()\n+\n+  /** Get Dataflow [[JobMetrics]]. */\n+  lazy val getJobMetrics: JobMetrics = client.projects().jobs()\n+    .getMetrics(internal.getProjectId, internal.getJobId)\n+    .execute()\n+\n+  /** Get a generic [[ScioResult]]. */\n+  override def asScioResult: ScioResult = new DataflowScioResult(internal)\n+\n+  private class DataflowScioResult(internal: PipelineResult) extends ScioResult(internal) {\n+    override val finalState: Future[PipelineResult.State] = {\n+      import scala.concurrent.ExecutionContext.Implicits.global\n+      Future {\n+        internal.waitUntilFinish()\n+        this.state\n+      }\n+    }\n+\n+    override def getMetrics: Metrics = {\n+      val options = getJob.getEnvironment.getSdkPipelineOptions.get(\"options\")\n+        .asInstanceOf[java.util.Map[String, AnyRef]]\n+      Metrics(\n+        options.get(\"scioVersion\").toString,\n+        options.get(\"scalaVersion\").toString,\n+        options.get(\"appName\").toString,\n+        internal.getState.toString,\n+        getBeamMetrics)\n+    }\n+  }\n+\n+}\n+\n+/** Companion object for [[DataflowResult]]. */\n+object DataflowResult {\n+  /** Create a new [[DataflowResult]] instance. */\n+  def apply(projectId: String, jobId: String): DataflowResult = {\n+    val options = getOptions(projectId)\n+\n+    val job = options.getDataflowClient.projects().jobs()\n+      .get(options.getProject, jobId)\n+      .setView(\"JOB_VIEW_ALL\")\n+      .execute()\n+    val transformStepNames: Map[AppliedPTransform[_, _, _], String] =","path":"scio-core/src/main/scala/com/spotify/scio/runners/dataflow/DataflowResult.scala","position":90,"original_position":90,"commit_id":"55fcf615cb3559ffa70535770e2028149b1da918","original_commit_id":"55fcf615cb3559ffa70535770e2028149b1da918","user":{"login":"ravwojdyla","id":1419010,"avatar_url":"https://avatars0.githubusercontent.com/u/1419010?v=4","gravatar_id":"","url":"https://api.github.com/users/ravwojdyla","html_url":"https://github.com/ravwojdyla","followers_url":"https://api.github.com/users/ravwojdyla/followers","following_url":"https://api.github.com/users/ravwojdyla/following{/other_user}","gists_url":"https://api.github.com/users/ravwojdyla/gists{/gist_id}","starred_url":"https://api.github.com/users/ravwojdyla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ravwojdyla/subscriptions","organizations_url":"https://api.github.com/users/ravwojdyla/orgs","repos_url":"https://api.github.com/users/ravwojdyla/repos","events_url":"https://api.github.com/users/ravwojdyla/events{/privacy}","received_events_url":"https://api.github.com/users/ravwojdyla/received_events","type":"User","site_admin":false},"body":"Maybe add a comment here that explains why this exists, and what you are doing here?","created_at":"2017-10-16T17:36:47Z","updated_at":"2017-10-16T17:36:47Z","html_url":"https://github.com/spotify/scio/pull/882#discussion_r144915322","pull_request_url":"https://api.github.com/repos/spotify/scio/pulls/882","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/spotify/scio/pulls/comments/144915322"},"html":{"href":"https://github.com/spotify/scio/pull/882#discussion_r144915322"},"pull_request":{"href":"https://api.github.com/repos/spotify/scio/pulls/882"}},"in_reply_to_id":144914546},"pull_request":{"url":"https://api.github.com/repos/spotify/scio/pulls/882","id":146150344,"html_url":"https://github.com/spotify/scio/pull/882","diff_url":"https://github.com/spotify/scio/pull/882.diff","patch_url":"https://github.com/spotify/scio/pull/882.patch","issue_url":"https://api.github.com/repos/spotify/scio/issues/882","number":882,"state":"open","locked":false,"title":"decouple Dataflow runner, fix 779","user":{"login":"nevillelyh","id":468514,"avatar_url":"https://avatars0.githubusercontent.com/u/468514?v=4","gravatar_id":"","url":"https://api.github.com/users/nevillelyh","html_url":"https://github.com/nevillelyh","followers_url":"https://api.github.com/users/nevillelyh/followers","following_url":"https://api.github.com/users/nevillelyh/following{/other_user}","gists_url":"https://api.github.com/users/nevillelyh/gists{/gist_id}","starred_url":"https://api.github.com/users/nevillelyh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nevillelyh/subscriptions","organizations_url":"https://api.github.com/users/nevillelyh/orgs","repos_url":"https://api.github.com/users/nevillelyh/repos","events_url":"https://api.github.com/users/nevillelyh/events{/privacy}","received_events_url":"https://api.github.com/users/nevillelyh/received_events","type":"User","site_admin":false},"body":"Todo:\r\n- [x] load `RunnerContext` via reflection\r\n- [x] remove DF runner from ScioContextTest\r\n- [x] ~remove DF runner from ScioContextIT~\r\n- [x] verify that scio-examples and scio-repl work without DF runner\r\n- [x] Support #850, allow creating ScioResult independently\r\n\r\nSummary:\r\n- `scio-core` depends on DF runner as `\"provided\"`\r\n- `scio-test` depends on DF runner as `\"it\"`, in `ScioContextIT` (can be removed by making a dummy `FakeRemoteRunner`), and `ScioBenchmark` (how do we remove this?)\r\n- `scio-repl` depends on DF runner, so it supports DF out of the box\r\n- Runner specific logic in `ScioContext` are moved to `RunnerContext`, and loaded via reflection\r\n- Runner specific logic in `ScioResult` are moved to `RunnerResult`, and loaded via `ScioResult#as`\r\n- DF specific context and result are under `com.spotify.scio.runners.dataflow` in `scio-core`. Nothing is statically initialized so it should be fine without DF runner dependency.","created_at":"2017-10-12T08:48:00Z","updated_at":"2017-10-16T17:36:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"10d144bfe4e141a0004ae9226e6dec49e74e63ee","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/spotify/scio/pulls/882/commits","review_comments_url":"https://api.github.com/repos/spotify/scio/pulls/882/comments","review_comment_url":"https://api.github.com/repos/spotify/scio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spotify/scio/issues/882/comments","statuses_url":"https://api.github.com/repos/spotify/scio/statuses/55fcf615cb3559ffa70535770e2028149b1da918","head":{"label":"spotify:neville/df-runner","ref":"neville/df-runner","sha":"55fcf615cb3559ffa70535770e2028149b1da918","user":{"login":"spotify","id":251374,"avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"repo":{"id":32946662,"name":"scio","full_name":"spotify/scio","owner":{"login":"spotify","id":251374,"avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spotify/scio","description":"A Scala API for Apache Beam and Google Cloud Dataflow.","fork":false,"url":"https://api.github.com/repos/spotify/scio","forks_url":"https://api.github.com/repos/spotify/scio/forks","keys_url":"https://api.github.com/repos/spotify/scio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spotify/scio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spotify/scio/teams","hooks_url":"https://api.github.com/repos/spotify/scio/hooks","issue_events_url":"https://api.github.com/repos/spotify/scio/issues/events{/number}","events_url":"https://api.github.com/repos/spotify/scio/events","assignees_url":"https://api.github.com/repos/spotify/scio/assignees{/user}","branches_url":"https://api.github.com/repos/spotify/scio/branches{/branch}","tags_url":"https://api.github.com/repos/spotify/scio/tags","blobs_url":"https://api.github.com/repos/spotify/scio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spotify/scio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spotify/scio/git/refs{/sha}","trees_url":"https://api.github.com/repos/spotify/scio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spotify/scio/statuses/{sha}","languages_url":"https://api.github.com/repos/spotify/scio/languages","stargazers_url":"https://api.github.com/repos/spotify/scio/stargazers","contributors_url":"https://api.github.com/repos/spotify/scio/contributors","subscribers_url":"https://api.github.com/repos/spotify/scio/subscribers","subscription_url":"https://api.github.com/repos/spotify/scio/subscription","commits_url":"https://api.github.com/repos/spotify/scio/commits{/sha}","git_commits_url":"https://api.github.com/repos/spotify/scio/git/commits{/sha}","comments_url":"https://api.github.com/repos/spotify/scio/comments{/number}","issue_comment_url":"https://api.github.com/repos/spotify/scio/issues/comments{/number}","contents_url":"https://api.github.com/repos/spotify/scio/contents/{+path}","compare_url":"https://api.github.com/repos/spotify/scio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spotify/scio/merges","archive_url":"https://api.github.com/repos/spotify/scio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spotify/scio/downloads","issues_url":"https://api.github.com/repos/spotify/scio/issues{/number}","pulls_url":"https://api.github.com/repos/spotify/scio/pulls{/number}","milestones_url":"https://api.github.com/repos/spotify/scio/milestones{/number}","notifications_url":"https://api.github.com/repos/spotify/scio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spotify/scio/labels{/name}","releases_url":"https://api.github.com/repos/spotify/scio/releases{/id}","deployments_url":"https://api.github.com/repos/spotify/scio/deployments","created_at":"2015-03-26T19:07:34Z","updated_at":"2017-10-16T17:08:36Z","pushed_at":"2017-10-15T11:57:45Z","git_url":"git://github.com/spotify/scio.git","ssh_url":"git@github.com:spotify/scio.git","clone_url":"https://github.com/spotify/scio.git","svn_url":"https://github.com/spotify/scio","homepage":"http://spotify.github.io/scio/com/spotify/scio/","size":7542,"stargazers_count":706,"watchers_count":706,"language":"Scala","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":105,"mirror_url":null,"open_issues_count":40,"forks":105,"open_issues":40,"watchers":706,"default_branch":"master"}},"base":{"label":"spotify:master","ref":"master","sha":"88e46f7e3bac9c1cdc5290a4f71a55e32974b725","user":{"login":"spotify","id":251374,"avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"repo":{"id":32946662,"name":"scio","full_name":"spotify/scio","owner":{"login":"spotify","id":251374,"avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spotify/scio","description":"A Scala API for Apache Beam and Google Cloud Dataflow.","fork":false,"url":"https://api.github.com/repos/spotify/scio","forks_url":"https://api.github.com/repos/spotify/scio/forks","keys_url":"https://api.github.com/repos/spotify/scio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spotify/scio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spotify/scio/teams","hooks_url":"https://api.github.com/repos/spotify/scio/hooks","issue_events_url":"https://api.github.com/repos/spotify/scio/issues/events{/number}","events_url":"https://api.github.com/repos/spotify/scio/events","assignees_url":"https://api.github.com/repos/spotify/scio/assignees{/user}","branches_url":"https://api.github.com/repos/spotify/scio/branches{/branch}","tags_url":"https://api.github.com/repos/spotify/scio/tags","blobs_url":"https://api.github.com/repos/spotify/scio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spotify/scio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spotify/scio/git/refs{/sha}","trees_url":"https://api.github.com/repos/spotify/scio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spotify/scio/statuses/{sha}","languages_url":"https://api.github.com/repos/spotify/scio/languages","stargazers_url":"https://api.github.com/repos/spotify/scio/stargazers","contributors_url":"https://api.github.com/repos/spotify/scio/contributors","subscribers_url":"https://api.github.com/repos/spotify/scio/subscribers","subscription_url":"https://api.github.com/repos/spotify/scio/subscription","commits_url":"https://api.github.com/repos/spotify/scio/commits{/sha}","git_commits_url":"https://api.github.com/repos/spotify/scio/git/commits{/sha}","comments_url":"https://api.github.com/repos/spotify/scio/comments{/number}","issue_comment_url":"https://api.github.com/repos/spotify/scio/issues/comments{/number}","contents_url":"https://api.github.com/repos/spotify/scio/contents/{+path}","compare_url":"https://api.github.com/repos/spotify/scio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spotify/scio/merges","archive_url":"https://api.github.com/repos/spotify/scio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spotify/scio/downloads","issues_url":"https://api.github.com/repos/spotify/scio/issues{/number}","pulls_url":"https://api.github.com/repos/spotify/scio/pulls{/number}","milestones_url":"https://api.github.com/repos/spotify/scio/milestones{/number}","notifications_url":"https://api.github.com/repos/spotify/scio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spotify/scio/labels{/name}","releases_url":"https://api.github.com/repos/spotify/scio/releases{/id}","deployments_url":"https://api.github.com/repos/spotify/scio/deployments","created_at":"2015-03-26T19:07:34Z","updated_at":"2017-10-16T17:08:36Z","pushed_at":"2017-10-15T11:57:45Z","git_url":"git://github.com/spotify/scio.git","ssh_url":"git@github.com:spotify/scio.git","clone_url":"https://github.com/spotify/scio.git","svn_url":"https://github.com/spotify/scio","homepage":"http://spotify.github.io/scio/com/spotify/scio/","size":7542,"stargazers_count":706,"watchers_count":706,"language":"Scala","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":105,"mirror_url":null,"open_issues_count":40,"forks":105,"open_issues":40,"watchers":706,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spotify/scio/pulls/882"},"html":{"href":"https://github.com/spotify/scio/pull/882"},"issue":{"href":"https://api.github.com/repos/spotify/scio/issues/882"},"comments":{"href":"https://api.github.com/repos/spotify/scio/issues/882/comments"},"review_comments":{"href":"https://api.github.com/repos/spotify/scio/pulls/882/comments"},"review_comment":{"href":"https://api.github.com/repos/spotify/scio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spotify/scio/pulls/882/commits"},"statuses":{"href":"https://api.github.com/repos/spotify/scio/statuses/55fcf615cb3559ffa70535770e2028149b1da918"}},"author_association":"OWNER"}}
{"actor":{"display_login":"ravwojdyla"}}