diff --git a/hq_superset/models.py b/hq_superset/models.py index 175a314..904c9df 100644 --- a/hq_superset/models.py +++ b/hq_superset/models.py @@ -7,6 +7,7 @@ ) from cryptography.fernet import MultiFernet from superset import db +from superset_config import SKIP_DATASET_CHANGE_FOR_DOMAINS from hq_superset.const import OAUTH2_DATABASE_NAME from hq_superset.exceptions import TableMissing @@ -16,6 +17,15 @@ get_hq_database, ) +import logging +logger = logging.getLogger(__name__) + +# constant here instead of const due to +# circular import error with config in const +SKIP_DATASET_CHANGE_FOR_SCHEMAS = [ + f"hqdomain_{domain_name}" + for domain_name in SKIP_DATASET_CHANGE_FOR_DOMAINS +] @dataclass class DataSetChange: @@ -41,6 +51,10 @@ def update_dataset(self): raise TableMissing(f'{self.data_source_id} table not found.') table = sqla_table.get_sqla_table_object() + if table.schema and table.schema in SKIP_DATASET_CHANGE_FOR_SCHEMAS: + logger.info("Skipped change for schema {0}".format(table.schema)) + return + with ( database.get_sqla_engine_with_context() as engine, engine.connect() as connection, diff --git a/hq_superset/tests/config_for_tests.py b/hq_superset/tests/config_for_tests.py index d70625f..46f23c2 100644 --- a/hq_superset/tests/config_for_tests.py +++ b/hq_superset/tests/config_for_tests.py @@ -67,3 +67,4 @@ FLASK_APP_MUTATOR = flask_app_mutator CUSTOM_SECURITY_MANAGER = oauth.CommCareSecurityManager USER_DOMAIN_ROLE_EXPIRY = 60 # minutes +SKIP_DATASET_CHANGE_FOR_DOMAINS = [] diff --git a/superset_config.example.py b/superset_config.example.py index e3e1341..809e0e7 100644 --- a/superset_config.example.py +++ b/superset_config.example.py @@ -190,4 +190,4 @@ class CeleryConfig: } USER_DOMAIN_ROLE_EXPIRY = 60 # minutes - +SKIP_DATASET_CHANGE_FOR_DOMAINS = []