def new_driver()

in pbspro/src/pbspro/autoscaler.py [0:0]


def new_driver(config: Dict) -> "PBSProDriver":
    import importlib

    pbs_config = config.get("pbs", {})

    driver_expr = pbs_config.get("driver", "pbs.driver.new_driver")

    if "." not in driver_expr:
        raise BadDriverError(driver_expr)

    module_expr, func_or_class_name = driver_expr.rsplit(".", 1)

    try:
        module = importlib.import_module(module_expr)
    except Exception as e:
        logging.exception(
            "Could not load module %s. Is it in the"
            + " PYTHONPATH environment variable? %s",
            str(e),
            sys.path,
        )
        raise

    func_or_class = getattr(module, func_or_class_name)
    return func_or_class(config)