def get_default_loggin_config(): from airflow.version import version as AIRFLOW_VERSION AIRFLOW_VERSION_PARTS = AIRFLOW_VERSION.split(".") AIRFLOW_VERSION_PARTS = [int(v) for v in AIRFLOW_VERSION_PARTS] AIRFLOW_MAJOR_VERSION = AIRFLOW_VERSION_PARTS[0] """Returns the airflow default logging config from the settings. Start the ariflow system. settings.initialize should be called if the logging configuration is to be reset? """ config_env_name = ( "AIRFLOW__LOGGING__LOGGING_CONFIG_CLASS" if AIRFLOW_MAJOR_VERSION > 1 else "AIRFLOW__CORE__LOGGING_CONFIG_CLASS" ) action_logging_config_env = os.environ.get(config_env_name, None) os.environ[config_env_name] = "airflow_db_logger.shell_logging_config.SIMPLE_LOGGING_CONFIG" from airflow.config_templates.airflow_local_settings import DEFAULT_LOGGING_CONFIG # noqa if action_logging_config_env is not None: os.environ[config_env_name] = action_logging_config_env return DEFAULT_LOGGING_CONFIG
import os import os.path import logging import mimetypes from flask import abort, jsonify, request, send_file from airflow.version import version from airflow_code_editor.commons import HTTP_404_NOT_FOUND from airflow_code_editor.utils import ( git_absolute_path, execute_git_command, normalize_path, ) __all__ = ['AbstractCodeEditorView'] AIRFLOW_MAJOR_VERSION = int(version.split('.')[0]) class AbstractCodeEditorView(object): airflow_major_version = AIRFLOW_MAJOR_VERSION def _index(self): return self._render('index') def _save(self, path=None): try: data = request.form['data'] # Newline fix (remove cr) data = data.replace('\r', '').rstrip() fullpath = git_absolute_path(path) os.makedirs(os.path.dirname(fullpath), exist_ok=True)
def __init__(self, *args, **kwargs): self.backends: dict[tuple[str, Optional[str]], DbtBackend] = {} if airflow_version.split(".")[0] == "1": kwargs["source"] = None super().__init__(*args, **kwargs)
import sys import os import logging import warnings import colorlog from typing import Union, List from typing import Type from enum import Enum from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, scoped_session from sqlalchemy.pool import NullPool, QueuePool from airflow.configuration import conf, AirflowConfigException, log from airflow.version import version as AIRFLOW_VERSION AIRFLOW_CONFIG_SECTION_NAME = "db_logger" AIRFLOW_VERSION_PARTS = AIRFLOW_VERSION.split(".") AIRFLOW_VERSION_PARTS = [int(v) for v in AIRFLOW_VERSION_PARTS] AIRFLOW_MAJOR_VERSION = AIRFLOW_VERSION_PARTS[0] def conf_get_no_warnings_no_errors(*args, **kwargs): old_level = log.level log.level = logging.ERROR try: val = conf.get(*args, **kwargs) except AirflowConfigException: val = None log.level = old_level return val