Skip to content

Commit fb6b2d1

Browse files
author
Rafał Harabień
authored
Make project_id argument optional in all dataproc operators (#21866)
`DataprocHook` handles `project_id=None` in `@GoogleBaseHook.fallback_to_default_project_id` decorator. In some operators `project_id` was already optional. Make it optional for all.
1 parent e856aba commit fb6b2d1

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

airflow/providers/google/cloud/operators/dataproc.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,9 @@ class DataprocDeleteClusterOperator(BaseOperator):
756756
"""
757757
Deletes a cluster in a project.
758758
759-
:param project_id: Required. The ID of the Google Cloud project that the cluster belongs to (templated).
760759
:param region: Required. The Cloud Dataproc region in which to handle the request (templated).
761760
:param cluster_name: Required. The cluster name (templated).
761+
:param project_id: Optional. The ID of the Google Cloud project that the cluster belongs to (templated).
762762
:param cluster_uuid: Optional. Specifying the ``cluster_uuid`` means the RPC should fail
763763
if cluster with specified UUID does not exist.
764764
:param request_id: Optional. A unique id used to identify the request. If the server receives two
@@ -785,9 +785,9 @@ class DataprocDeleteClusterOperator(BaseOperator):
785785
def __init__(
786786
self,
787787
*,
788-
project_id: str,
789788
region: str,
790789
cluster_name: str,
790+
project_id: Optional[str] = None,
791791
cluster_uuid: Optional[str] = None,
792792
request_id: Optional[str] = None,
793793
retry: Optional[Retry] = None,
@@ -1499,7 +1499,7 @@ class DataprocCreateWorkflowTemplateOperator(BaseOperator):
14991499
"""
15001500
Creates new workflow template.
15011501
1502-
:param project_id: Required. The ID of the Google Cloud project the cluster belongs to.
1502+
:param project_id: Optional. The ID of the Google Cloud project the cluster belongs to.
15031503
:param region: Required. The Cloud Dataproc region in which to handle the request.
15041504
:param location: (To be deprecated). The Cloud Dataproc region in which to handle the request.
15051505
:param template: The Dataproc workflow template to create. If a dict is provided,
@@ -1519,8 +1519,8 @@ def __init__(
15191519
self,
15201520
*,
15211521
template: Dict,
1522-
project_id: str,
15231522
region: Optional[str] = None,
1523+
project_id: Optional[str] = None,
15241524
location: Optional[str] = None,
15251525
retry: Optional[Retry] = None,
15261526
timeout: Optional[float] = None,
@@ -1759,7 +1759,7 @@ class DataprocSubmitJobOperator(BaseOperator):
17591759
"""
17601760
Submits a job to a cluster.
17611761
1762-
:param project_id: Required. The ID of the Google Cloud project that the job belongs to.
1762+
:param project_id: Optional. The ID of the Google Cloud project that the job belongs to.
17631763
:param region: Required. The Cloud Dataproc region in which to handle the request.
17641764
:param location: (To be deprecated). The Cloud Dataproc region in which to handle the request.
17651765
:param job: Required. The job resource.
@@ -1798,8 +1798,8 @@ class DataprocSubmitJobOperator(BaseOperator):
17981798
def __init__(
17991799
self,
18001800
*,
1801-
project_id: str,
18021801
job: Dict,
1802+
project_id: Optional[str] = None,
18031803
region: Optional[str] = None,
18041804
location: Optional[str] = None,
18051805
request_id: Optional[str] = None,
@@ -1876,8 +1876,8 @@ class DataprocUpdateClusterOperator(BaseOperator):
18761876
"""
18771877
Updates a cluster in a project.
18781878
1879-
:param project_id: Required. The ID of the Google Cloud project the cluster belongs to.
18801879
:param region: Required. The Cloud Dataproc region in which to handle the request.
1880+
:param project_id: Optional. The ID of the Google Cloud project the cluster belongs to.
18811881
:param location: (To be deprecated). The Cloud Dataproc region in which to handle the request.
18821882
:param cluster_name: Required. The cluster name.
18831883
:param cluster: Required. The changes to the cluster.
@@ -1993,7 +1993,7 @@ class DataprocCreateBatchOperator(BaseOperator):
19931993
"""
19941994
Creates a batch workload.
19951995
1996-
:param project_id: Required. The ID of the Google Cloud project that the cluster belongs to. (templated)
1996+
:param project_id: Optional. The ID of the Google Cloud project that the cluster belongs to. (templated)
19971997
:param region: Required. The Cloud Dataproc region in which to handle the request. (templated)
19981998
:param batch: Required. The batch to create. (templated)
19991999
:param batch_id: Optional. The ID to use for the batch, which will become the final component
@@ -2031,7 +2031,7 @@ def __init__(
20312031
self,
20322032
*,
20332033
region: Optional[str] = None,
2034-
project_id: str,
2034+
project_id: Optional[str] = None,
20352035
batch: Union[Dict, Batch],
20362036
batch_id: Optional[str] = None,
20372037
request_id: Optional[str] = None,
@@ -2101,8 +2101,8 @@ class DataprocDeleteBatchOperator(BaseOperator):
21012101
:param batch_id: Required. The ID to use for the batch, which will become the final component
21022102
of the batch's resource name.
21032103
This value must be 4-63 characters. Valid characters are /[a-z][0-9]-/.
2104-
:param project_id: Required. The ID of the Google Cloud project that the cluster belongs to.
21052104
:param region: Required. The Cloud Dataproc region in which to handle the request.
2105+
:param project_id: Optional. The ID of the Google Cloud project that the cluster belongs to.
21062106
:param retry: A retry object used to retry requests. If ``None`` is specified, requests will not be
21072107
retried.
21082108
:param timeout: The amount of time, in seconds, to wait for the request to complete. Note that if
@@ -2126,7 +2126,7 @@ def __init__(
21262126
*,
21272127
batch_id: str,
21282128
region: str,
2129-
project_id: str,
2129+
project_id: Optional[str] = None,
21302130
retry: Optional[Retry] = None,
21312131
timeout: Optional[float] = None,
21322132
metadata: Sequence[Tuple[str, str]] = (),
@@ -2165,8 +2165,8 @@ class DataprocGetBatchOperator(BaseOperator):
21652165
:param batch_id: Required. The ID to use for the batch, which will become the final component
21662166
of the batch's resource name.
21672167
This value must be 4-63 characters. Valid characters are /[a-z][0-9]-/.
2168-
:param project_id: Required. The ID of the Google Cloud project that the cluster belongs to.
21692168
:param region: Required. The Cloud Dataproc region in which to handle the request.
2169+
:param project_id: Optional. The ID of the Google Cloud project that the cluster belongs to.
21702170
:param retry: A retry object used to retry requests. If ``None`` is specified, requests will not be
21712171
retried.
21722172
:param timeout: The amount of time, in seconds, to wait for the request to complete. Note that if
@@ -2191,7 +2191,7 @@ def __init__(
21912191
*,
21922192
batch_id: str,
21932193
region: str,
2194-
project_id: str,
2194+
project_id: Optional[Retry] = None,
21952195
retry: Optional[Retry] = None,
21962196
timeout: Optional[float] = None,
21972197
metadata: Sequence[Tuple[str, str]] = (),
@@ -2230,8 +2230,8 @@ class DataprocListBatchesOperator(BaseOperator):
22302230
"""
22312231
Lists batch workloads.
22322232
2233-
:param project_id: Required. The ID of the Google Cloud project that the cluster belongs to.
22342233
:param region: Required. The Cloud Dataproc region in which to handle the request.
2234+
:param project_id: Optional. The ID of the Google Cloud project that the cluster belongs to.
22352235
:param page_size: Optional. The maximum number of batches to return in each response. The service may
22362236
return fewer than this value. The default page size is 20; the maximum page size is 1000.
22372237
:param page_token: Optional. A page token received from a previous ``ListBatches`` call.

airflow/providers/google/cloud/sensors/dataproc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class DataprocJobSensor(BaseSensorOperator):
3636
"""
3737
Check for the state of a previously submitted Dataproc job.
3838
39-
:param project_id: The ID of the google cloud project in which
40-
to create the cluster. (templated)
4139
:param dataproc_job_id: The Dataproc job ID to poll. (templated)
4240
:param region: Required. The Cloud Dataproc region in which to handle the request. (templated)
41+
:param project_id: The ID of the google cloud project in which
42+
to create the cluster. (templated)
4343
:param location: (To be deprecated). The Cloud Dataproc region in which to handle the request. (templated)
4444
:param gcp_conn_id: The connection ID to use connecting to Google Cloud Platform.
4545
:param wait_timeout: How many seconds wait for job to be ready.
@@ -51,9 +51,9 @@ class DataprocJobSensor(BaseSensorOperator):
5151
def __init__(
5252
self,
5353
*,
54-
project_id: str,
5554
dataproc_job_id: str,
5655
region: Optional[str] = None,
56+
project_id: Optional[str] = None,
5757
location: Optional[str] = None,
5858
gcp_conn_id: str = 'google_cloud_default',
5959
wait_timeout: Optional[int] = None,

0 commit comments

Comments
 (0)