예제 #1
0
    def __init__(self,
                 warehouse_yml_dict: dict,
                 warehouse_yml_path: str = 'warehouse-dict'):
        super().__init__(description=warehouse_yml_path)

        if isinstance(warehouse_yml_dict, dict):
            self._push_context(object=warehouse_yml_dict,
                               name=self.description)

            self.warehouse_yml = WarehouseYml()
            self.warehouse_yml.name = self.get_str_required(KEY_NAME)

            EnvVars.load_env_vars(self.warehouse_yml.name)

            connection_dict = self.get_dict_required(KEY_CONNECTION)
            if connection_dict:
                self._push_context(object=connection_dict, name=KEY_CONNECTION)
                self.warehouse_yml.dialect = Dialect.create(self)
                if self.warehouse_yml.dialect:
                    self.warehouse_yml.dialect.validate_connection()
                self._pop_context()

            soda_account_dict = self.get_dict_optional(KEY_SODA_ACCOUNT)
            if soda_account_dict:
                self._push_context(object=soda_account_dict,
                                   name=KEY_SODA_ACCOUNT)
                self.warehouse_yml.soda_host = self.get_str_optional(
                    SODA_KEY_HOST, 'cloud.soda.io')
                self.warehouse_yml.soda_port = self.get_int_optional(
                    SODA_KEY_PORT, 443)
                self.warehouse_yml.soda_protocol = self.get_str_optional(
                    SODA_KEY_PROTOCOL, 'https')
                self.warehouse_yml.soda_api_key_id = self.get_str_required_env(
                    SODA_KEY_API_KEY_ID)
                self.warehouse_yml.soda_api_key_secret = self.get_str_required_env(
                    SODA_KEY_API_KEY_SECRET)
                self._pop_context()

            ingest_dict = self.get_dict_optional(KEY_INGEST)
            if ingest_dict:
                self._push_context(object=ingest_dict, name=KEY_INGEST)
                self.warehouse_yml.dbt_cloud_api_token = self.get_str_optional(
                    DBT_CLOUD_KEY_API_TOKEN)
                self._pop_context()

            self.check_invalid_keys(VALID_WAREHOUSE_KEYS)

        else:
            self.error('No warehouse configuration provided')
예제 #2
0
 def __init__(self, warehouse_connection_dict: dict):
     super().__init__('warehouse')
     self._push_context(warehouse_connection_dict, 'connection')
     self.dialect = Dialect.create(self)
def create_dialect(target):
    return Dialect.create(DialectParser({KEY_WAREHOUSE_TYPE: target}))