Apache Airflow Provider(s)
google
Versions of Apache Airflow Providers
No response
Apache Airflow version
3.2.0
Operating System
Windows(Local Development)
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
What happened
In The Operator Bigtable.py contains several try/except block that are not required and not expected in Operator Level as it Should be handled at Hook Level.
Moreover The Exceptions raised at the Operator level are already Handled at the Hook Level. So what's the point of duplicating it in Operator Level. Let me take an example here
Bigtable.py operator file contains one class BigtableDeleteInstanceOperator which has a method
` def execute(self, context: Context) -> None:
hook = BigtableHook(
gcp_conn_id=self.gcp_conn_id,
impersonation_chain=self.impersonation_chain,
)
try:
hook.delete_instance(project_id=self.project_id, instance_id=self.instance_id)
except google.api_core.exceptions.NotFound:
self.log.info(
"The instance '%s' does not exist in project '%s'. Consider it as deleted",
self.instance_id,
self.project_id,
)
except google.api_core.exceptions.GoogleAPICallError as e:
self.log.error("An error occurred. Exiting.")
raise e`
It raises exception when the instance does not exists which is already handled at the Hook level see below
` @GoogleBaseHook.fallback_to_default_project_id
def delete_instance(self, instance_id: str, project_id: str) -> None:
instance = self.get_instance(instance_id=instance_id, project_id=project_id)
if instance:
instance.delete()
else:
self.log.warning(
"The instance '%s' does not exist in project '%s'. Exiting", instance_id, project_id
)`
Like wise the whole Bigquery.py has lot's of not necessary try/except blocks.
What you think should happen instead
No response
How to reproduce
I will raise a PR for the above mentioned code first and in the next PR I will fix the whole Bigtable.py file.
Anything else
No response
Are you willing to submit PR?
Code of Conduct
Apache Airflow Provider(s)
google
Versions of Apache Airflow Providers
No response
Apache Airflow version
3.2.0
Operating System
Windows(Local Development)
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
What happened
In The Operator
Bigtable.pycontains severaltry/exceptblock that are not required and not expected in Operator Level as it Should be handled at Hook Level.Moreover The Exceptions raised at the Operator level are already Handled at the Hook Level. So what's the point of duplicating it in Operator Level. Let me take an example here
Bigtable.pyoperator file contains one classBigtableDeleteInstanceOperatorwhich has a methodIt raises exception when the instance does not exists which is already handled at the Hook level see below
Like wise the whole
Bigquery.pyhas lot's of not necessary try/except blocks.What you think should happen instead
No response
How to reproduce
I will raise a PR for the above mentioned code first and in the next PR I will fix the whole
Bigtable.pyfile.Anything else
No response
Are you willing to submit PR?
Code of Conduct