Only invoked conditionally if subcommand is 'train'
480479
def init_train_args(self, parser):
        ''' '''
        parser.add_argument('-f', '--configuration', dest='config', default=DEFAULT_USER_CONFIG_PATH,
                            help='the path to the configuration file to use -- ./config.yaml by default')
        parser.add_argument('-c', '--dataset-name', help='the name of the saved dataset to train on')
        parser.add_argument('-s', '--saved-model-name', help='the name of the saved model to continue training')
        parser.add_argument('-n', '--new-model-name', help='the name to give the newly trained model')
        parser.add_argument('-g', '--gpus', dest='num_gpus', type=int, default=1, help='the number of gpus to use during training')
815848
def on_train_end(self, **kwargs):
        ""
        if self.every=="improvement" and (self.learn.path/f'{self.learn.model_dir}/{self.name}.pth').is_file():
            self.learn.load(f'{self.name}', purge=False)
1227592
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var sub = info.command.sub
    , cmd = '' + sub.cmd
    , args = sub.args
    , key
    , val
    , verified;

  if(cmd === Constants.SUBCOMMAND.config.set.name) {
    key = '' + args[0];
    val = '' + args[1];

    // test config key is allowed to be set at runtime
    if(!~Runtime.indexOf(key)) {
      throw new ConfigParameter(key);
    }

    // validate input value and coerce to native type
    try {
      val = this.conf.validate(key, [val]);

      // additional validation after type coercion and
      // basic checks, some methods modify the value (hz)
      // although most just throw an error
      verified = this.conf.verify(key, val);
      if(verified !== undefined) {
        val = verified;
      }
      args[1] = val;
    }catch(e) {
      throw new ConfigValue(key, val);
    }
  }else if(cmd === Constants.SUBCOMMAND.config.rewrite.name) {
    if(this.conf.isDefault()) {
      throw ConfigRewrite;
    }
  }
}
837990
def mod_run_check(cmd_kwargs, onlyif, unless, creates):
    '''
    
    '''
    # never use VT for onlyif/unless executions because this will lead
    # to quote problems
    cmd_kwargs = copy.deepcopy(cmd_kwargs)
    cmd_kwargs['use_vt'] = False
    cmd_kwargs['bg'] = False

    if onlyif is not None:
        if isinstance(onlyif, six.string_types):
            cmd = __salt__['cmd.retcode'](onlyif, ignore_retcode=True, python_shell=True, **cmd_kwargs)
            log.debug('Last command return code: %s', cmd)
            if cmd != 0:
                return {'comment': 'onlyif condition is false',
                        'skip_watch': True,
                        'result': True}
        elif isinstance(onlyif, list):
            for entry in onlyif:
                cmd = __salt__['cmd.retcode'](entry, ignore_retcode=True, python_shell=True, **cmd_kwargs)
                log.debug('Last command \'%s\' return code: %s', entry, cmd)
                if cmd != 0:
                    return {'comment': 'onlyif condition is false: {0}'.format(entry),
                            'skip_watch': True,
                            'result': True}
        elif not isinstance(onlyif, six.string_types):
            if not onlyif:
                log.debug('Command not run: onlyif did not evaluate to string_type')
                return {'comment': 'onlyif condition is false',
                        'skip_watch': True,
                        'result': True}

    if unless is not None:
        if isinstance(unless, six.string_types):
            cmd = __salt__['cmd.retcode'](unless, ignore_retcode=True, python_shell=True, **cmd_kwargs)
            log.debug('Last command return code: %s', cmd)
            if cmd == 0:
                return {'comment': 'unless condition is true',
                        'skip_watch': True,
                        'result': True}
        elif isinstance(unless, list):
            cmd = []
            for entry in unless:
                cmd.append(__salt__['cmd.retcode'](entry, ignore_retcode=True, python_shell=True, **cmd_kwargs))
                log.debug('Last command return code: %s', cmd)
            if all([c == 0 for c in cmd]):
                return {'comment': 'unless condition is true',
                        'skip_watch': True,
                        'result': True}
        elif not isinstance(unless, six.string_types):
            if unless:
                log.debug('Command not run: unless did not evaluate to string_type')
                return {'comment': 'unless condition is true',
                        'skip_watch': True,
                        'result': True}

    if isinstance(creates, six.string_types) and os.path.exists(creates):
        return {'comment': '{0} exists'.format(creates),
                'result': True}
    elif isinstance(creates, list) and all([
        os.path.exists(path) for path in creates
    ]):
        return {'comment': 'All files in creates exist',
                'result': True}

    # No reason to stop, return True
    return True
