Skip to content

Commit

Permalink
fix templated field assignment google/cloud/operators/compute.py (#…
Browse files Browse the repository at this point in the history
…37659)

* fix templated field assignment

* fix cr
  • Loading branch information
romsharon98 authored Feb 25, 2024
1 parent ff775e0 commit 046fb49
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ repos:
(?x)^(
^.*__init__\.py$|
^airflow\/providers\/amazon\/aws\/transfers\/redshift_to_s3\.py$|
^airflow\/providers\/google\/cloud\/operators\/compute\.py$|
^airflow\/providers\/amazon\/aws\/operators\/emr\.py$|
^airflow\/providers\/amazon\/aws\/operators\/eks\.py$
)$
Expand Down
6 changes: 3 additions & 3 deletions airflow/providers/google/cloud/links/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def persist(
context: Context,
task_instance: BaseOperator,
location_id: str,
resource_id: str,
resource_id: str | None,
project_id: str | None,
):
task_instance.xcom_push(
Expand All @@ -73,7 +73,7 @@ class ComputeInstanceTemplateDetailsLink(BaseGoogleLink):
def persist(
context: Context,
task_instance: BaseOperator,
resource_id: str,
resource_id: str | None,
project_id: str | None,
):
task_instance.xcom_push(
Expand All @@ -98,7 +98,7 @@ def persist(
context: Context,
task_instance: BaseOperator,
location_id: str,
resource_id: str,
resource_id: str | None,
project_id: str | None,
):
task_instance.xcom_push(
Expand Down
25 changes: 14 additions & 11 deletions airflow/providers/google/cloud/operators/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(
self,
*,
zone: str,
resource_id: str,
resource_id: str | None = None,
project_id: str | None = None,
gcp_conn_id: str = "google_cloud_default",
api_version: str = "v1",
Expand Down Expand Up @@ -151,7 +151,8 @@ def __init__(
self.body = body
self.zone = zone
self.request_id = request_id
self.resource_id = self.body["name"] if "name" in body else resource_id
if "name" in body:
resource_id = self.body["name"]
self._field_validator = None # Optional[GcpBodyFieldValidator]
self.retry = retry
self.timeout = timeout
Expand All @@ -163,7 +164,7 @@ def __init__(
)
self._field_sanitizer = GcpBodyFieldSanitizer(GCE_INSTANCE_FIELDS_TO_SANITIZE)
super().__init__(
resource_id=self.resource_id,
resource_id=resource_id,
zone=zone,
project_id=project_id,
gcp_conn_id=gcp_conn_id,
Expand Down Expand Up @@ -332,7 +333,8 @@ def __init__(
self.source_instance_template = source_instance_template
self.body = body
self.zone = zone
self.resource_id = self.body["name"] if "name" in body else resource_id
if "name" in body:
resource_id = self.body["name"]
self.request_id = request_id
self._field_validator = None # Optional[GcpBodyFieldValidator]
self.retry = retry
Expand All @@ -345,7 +347,7 @@ def __init__(
)
self._field_sanitizer = GcpBodyFieldSanitizer(GCE_INSTANCE_FIELDS_TO_SANITIZE)
super().__init__(
resource_id=self.resource_id,
resource_id=resource_id,
zone=zone,
project_id=project_id,
gcp_conn_id=gcp_conn_id,
Expand Down Expand Up @@ -893,7 +895,8 @@ def __init__(
) -> None:
self.body = body
self.request_id = request_id
self.resource_id = self.body["name"] if "name" in body else resource_id
if "name" in body:
resource_id = self.body["name"]
self._field_validator = None # Optional[GcpBodyFieldValidator]
self.retry = retry
self.timeout = timeout
Expand All @@ -907,7 +910,7 @@ def __init__(
super().__init__(
project_id=project_id,
zone="global",
resource_id=self.resource_id,
resource_id=resource_id,
gcp_conn_id=gcp_conn_id,
api_version=api_version,
impersonation_chain=impersonation_chain,
Expand Down Expand Up @@ -1341,7 +1344,7 @@ def __init__(
)
super().__init__(
project_id=project_id,
zone=self.zone,
zone=zone,
resource_id=resource_id,
gcp_conn_id=gcp_conn_id,
api_version=api_version,
Expand Down Expand Up @@ -1477,9 +1480,9 @@ def __init__(
**kwargs,
) -> None:
self.body = body
self.zone = zone
self.request_id = request_id
self.resource_id = self.body["name"] if "name" in body else resource_id
if "name" in body:
resource_id = self.body["name"]
self._field_validator = None # Optional[GcpBodyFieldValidator]
self.retry = retry
self.timeout = timeout
Expand All @@ -1492,7 +1495,7 @@ def __init__(
super().__init__(
project_id=project_id,
zone=zone,
resource_id=self.resource_id,
resource_id=resource_id,
gcp_conn_id=gcp_conn_id,
api_version=api_version,
impersonation_chain=impersonation_chain,
Expand Down

0 comments on commit 046fb49

Please sign in to comment.