You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/06 14:32:53 UTC

[GitHub] [beam] damccorm commented on a diff in pull request #19266: Add an option to run Python operations in-line when invoked as a remote runner.

damccorm commented on code in PR #19266:
URL: https://github.com/apache/beam/pull/19266#discussion_r890213535


##########
sdks/python/apache_beam/runners/dataflow/dataflow_job_service.py:
##########
@@ -34,31 +32,22 @@ def _invoke_runner(self):
     """Actually calls Dataflow and waits for completion.
     """
     runner = dataflow_runner.DataflowRunner()
-    result = runner.run_pipeline(
+    self.result = runner.run_pipeline(
         None, self.pipeline_options(), self._pipeline_proto)
     # Prefer this to result.wait_until_finish() to get state updates
     # and avoid creating an extra thread (which also messes with logging).
     dataflow_runner.DataflowRunner.poll_for_job_completion(
         runner,
-        result,
+        self.result,
         None,
         lambda dataflow_state: self.set_state(
             portable_runner.PipelineResult.pipeline_state_to_runner_api_state(
-                result.api_jobstate_to_pipeline_state(dataflow_state))))
-    return result
+                self.result.api_jobstate_to_pipeline_state(dataflow_state))))
+    return self.result
 
-  def pipeline_options(self):
-    def from_urn(key):
-      assert key.startswith('beam:option:')
-      assert key.endswith(':v1')
-      return key[12:-3]
-
-    return pipeline_options.PipelineOptions(
-        **{
-            from_urn(key): value
-            for (key, value
-                 ) in job_utils.struct_to_dict(self._pipeline_options).items()
-        })
+  def cancel(self):
+    if not self.is_terminal_state(self.state):
+      self.result.cancel()

Review Comment:
   Are we using this function anywhere/is there a reason to pull this out?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org