You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/12/08 02:46:41 UTC
[GitHub] [airflow] otourzan commented on issue #12804: Regional Dataproc Workflow Template Instantiate Fails
otourzan commented on issue #12804:
URL: https://github.com/apache/airflow/issues/12804#issuecomment-740324839
I could workaround it by overriding hook methods in DAG with the following code. I'll send a pull request to fix in main code as well.
```python
from airflow.providers.google.cloud.hooks.dataproc import DataprocHook
from google.cloud.dataproc_v1beta2 import WorkflowTemplateServiceClient
def get_template_client(self, location=None) -> WorkflowTemplateServiceClient:
"""Returns WorkflowTemplateServiceClient."""
client_options = {'api_endpoint': f'{location}-dataproc.googleapis.com:443'} if location and location != 'global' else None
return WorkflowTemplateServiceClient(
credentials=self._get_credentials(), client_info=self.client_info, client_options=client_options
)
def instantiate_workflow_template(
self,
location: str,
template_name: str,
project_id: str,
version=None,
request_id=None,
parameters=None,
retry=None,
timeout=None,
metadata=None,
):
client = self.get_template_client(location)
name = client.workflow_template_path(project_id, location, template_name)
operation = client.instantiate_workflow_template(
name=name,
version=version,
parameters=parameters,
request_id=request_id,
retry=retry,
timeout=timeout,
metadata=metadata,
)
return operation
DataprocHook.get_template_client = get_template_client
DataprocHook.instantiate_workflow_template = instantiate_workflow_template
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org