Skip to content

Commit

Permalink
Remove some useless try/except from providers code (#33967)
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-awala committed Aug 31, 2023
1 parent 17d031d commit 0a5e228
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
20 changes: 8 additions & 12 deletions airflow/providers/amazon/aws/hooks/redshift_cluster.py
Expand Up @@ -21,7 +21,6 @@
from typing import Any, Sequence

import botocore.exceptions
from botocore.exceptions import ClientError

from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseAsyncHook, AwsBaseHook
Expand Down Expand Up @@ -70,17 +69,14 @@ def create_cluster(
for the cluster that is being created.
:param params: Remaining AWS Create cluster API params.
"""
try:
response = self.get_conn().create_cluster(
ClusterIdentifier=cluster_identifier,
NodeType=node_type,
MasterUsername=master_username,
MasterUserPassword=master_user_password,
**params,
)
return response
except ClientError as e:
raise e
response = self.get_conn().create_cluster(
ClusterIdentifier=cluster_identifier,
NodeType=node_type,
MasterUsername=master_username,
MasterUserPassword=master_user_password,
**params,
)
return response

# TODO: Wrap create_cluster_snapshot
def cluster_status(self, cluster_identifier: str) -> str:
Expand Down
13 changes: 4 additions & 9 deletions airflow/providers/dbt/cloud/hooks/dbt.py
Expand Up @@ -254,15 +254,10 @@ async def get_job_status(
:param include_related: Optional. List of related fields to pull with the run.
Valid values are "trigger", "job", "repository", and "environment".
"""
try:
self.log.info("Getting the status of job run %s.", run_id)
response = await self.get_job_details(
run_id, account_id=account_id, include_related=include_related
)
job_run_status: int = response["data"]["status"]
return job_run_status
except Exception as e:
raise e
self.log.info("Getting the status of job run %s.", run_id)
response = await self.get_job_details(run_id, account_id=account_id, include_related=include_related)
job_run_status: int = response["data"]["status"]
return job_run_status

@cached_property
def connection(self) -> Connection:
Expand Down
15 changes: 6 additions & 9 deletions airflow/providers/google/cloud/hooks/cloud_sql.py
Expand Up @@ -437,15 +437,12 @@ async def get_operation_name(self, project_id: str, operation_name: str, session

async def get_operation(self, project_id: str, operation_name: str):
async with ClientSession() as session:
try:
operation = await self.get_operation_name(
project_id=project_id,
operation_name=operation_name,
session=session,
)
operation = await operation.json(content_type=None)
except HttpError as e:
raise e
operation = await self.get_operation_name(
project_id=project_id,
operation_name=operation_name,
session=session,
)
operation = await operation.json(content_type=None)
return operation


Expand Down

0 comments on commit 0a5e228

Please sign in to comment.