Exemple #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();
  }
Exemple #2
0
 /**
  * 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();
     }
   }
 }
Exemple #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;
 }
Exemple #4
0
 /**
  * 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;
   }
 }
Exemple #5
0
 protected static final void help(Argument arg, String help) {
   arg._requestHelp = help;
 }