def get_default_executor_class() -> type: """ Returns the `Executor` class specified in `prefect.config.engine.executor.default_class`. If the value is a string, it will attempt to load the already-imported object. Otherwise, the value is returned. Defaults to `SynchronousExecutor` if the string config value can not be loaded """ config_value = config.get_nested("engine.executor.default_class") if isinstance(config_value, str): try: return prefect.utilities.serialization.from_qualified_name( config_value) except ValueError: warn("Could not import {}; using " "prefect.engine.executors.LocalExecutor instead.".format( config_value)) return prefect.engine.executors.LocalExecutor else: return config_value
def get_default_storage_class() -> type: """ Returns the `Storage` class specified in `prefect.config.flows.defaults.storage.default_class`. If the value is a string, it will attempt to load the already-imported object. Otherwise, the value is returned. Defaults to `Docker` if the string config value can not be loaded """ config_value = config.get_nested("flows.defaults.storage.default_class") if isinstance(config_value, str): try: return prefect.utilities.serialization.from_qualified_name( config_value) except ValueError: warn("Could not import {}; using " "prefect.environments.storage.Docker instead.".format( config_value)) return Docker else: return config_value
def get_default_result_handler_class() -> type: """ Returns the `ResultHandler` class specified in `prefect.config.engine.result_handler.default_class` If the value is a string, it will attempt to load the already-imported object. Otherwise, the value is returned. Defaults to `None` if the string config value can not be loaded """ config_value = config.get_nested("engine.result_handler.default_class") if isinstance(config_value, str): if not config_value: return lambda *args, **kwargs: None # type: ignore try: return prefect.utilities.serialization.from_qualified_name( config_value) except ValueError: warn("Could not import {}; using " "None instead.".format(config_value)) return lambda *args, **kwargs: None # type: ignore else: return config_value