200943
function checkConditional(runner, conditional) {
  try {
    return conditional[1].call(runner, runner.target, runner.context);
  } catch (e) {}
}
1371943
def p_if_command(p):
    ''''''
    # we currently don't distinguish the various lists that make up the
    # command, because it's not needed later on. if there will be a need
    # we can always add different nodes for elif/else.
    parts = _makeparts(p)
    p[0] = ast.node(kind='compound',
                    redirects=[],
                    list=[ast.node(kind='if', parts=parts, pos=_partsspan(parts))],
                    pos=_partsspan(parts))
1118532
def detect_command(cmdlist):
    ''''''

    for platform, command, args in cmdlist:
        if platform is None or sys.platform == platform:
            path = shutil.which(command)
            if path:
                return ' '.join([path, args])

    return ''
1321042
def _filter_commands(ctx, commands=None):
    """"""
    lookup = getattr(ctx.command, 'commands', {})
    if not lookup and isinstance(ctx.command, click.MultiCommand):
        lookup = _get_lazyload_commands(ctx.command)

    if commands is None:
        return sorted(lookup.values(), key=lambda item: item.name)

    names = [name.strip() for name in commands.split(',')]
    return [lookup[name] for name in names if name in lookup]
1132448
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var withscores;
  if(args.length > 3) {
    withscores = ('' + args[3]).toLowerCase();
    if(withscores !== Constants.ZSET.WITHSCORES) {
      throw CommandSyntax;
    }
    args[3] = withscores;
  }
}
795771
def on_batch_begin(self, train, **kwargs:Any)->None:
        ""
        if train:
            self.lrs.append(self.opt.lr)
            self.moms.append(self.opt.mom)
297089
def execd_run(command, execd_dir=None, die_on_error=True, stderr=subprocess.STDOUT):
    """"""
    for submodule_path in execd_submodule_paths(command, execd_dir):
        try:
            subprocess.check_output(submodule_path, stderr=stderr,
                                    universal_newlines=True)
        except subprocess.CalledProcessError as e:
            hookenv.log("Error ({}) running  {}. Output: {}".format(
                e.returncode, e.cmd, e.output))
            if die_on_error:
                sys.exit(e.returncode)
205801
function parseSubCommand(cmd) {
	const parseDetails = parseLine(cmd.rest, cmd.lineno);
	if (parseDetails.command) {
		cmd.args = parseDetails.command;
		return true;
	}
	cmd.error = 'Unhandled onbuild command: ' + cmd.rest;
	return false;
}
232542
function invokeCommandError(command, isInternalCommand) {

  if (isInternalCommand) {
    return;
  }

  const cwd = process.cwd();
  logger.error(`No modules found for ${command}`);

  if (cwd.indexOf('skyux-spa') === -1) {
    logger.error(`Are you in a SKY UX SPA directory?`);
  } else if (!fs.existsSync('./node_modules')) {
    logger.error(`Have you ran 'npm install'?`);
  }

  process.exit(1);
}
938804
def check_call(args, stdin=None, env=None):
    """"""
    log.debug('run: %s%s', args, ' {}'.format(env) if env else '')
    subprocess.check_call(args=args, stdin=stdin, env=env)
748858
def on_train_begin(self, **kwargs):
        ""
        if not self.modules:
            self.modules = [m for m in flatten_model(self.learn.model)
                            if hasattr(m, 'weight')]
        self.hooks = Hooks(self.modules, self.hook)
794818
def on_train_begin(self, **kwargs:Any)->None:
        ""
        self.wait, self.opt = 0, self.learn.opt
        super().on_train_begin(**kwargs)
1235732
def rule_match(component, cmd):
    ''''''
    if component == cmd:
        return True
    expanded = rule_expand(component, cmd)
    if cmd in expanded:
        return True
    return False