def run_rta()

in cortado/rtas/_cli.py [0:0]


def run_rta():
    configure_logging()

    if len(sys.argv) != 2:
        raise ValueError("RTA name argument is not provided")

    rta_to_run = sys.argv[1]
    rta_to_run = rta_to_run.strip()

    if not rta_to_run:
        raise ValueError("RTA name is not provided")

    if rta_to_run == DUMMY_RTA_NAME:
        log.info("Dummy RTA name received. The check is done")
        return

    # NOTE: we're assuming here that the RTA will be registered in the module
    # named as RTA. This might not be the case in the future.
    load_module(rta_to_run)
    registry = get_registry()

    log.info(f"RTAs loaded: {len(registry)}")

    for rta_name, rta_details in registry.items():
        if rta_name != rta_to_run:
            continue

        log.debug(f"Running `{rta_name}` RTA")

        if isinstance(rta_details, CodeRta):
            rta_details.code_func()
            return
        else:
            log.error(f"Found an RTA but it's a hash RTA: `{rta_name}`")
            raise ValueError("Can't run a hash RTA")