示例#1
0
  protected void buildPython(IndentingAppender ia) throws IOException {
    String name = getClass().getSimpleName();

    ia.append("def ").append(name).append("(self");
    ia.incrementIndent().incrementIndent();
    for (Argument arg : _arguments) {
      ia.append(", ").append(arg._name);
      if (!arg._required) ia.append("=None");
    }
    ia.appendln("):");
    ia.decrementIndent().decrementIndent();
    ia.incrementIndent();
    ia.appendln("'''");
    ia.appendln(Objects.firstNonNull(_requestHelp, "MISSING HELP STRING"));

    if (!_arguments.isEmpty()) ia.appendln("Arguments:");
    ia.incrementIndent();
    for (Argument arg : _arguments) {
      ia.append(arg._name).append(" -- ");
      if (arg._required) ia.append("required -- ");
      ia.appendln(arg.queryDescription());
      ia.incrementIndent();
      ia.appendln(Objects.firstNonNull(arg._requestHelp, "MISSING HELP STRING"));
      ia.decrementIndent();
    }
    ia.decrementIndent();
    ia.appendln("'''");
    ia.appendln("pass");
    ia.decrementIndent();
  }
示例#2
0
文件: Job.java 项目: chouclee/h2o
 /**
  * Helper to specify which arguments trigger a refresh on change
  *
  * @param ver
  */
 @Override
 protected void registered(RequestServer.API_VERSION ver) {
   super.registered(ver);
   for (Argument arg : _arguments) {
     if (arg._name.equals("validation")) {
       arg.setRefreshOnChange();
     }
   }
 }
示例#3
0
 protected JsonObject serveHelp() {
   JsonObject r = new JsonObject();
   r.addProperty(NAME, getClass().getSimpleName());
   r.addProperty(DESCRIPTION, _requestHelp);
   JsonArray args = new JsonArray();
   for (Argument arg : _arguments) {
     args.add(arg.requestHelp());
   }
   r.add(ARGUMENTS, args);
   return r;
 }
示例#4
0
文件: Job.java 项目: chouclee/h2o
 /**
  * Helper to handle arguments based on existing input values
  *
  * @param arg
  * @param inputArgs
  */
 @Override
 protected void queryArgumentValueSet(Argument arg, java.util.Properties inputArgs) {
   super.queryArgumentValueSet(arg, inputArgs);
   if (arg._name.equals("n_folds") && validation != null) {
     arg.disable("Only if no validation dataset is provided.");
     n_folds = 0;
   }
 }
示例#5
0
 protected static final void help(Argument arg, String help) {
   arg._requestHelp = help;
 }