Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataprocHook: Remove deprecated function submit #23389

Merged
merged 1 commit into from
May 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions airflow/providers/google/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Breaking changes

* ``DataprocHook``: order of parameters in ``wait_for_job`` function has changed.

* ``DataprocHook``: Remove function ``submit``. Please use ``submit_job``

* ``DataprocSubmitJobOperator``: order of parameters has changed.

* ``CloudDatastoreImportEntitiesOperator`` : Remove ``xcom_push``. Please use ``BaseOperator.do_xcom_push``
Expand Down
24 changes: 1 addition & 23 deletions airflow/providers/google/cloud/hooks/dataproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

import time
import uuid
import warnings
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union

from google.api_core.client_options import ClientOptions
from google.api_core.exceptions import ServerError
Expand Down Expand Up @@ -767,27 +766,6 @@ def submit_job(
metadata=metadata,
)

def submit(
self,
project_id: str,
job: dict,
region: str = 'global',
job_error_states: Optional[Iterable[str]] = None,
) -> None:
"""
Submits Google Cloud Dataproc job.

:param project_id: The id of Google Cloud Dataproc project.
:param job: The job to be submitted
:param region: The region of Google Dataproc cluster.
:param job_error_states: Job states that should be considered error states.
"""
# TODO: Remover one day
warnings.warn("This method is deprecated. Please use `submit_job`", DeprecationWarning, stacklevel=2)
job_object = self.submit_job(region=region, project_id=project_id, job=job)
job_id = job_object.reference.job_id
self.wait_for_job(job_id=job_id, region=region, project_id=project_id)

@GoogleBaseHook.fallback_to_default_project_id
def cancel_job(
self,
Expand Down
9 changes: 0 additions & 9 deletions tests/providers/google/cloud/hooks/test_dataproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,6 @@ def test_submit_job_missing_region(self, mock_client):
with pytest.raises(TypeError):
self.hook.submit_job(job=JOB, project_id=GCP_PROJECT)

@mock.patch(DATAPROC_STRING.format("DataprocHook.wait_for_job"))
@mock.patch(DATAPROC_STRING.format("DataprocHook.submit_job"))
def test_submit(self, mock_submit_job, mock_wait_for_job):
mock_submit_job.return_value.reference.job_id = JOB_ID
with pytest.warns(DeprecationWarning):
self.hook.submit(project_id=GCP_PROJECT, job=JOB, region=GCP_LOCATION)
mock_submit_job.assert_called_once_with(region=GCP_LOCATION, project_id=GCP_PROJECT, job=JOB)
mock_wait_for_job.assert_called_once_with(region=GCP_LOCATION, project_id=GCP_PROJECT, job_id=JOB_ID)

@mock.patch(DATAPROC_STRING.format("DataprocHook.get_job_client"))
def test_cancel_job(self, mock_client):
self.hook.cancel_job(region=GCP_LOCATION, job_id=JOB_ID, project_id=GCP_PROJECT)
Expand Down