示例#1
0
import datetime
import logging

from dbnd._core.utils.project.project_fs import abs_join, relative_path
from dbnd_test_scenarios.data_chaos_monkey.client_scoring_chaos import (
    is_chaos_column_10, )
from targets import target

logger = logging.getLogger(__name__)
_PLUGIN_ROOT = relative_path(__file__, "..", "..")
_PLUGIN_SRC_ROOT = relative_path(__file__)


def scenario_root_path(*path):
    return abs_join(_PLUGIN_ROOT, *path)


def scenario_src_path(*path):
    return abs_join(_PLUGIN_SRC_ROOT, *path)


def test_scenario_path(*path):
    return scenario_root_path("scenarios", *path)


def test_scenario_target(*path):
    return target(test_scenario_path(*path))


def scenario_data_path(*path):
    return scenario_root_path("data", *path)
示例#2
0
def scenario_path(*path):
    return relative_path(__file__, *path)
示例#3
0
文件: utils.py 项目: databand-ai/dbnd
import logging

from dbnd._core.utils.project.project_fs import abs_join, relative_path


logger = logging.getLogger(__name__)
_airflow_lib_home_default = relative_path(__file__)


def dbnd_airflow_path(*path):
    return abs_join(_airflow_lib_home_default, *path)


def create_airflow_pool(pool_name):
    from airflow.models import Pool
    from airflow.utils.db import create_session

    print("Creating Airflow pool '%s'" % pool_name)
    with create_session() as session:
        if session.query(Pool.pool).filter(Pool.pool == pool_name).scalar() is not None:
            return

        # -1 so we have endless pool
        dbnd_pool = Pool(pool=pool_name, slots=-1)
        session.merge(dbnd_pool)
        session.commit()
示例#4
0
def test_scenario_path(*path):
    scenarios_dir = relative_path(__file__, "..", "..", "scenarios")
    # if env var exists - use it as the examples dir, otherwise, calculate relative from here.

    return os.path.join(scenarios_dir, *path)