def main(): """Script's main function and start point.""" _dbnd_exception_handling() configure_basic_logging(None) if should_fix_pyspark_imports(): fix_pyspark_imports() register_dbnd_plugins() # adding all plugins cli commands for commands in pm.hook.dbnd_get_commands(): for command in commands: cli.add_command(command) try: return cli(prog_name="dbnd") except KeyboardInterrupt: sys.exit(1) except Exception as ex: from dbnd._core.failures import get_databand_error_message msg, code = get_databand_error_message(ex=ex, args=sys.argv[1:]) logger.error(msg) if code is not None: sys.exit(code) except SystemExit as ex: if ex.code == 0: # databricks can't handle for a reason exit with an exit code. exit() else: sys.exit(ex.code)
def dbnd_bootstrap(): global _dbnd_bootstrap global _dbnd_bootstrap_started if _dbnd_bootstrap_started: return _dbnd_bootstrap_started = True dbnd_system_bootstrap() from targets.marshalling import register_basic_data_marshallers register_basic_data_marshallers() _surpress_loggers() _suppress_warnings() enable_osx_forked_request_calls() if is_airflow_enabled(): from dbnd_airflow.bootstrap import airflow_bootstrap airflow_bootstrap() register_dbnd_plugins() from dbnd._core.configuration import environ_config from dbnd._core.utils.basics.load_python_module import run_user_func from dbnd._core.plugin.dbnd_plugins import pm from dbnd._core.configuration.dbnd_config import config user_plugins = config.get("core", "plugins", None) if user_plugins: register_dbnd_user_plugins(user_plugins.split(",")) if is_unit_test_mode(): pm.hook.dbnd_setup_unittest() pm.hook.dbnd_setup_plugin() if is_sigquit_handler_on(): from dbnd._core.utils.basics.signal_utils import ( register_sigquit_stack_dump_handler, ) register_sigquit_stack_dump_handler() # now we can run user code ( at driver/task) user_preinit = environ_config.get_user_preinit() if user_preinit: run_user_func(user_preinit) # if for any reason there will be code that calls dbnd_bootstrap, this will prevent endless recursion _dbnd_bootstrap = True