fix(ingest): fail gracefully when lookml used on old python versions (#2614)

This commit is contained in:
Harshal Sheth 2021-05-26 17:16:17 -07:00 committed by GitHub
parent 8d53924892
commit acef397ece
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 10 deletions

View File

@ -84,14 +84,12 @@ plugins: Dict[str, Set[str]] = {
"oracle": sql_common | {"cx_Oracle"},
"ldap": {"python-ldap>=2.4"},
"looker": {"looker-sdk==21.6.0"},
"lookml": {"lkml>=1.1.0", "sql-metadata==1.12.0"},
"druid": sql_common | {"pydruid>=0.6.2"},
"mongodb": {"pymongo>=3.11"},
"superset": {"requests"},
"glue": {"boto3"},
}
if is_py37_or_newer:
plugins["lookml"] = {"lkml>=1.1.0", "sql-metadata==1.12.0"}
base_dev_requirements = {
*base_requirements,
@ -130,6 +128,7 @@ base_dev_requirements = {
}
if is_py37_or_newer:
# The lookml plugin only works on Python 3.7 or newer.
base_dev_requirements = base_dev_requirements.union(
{dependency for plugin in ["lookml"] for dependency in plugins[plugin]}
)
@ -161,6 +160,7 @@ entry_points = {
"kafka-connect = datahub.ingestion.source.kafka_connect:KafkaConnectSource",
"ldap = datahub.ingestion.source.ldap:LDAPSource",
"looker = datahub.ingestion.source.looker:LookerDashboardSource",
"lookml = datahub.ingestion.source.lookml:LookMLSource",
"mongodb = datahub.ingestion.source.mongodb:MongoDBSource",
"mssql = datahub.ingestion.source.mssql:SQLServerSource",
"mysql = datahub.ingestion.source.mysql:MySQLSource",
@ -179,11 +179,6 @@ entry_points = {
"apache_airflow_provider": ["provider_info=datahub_provider:get_provider_info"],
}
if is_py37_or_newer:
entry_points["datahub.ingestion.source.plugins"].append(
"lookml = datahub.ingestion.source.lookml:LookMLSource"
)
setuptools.setup(
# Package metadata.

View File

@ -40,6 +40,7 @@ def local_docker() -> None:
@check.command()
@click.option(
"--verbose",
"-v",
type=bool,
is_flag=True,
default=False,

View File

@ -10,10 +10,10 @@ from enum import Enum
from pathlib import Path
from typing import Dict, Iterable, List, Optional, Tuple
if sys.version_info[1] >= 7:
if sys.version_info >= (3, 7):
import lkml
else:
logging.warning("This plugin requres Python 3.7 or newer.")
raise ModuleNotFoundError("The lookml plugin requires Python 3.7 or newer.")
from sql_metadata import get_query_tables
from datahub.configuration import ConfigModel