[ 
https://issues.apache.org/jira/browse/BEAM-13812?focusedWorklogId=727935&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-727935
 ]

ASF GitHub Bot logged work on BEAM-13812:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 15/Feb/22 23:54
            Start Date: 15/Feb/22 23:54
    Worklog Time Spent: 10m 
      Work Description: VictorPlusC commented on a change in pull request 
#16741:
URL: https://github.com/apache/beam/pull/16741#discussion_r807416546



##########
File path: 
sdks/python/apache_beam/runners/interactive/interactive_environment.py
##########
@@ -549,6 +589,50 @@ def set_cached_source_signature(self, pipeline, signature):
   def get_cached_source_signature(self, pipeline):
     return self._cached_source_signature.get(str(id(pipeline)), set())
 
+  def set_dataproc_cluster_manager(self, pipeline):
+    """Sets the instance of DataprocClusterManager to be used by the
+    pipeline.
+    """
+    if self._is_in_ipython:
+      warnings.filterwarnings(
+          'ignore',
+          'options is deprecated since First stable release. References to '
+          '<pipeline>.options will not be supported',
+          category=DeprecationWarning)
+    project_id = (pipeline.options.view_as(GoogleCloudOptions).project)
+    region = (pipeline.options.view_as(GoogleCloudOptions).region)
+    cluster_name = self.clusters.default_cluster_name
+    cluster_manager = DataprocClusterManager(
+        project_id=project_id, region=region, cluster_name=cluster_name)
+    self.clusters._dataproc_cluster_managers[str(id(pipeline))] = 
cluster_manager
+
+  def get_dataproc_cluster_manager(self, pipeline):
+    """Gets the instance of DataprocClusterManager currently used by the
+    pipeline.
+    """
+    return self.clusters._dataproc_cluster_managers.get(str(id(pipeline)), 
None)
+
+  def evict_dataproc_cluster_manager(self, pipeline):
+    """Evicts and pops the instance of DataprocClusterManager that is currently
+    used by the pipeline. Noop if the given pipeline is absent from the
+    environment or if the DataprocClusterManager instance is being used by
+    another pipeline. If no pipeline is specified, evicts for all pipelines.
+    """
+    if pipeline:
+      cluster_manager = self.clusters._dataproc_cluster_managers.pop(
+          str(id(pipeline)), None)
+      if cluster_manager:
+        master_url = cluster_manager.master_url
+        if len(self.clusters.get_pipelines_using_master_url( \
+        master_url)) == 1:
+          del self.clusters._master_urls[master_url]
+          del self.clusters._master_urls_to_pipelines[master_url]
+      return
+    self.clusters._dataproc_cluster_managers.clear()
+    self.clusters._master_urls.clear()
+    self.clusters._master_urls.inverse.clear()

Review comment:
       That makes sense. I've now implemented this change, thanks!




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 727935)
    Time Spent: 11.5h  (was: 11h 20m)

> Integrate DataprocClusterManager into Interactive Environment
> -------------------------------------------------------------
>
>                 Key: BEAM-13812
>                 URL: https://issues.apache.org/jira/browse/BEAM-13812
>             Project: Beam
>          Issue Type: New Feature
>          Components: runner-py-interactive
>            Reporter: Victor Chen
>            Assignee: Victor Chen
>            Priority: P2
>          Time Spent: 11.5h
>  Remaining Estimate: 0h
>
> * Adds code to automatically create a Dataproc cluster configured with Docker 
> and Flink if a user instantiates an InteractiveRunner using 
> underlying_runner='FlinkRunner'
>  * By default, the created Dataproc cluster will be called 
> 'interactive-beam-cluster' and will be cleaned up when the Interactive 
> Environment is interrupted
>  * Users will be able to toggle an automatic deletion of the cluster with the 
> default name, 'interactive-beam-cluster' when the kernel is interrupted
>  * Introduces the Clusters class in interactive_beam.py, which acts as a user 
> interface that provides the user with the following capabilities:
>  ** Changing the default name of the clusters created by Interactive Beam
>  ** Cleaning up a cluster by providing a corresponding pipeline, an option to 
> force the deletion is provided, in the case where more than one pipeline use 
> the same cluster
>  ** Getting all pipelines that use the provided master_url
>  ** Receiving a description back for either the cluster corresponding to a 
> specific pipeline, or the descriptions of all pipelines



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to