Coverage for airflow/hooks.py: 50%

# Coverage for airflow/hooks.py : 50%

## 16 statements 8 run 8 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | # -*- coding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import sys # ------------------------------------------------------------------------ # # #TODO #FIXME Airflow 2.0 # # Old import machinary below. # # This is deprecated but should be kept until Airflow 2.0 # for compatibility. # # ------------------------------------------------------------------------ # Imports the hooks dynamically while keeping the package API clean, # abstracting the underlying modules _hooks = { 'base_hook': ['BaseHook'], 'hive_hooks': [ 'HiveCliHook', 'HiveMetastoreHook', 'HiveServer2Hook', ], 'hdfs_hook': ['HDFSHook'], 'webhdfs_hook': ['WebHDFSHook'], 'pig_hook': ['PigCliHook'], 'mysql_hook': ['MySqlHook'], 'postgres_hook': ['PostgresHook'], 'presto_hook': ['PrestoHook'], 'samba_hook': ['SambaHook'], 'sqlite_hook': ['SqliteHook'], 'S3_hook': ['S3Hook'], 'http_hook': ['HttpHook'], 'druid_hook': ['DruidHook'], 'jdbc_hook': ['JdbcHook'], 'dbapi_hook': ['DbApiHook'], 'mssql_hook': ['MsSqlHook'], 'oracle_hook': ['OracleHook'], } import os as _os if not _os.environ.get('AIRFLOW_USE_NEW_IMPORTS', False): from airflow.utils.helpers import AirflowImporter airflow_importer = AirflowImporter(sys.modules[__name__], _hooks) def _integrate_plugins(): """Integrate plugins to the context""" import sys from airflow.plugins_manager import hooks as _hooks for _hook_module in _hooks: sys.modules[_hook_module.__name__] = _hook_module globals()[_hook_module._name] = _hook_module ########################################################## # TODO FIXME Remove in Airflow 2.0 if not _os.environ.get('AIRFLOW_USE_NEW_IMPORTS', False): from zope.deprecation import deprecated as _deprecated for _hook in _hook_module._objects: globals()[_hook.__name__] = _deprecated( _hook, "Importing plugin hook '{i}' directly from " "'airflow.hooks' has been deprecated. Please " "import from 'airflow.hooks.[plugin_module]' " "instead. Support for direct imports will be dropped " "entirely in Airflow 2.0.".format(i=_hook))