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

Airflow upgrade_check gives false positives on DbApi functions implementations check #14541

Closed
amaraliou opened this issue Mar 1, 2021 · 8 comments
Assignees
Labels
kind:bug This is a clearly a bug upgrade-check upgrade-check CLI

Comments

@amaraliou
Copy link

amaraliou commented Mar 1, 2021

Apache Airflow version:
1.10.14

Kubernetes version (if you are using kubernetes) (use kubectl version):
N/A

Environment:

  • Cloud provider or hardware configuration: GCP
  • OS (e.g. from /etc/os-release): Ubuntu 18.04.4 LTS
  • Kernel (e.g. uname -a): N/A
  • Install tools: pip

What happened:

Running airflow upgrade_check threw the following warnings:

  1.  Class <class 'airflow.hooks.http_hook.HttpHook'> incorrectly implements the function run while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
  2.  Class <class 'airflow.contrib.hooks.bigquery_hook.BigQueryHook'> incorrectly implements the function get_pandas_df while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
  3.  Class <class 'airflow.contrib.hooks.bigquery_hook.BigQueryHook'> incorrectly implements the function run while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
  4.  Class <class 'airflow.contrib.hooks.bigquery_hook.BigQueryHook'> incorrectly implements the function get_records while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
  5.  Class <class '_hooks.gc_bigquery_hook.BigQueryStandardHook'> incorrectly implements the function get_pandas_df while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
  6.  Class <class '_hooks.gc_bigquery_hook.BigQueryStandardHook'> incorrectly implements the function run while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
  7.  Class <class '_hooks.gc_bigquery_hook.BigQueryStandardHook'> incorrectly implements the function get_records while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
  8.  Class <class 'unusual_prefix_9358643817187292af016429303a09afd4152fc5_gc_bigquery_hook.BigQueryStandardHook'> incorrectly implements the function get_pandas_df while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
  9.  Class <class 'unusual_prefix_9358643817187292af016429303a09afd4152fc5_gc_bigquery_hook.BigQueryStandardHook'> incorrectly implements the function run while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
 10.  Class <class 'unusual_prefix_9358643817187292af016429303a09afd4152fc5_gc_bigquery_hook.BigQueryStandardHook'> incorrectly implements the function get_records while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
 11.  Class <class '_hooks.gc_bigquery_hook.GCBigQueryHook'> incorrectly implements the function get_pandas_df while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
 12.  Class <class '_hooks.gc_bigquery_hook.GCBigQueryHook'> incorrectly implements the function run while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
 13.  Class <class '_hooks.gc_bigquery_hook.GCBigQueryHook'> incorrectly implements the function get_records while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
 14.  Class <class 'unusual_prefix_9358643817187292af016429303a09afd4152fc5_gc_bigquery_hook.GCBigQueryHook'> incorrectly implements the function get_pandas_df while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
 15.  Class <class 'unusual_prefix_9358643817187292af016429303a09afd4152fc5_gc_bigquery_hook.GCBigQueryHook'> incorrectly implements the function run while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead
 16.  Class <class 'unusual_prefix_9358643817187292af016429303a09afd4152fc5_gc_bigquery_hook.GCBigQueryHook'> incorrectly implements the function get_records while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead

The custom hooks all inherit from BigQueryHook. Looking at the code, it inherits both DbApiHook and GoogleCloudBaseHook which inherits BaseHook. I also noticed that the same BigQueryHook implementation appears in the 2.0-stable branch so this is probably a false positive. The warning (1) is already fixed by #14344.

What you expected to happen:

No warnings

How to reproduce it: N/A

@amaraliou amaraliou added the kind:bug This is a clearly a bug label Mar 1, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Mar 1, 2021

Thanks for opening your first issue here! Be sure to follow the issue template!

@vikramkoka vikramkoka added the upgrade-check upgrade-check CLI label Mar 2, 2021
@omar-binary
Copy link

any luck with this? 👆

@potiuk
Copy link
Member

potiuk commented Jun 18, 2021

@kaxil - maybe we should add this one as well to the last upgrade_check release? Sounds like pretty annoying warning for popular operators?

@ephraimbuddy
Copy link
Contributor

any luck with this? 👆

What version of the upgrade-check are you using because I believe this was resolved in #14344

@omar-binary
Copy link

omar-binary commented Jun 18, 2021

I can still see it in V1.3.0

Apache Airflow version:
1.10.15

airflow@d9b97fe4d7cc:/opt/airflow$ airflow upgrade_check --version
1.3.0
airflow@d9b97fe4d7cc:/opt/airflow$ airflow upgrade_check --config /opt/airflow/plugins/upgrade.yml
Using config file: /opt/airflow/plugins/upgrade.yml

====================================================================================== STATUS ======================================================================================

Check for latest versions of apache-airflow and checker...................................................................................................................SUCCESS
Remove airflow.AirflowMacroPlugin class...................................................................................................................................SUCCESS
Ensure users are not using custom metaclasses in custom operators.........................................................................................................SUCCESS
Chain between DAG and operator not allowed................................................................................................................................SUCCESS
Connection.conn_type is not nullable......................................................................................................................................SUCCESS
Custom Executors now require full path....................................................................................................................................SUCCESS
/home/airflow/.local/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/bigquery.py:119: DeprecationWarning: This method will be deprecated. Please use `BigQueryHook.get_client` method
  warnings.warn(
Hooks that run DB functions must inherit from DBApiHook...................................................................................................................FAIL
Fernet is enabled by default..............................................................................................................................................SUCCESS
GCP service account key deprecation.......................................................................................................................................SUCCESS
Unify hostname_callable option in core section............................................................................................................................SUCCESS
Changes in import paths of hooks, operators, sensors and others...........................................................................................................SUCCESS
Legacy UI is deprecated by default........................................................................................................................................SUCCESS
Logging configuration has been moved to new section.......................................................................................................................SUCCESS
Removal of Mesos Executor.................................................................................................................................................SUCCESS
No additional argument allowed in BaseOperator............................................................................................................................SUCCESS
SendGrid email uses old airflow.contrib module............................................................................................................................SUCCESS
Check Spark JDBC Operator default connection name.........................................................................................................................SUCCESS
Changes in import path of remote task handlers............................................................................................................................SUCCESS
Connection.conn_id is not unique..........................................................................................................................................SUCCESS
Use CustomSQLAInterface instead of SQLAInterface for custom data models...................................................................................................SUCCESS
Found 1 problem.

================================================================================= RECOMMENDATIONS ==================================================================================

Hooks that run DB functions must inherit from DBApiHook
-------------------------------------------------------
Hooks that run DB functions must inherit from DBApiHook instead of BaseHook

Problems:

  1.  Class <class 'airflow.providers.google.cloud.hooks.bigquery.BigQueryHook'> incorrectly implements the function get_pandas_df while inheriting from BaseHook. Please make this class inherit from airflow.hooks.db_api_hook.DbApiHook instead

airflow@d9b97fe4d7cc:/opt/airflow$ 

@kaxil
Copy link
Member

kaxil commented Jun 19, 2021

PR: #16543

@kaxil
Copy link
Member

kaxil commented Jun 21, 2021

Closed by #16543 .

Will cut 1.4.0rc2 today and start the vote to release it

@eladkal
Copy link
Contributor

eladkal commented Jun 26, 2021

fixed by #16543 and released in 1.4.0

@eladkal eladkal closed this as completed Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug This is a clearly a bug upgrade-check upgrade-check CLI
Projects
None yet
Development

No branches or pull requests

7 participants