def construct_cmd()

in agents/launch.py [0:0]


def construct_cmd(args):
    """Construct the cmd as provided in args."""
    if args.cfg:
        assert args.cfg.startswith('expts'), 'Must be wrt this directory'
    agent_folder = '{}/{}'.format(BASE_RUN_DIR,
                                  args.cfg if args.cfg else 'default')
    if args.local and not args.test:
        # If args.test, then might be testing a model from other dir
        agent_folder = os.path.join(agent_folder, 'local')
    if args.tb:  # Run tensorboard only
        # Clear the cli and just run tensorboard
        cli = ('cd {agent_folder}; tensorboard --logdir . --port {port} '
               '--max_reload_threads 10 --window_title {name} ').format(
                   agent_folder=agent_folder,
                   port=get_free_port(),
                   name=args.cfg)
        return cli
    if args.fl:  # Visualize the folder only
        # Clear the cli and just run tensorboard
        cli = 'cd {}; python -m http.server {}'.format(agent_folder,
                                                       get_free_port())
        return cli
    if args.delete:
        cli = 'rm -r {f}/* {f}/.*'.format(f=agent_folder)
        shall = input("Run %s (y/N) " % cli).lower() == 'y'
        if shall:
            return cli
        return ''
    # Else, it is the general train command
    cli = ' {} train2.py hydra.run.dir={} '.format(
        'kernprof -l ' if args.profile else 'python ', agent_folder)
    run_id, cli_stuff = read_file_into_cli(args.cfg,
                                           running_local=args.local,
                                           run_id=args.run_id)
    cli_stuff = [f"'{el}'" for el in cli_stuff]
    cli += ' '.join(cli_stuff)
    if args.vis:
        cli += (' eval.store_vis=True '
                ' eval.frames_per_clip=20 '
                ' eval.n_fwd_times=20 '
                ' force_eval=true ')
    if args.test:
        # wts_folder = get_models_dir(agent_folder) if args.local else 'last'
        wts_folder = (os.path.join(agent_folder, str(run_id))
                      if args.local else 'last')
        cli += ' agent.weights_folder={} '.format(wts_folder)
    if args.local:
        cli += (' num_gpus=1 train.batch_size=2 '
                ' eval.batch_size=4 '
                ' train.data_loader.num_workers=0 '
                ' eval.data_loader.num_workers=0 ')
    cli += ' ' + ' '.join(args.rest)
    # This must go at the end, the other args must go before
    if not args.local:
        cli += ' -m '
    return cli