Пример #1
0
def change_config(python, backend, cheatsheet, asciiart):
    """
    Toggles on/off cheatsheet, asciiart
    """
    from airflow_breeze.cache import delete_cache, touch_cache_file, write_to_cache_file

    if asciiart:
        console.print('[blue] ASCIIART enabled')
        delete_cache('suppress_asciiart')
    elif asciiart is not None:
        touch_cache_file('suppress_asciiart')
    else:
        pass
    if cheatsheet:
        console.print('[blue] Cheatsheet enabled')
        delete_cache('suppress_cheatsheet')
    elif cheatsheet is not None:
        touch_cache_file('suppress_cheatsheet')
    else:
        pass
    if python is not None:
        write_to_cache_file('PYTHON_MAJOR_MINOR_VERSION', python)
        console.print(f'[blue]Python cached_value {python}')
    if backend is not None:
        write_to_cache_file('BACKEND', backend)
        console.print(f'[blue]Backend cached_value {backend}')
Пример #2
0
def get_cached_params(user_params) -> Dict:
    updated_params = dict(user_params)
    for param in PARAMS_IN_CACHE:
        if param in user_params:
            param_name = PARAMS_IN_CACHE[param]
            user_param_value = user_params[param]
            if user_param_value is not None:
                write_to_cache_file(param_name, user_param_value)
            else:
                param_value = getattr(global_constants, DEFAULT_VALUES_FOR_PARAM[param])
                _, user_param_value = check_cache_and_write_if_not_cached(param_name, param_value)
            updated_params[param] = user_param_value
    return updated_params
Пример #3
0
def get_image_build_params(parameters_passed: Dict[str, str]):
    cacheable_parameters = {"python_version": 'PYTHON_MAJOR_MINOR_VERSION'}
    ci_image_params = BuildParams(**parameters_passed)
    for parameter, cache_key in cacheable_parameters.items():
        value_from_parameter = parameters_passed.get(parameter)
        if value_from_parameter:
            write_to_cache_file(cache_key, value_from_parameter, check_allowed_values=True)
            setattr(ci_image_params, parameter, value_from_parameter)
        else:
            is_cached, value = check_cache_and_write_if_not_cached(
                cache_key, getattr(ci_image_params, parameter)
            )
            if is_cached:
                setattr(ci_image_params, parameter, value)
    return ci_image_params