def _profile_found(self): if not self.raw_profile_data: return red('ERROR not found') assert self.raw_profile_data is not None if self.profile_name in self.raw_profile_data: return green('OK found') else: return red('ERROR not found')
def _target_found(self): requirements = (self.raw_profile_data and self.profile_name and self.target_name) if not requirements: return red('ERROR not found') # mypy appeasement, we checked just above assert self.raw_profile_data is not None assert self.profile_name is not None assert self.target_name is not None if self.profile_name not in self.raw_profile_data: return red('ERROR not found') profiles = self.raw_profile_data[self.profile_name]['outputs'] if self.target_name not in profiles: return red('ERROR not found') return green('OK found')
def _connection_result(self): result = self.attempt_connection(self.profile) if result is not None: self.messages.append(result) self.any_failure = True return red('ERROR') return green('OK connection ok')
def print_skip_caused_by_error(model, schema: str, relation: str, index: int, num_models: int, result) -> None: msg = ('SKIP relation {}.{} due to ephemeral model error'.format( schema, relation)) print_fancy_output_line(msg, ui.red('ERROR SKIP'), logger.error, index, num_models) print_run_result_error(result, newline=False)
def test_git(self): try: dbt.clients.system.run_cmd(os.getcwd(), ['git', '--help']) except dbt.exceptions.ExecutableError as exc: self.messages.append('Error from git --help: {!s}'.format(exc)) return red('ERROR') return green('OK found')
def print_cancel_line(model) -> None: msg = 'CANCEL query {}'.format(model) print_fancy_output_line(msg, ui.red('CANCEL'), logger.error, index=None, total=None)
def _handle_internal_exception(self, e, ctx): build_path = self.node.build_path prefix = 'Internal error executing {}'.format(build_path) error = "{prefix}\n{error}\n\n{note}".format( prefix=ui.red(prefix), error=str(e).strip(), note=INTERNAL_ERROR_STRING) logger.debug(error, exc_info=True) return str(e)
def _handle_generic_exception(self, e, ctx): node_description = self.node.build_path if node_description is None: node_description = self.node.unique_id prefix = "Unhandled error while executing {}".format(node_description) error = "{prefix}\n{error}".format(prefix=ui.red(prefix), error=str(e).strip()) logger.error(error) logger.debug('', exc_info=True) return str(e)
def get_printable_result(result, success: str, error: str) -> Tuple[str, str, Callable]: if result.status == NodeStatus.Error: info = 'ERROR {}'.format(error) status = ui.red(result.status.upper()) logger_fn = logger.error else: info = 'OK {}'.format(success) status = ui.green(result.message) logger_fn = logger.info return info, status, logger_fn
def get_printable_result(result, success: str, error: str) -> Tuple[str, str, Callable]: if result.error is not None: info = 'ERROR {}'.format(error) status = ui.red(result.status) logger_fn = logger.error else: info = 'OK {}'.format(success) status = ui.green(result.status) logger_fn = logger.info return info, status, logger_fn
def _load_profile(self): if not os.path.exists(self.profile_path): self.profile_fail_details = FILE_NOT_FOUND self.messages.append(MISSING_PROFILE_MESSAGE.format( path=self.profile_path, url=ProfileConfigDocs )) return red('ERROR not found') try: raw_profile_data = load_yaml_text( dbt.clients.system.load_file_contents(self.profile_path) ) except Exception: pass # we'll report this when we try to load the profile for real else: if isinstance(raw_profile_data, dict): self.raw_profile_data = raw_profile_data profile_errors = [] profile_names = self._choose_profile_names() renderer = ProfileRenderer(generate_base_context(self.cli_vars)) for profile_name in profile_names: try: profile: Profile = QueryCommentedProfile.render_from_args( self.args, renderer, profile_name ) except dbt.exceptions.DbtConfigError as exc: profile_errors.append(str(exc)) else: if len(profile_names) == 1: # if a profile was specified, set it on the task self.target_name = self._choose_target_name(profile_name) self.profile = profile if profile_errors: self.profile_fail_details = '\n\n'.join(profile_errors) return red('ERROR invalid') return green('OK found and valid')
def _load_project(self): if not os.path.exists(self.project_path): self.project_fail_details = FILE_NOT_FOUND return red('ERROR not found') if self.profile is None: ctx = generate_base_context(self.cli_vars) else: ctx = generate_target_context(self.profile, self.cli_vars) renderer = DbtProjectYamlRenderer(ctx) try: self.project = Project.from_project_root( self.project_dir, renderer, verify_version=getattr(self.args, 'version_check', False), ) except dbt.exceptions.DbtConfigError as exc: self.project_fail_details = str(exc) return red('ERROR invalid') return green('OK found and valid')
def print_end_of_run_summary(num_errors: int, num_warnings: int, keyboard_interrupt: bool = False) -> None: error_plural = utils.pluralize(num_errors, 'error') warn_plural = utils.pluralize(num_warnings, 'warning') if keyboard_interrupt: message = ui.yellow('Exited because of keyboard interrupt.') elif num_errors > 0: message = ui.red("Completed with {} and {}:".format( error_plural, warn_plural)) elif num_warnings > 0: message = ui.yellow('Completed with {}:'.format(warn_plural)) else: message = ui.green('Completed successfully') with TextOnly(): logger.info('') logger.info('{}'.format(message))