@Commands.command(
        'work-manager',
        help='Run the CodaLab bundle work manager (to execute run bundles).',
        arguments=(
            Commands.Argument('-t', '--worker-type', type=str, help='Worker type (defined in config.json).', default='local'),
            Commands.Argument('--num-iterations', help='Number of bundles to process before exiting (for debugging).', type=int, default=None),
            Commands.Argument('--sleep-time', type=int, help='Number of seconds to wait between successive actions.', default=1),
        ),
    )
    def do_work_manager_command(self, args):
        self._fail_if_headless('work-manager')
        # This command only works if client is a LocalBundleClient.

        worker_config = self.manager.config['workers']
        if args.worker_type == 'local':
            machine = LocalMachine()
        elif args.worker_type in worker_config:
            machine = RemoteMachine(worker_config[args.worker_type])
        else:
            print >>self.stdout, '\'' + args.worker_type + '\'' + \
                  ' is not specified in your config file: ' + self.manager.config_path
            print >>self.stdout, 'Options are ' + str(map(str, worker_config.keys()))
            return

        client = self.manager.local_client()  # Always use the local bundle client
        worker = Worker(client.bundle_store, client.model, machine, client.auth_handler)
        worker.run_loop(args.num_iterations, args.sleep_time)
dataset/ETHPy150Open codalab/codalab-cli/codalab/lib/bundle_cli.py/BundleCLI.do_work_manager_command/original