use of water.api.schemas3.JobV3 in project h2o-3 by h2oai.
the class GridSearchHandler method handle.
// Invoke the handler with parameters. Can throw any exception the called handler can throw.
// TODO: why does this do its own params filling?
// TODO: why does this do its own sub-dispatch?
@Override
S handle(int version, water.api.Route route, Properties parms, String postBody) throws Exception {
// Only here for train or validate-parms
if (!route._handler_method.getName().equals("train"))
throw water.H2O.unimpl();
// Peek out the desired algo from the URL
String[] ss = route._url.split("/");
// {}/{99}/{Grid}/{gbm}/
String algoURLName = ss[3];
// gbm -> GBM; deeplearning -> DeepLearning
String algoName = ModelBuilder.algoName(algoURLName);
String schemaDir = ModelBuilder.schemaDirectory(algoURLName);
// Get the latest version of this algo: /99/Grid/gbm ==> GBMV3
// String algoSchemaName = SchemaServer.schemaClass(version, algoName).getSimpleName(); // GBMV3
// int algoVersion = Integer.valueOf(algoSchemaName.substring(algoSchemaName.lastIndexOf("V")+1)); // '3'
// Ok, i'm replacing one hack with another hack here, because SchemaServer.schema*() calls are getting eliminated.
// There probably shouldn't be any reference to algoVersion here at all... TODO: unhack all of this
int algoVersion = 3;
if (algoName.equals("SVD") || algoName.equals("Aggregator") || algoName.equals("StackedEnsemble"))
algoVersion = 99;
// TODO: this is a horrible hack which is going to cause maintenance problems:
String paramSchemaName = schemaDir + algoName + "V" + algoVersion + "$" + ModelBuilder.paramName(algoURLName) + "V" + algoVersion;
// Build the Grid Search schema, and fill it from the parameters
S gss = (S) new GridSearchSchema();
gss.init_meta();
gss.parameters = (P) TypeMap.newFreezable(paramSchemaName);
gss.parameters.init_meta();
gss.hyper_parameters = new IcedHashMap<>();
// Get default parameters, then overlay the passed-in values
// Default parameter settings
ModelBuilder builder = ModelBuilder.make(algoURLName, null, null);
// Defaults for this builder into schema
gss.parameters.fillFromImpl(builder._parms);
// Override defaults from user parms
gss.fillFromParms(parms);
// Verify list of hyper parameters
// Right now only names, no types
// note: still use _validation_frame and and _training_frame at this point.
// Do not change those names yet.
validateHyperParams((P) gss.parameters, gss.hyper_parameters);
// Get actual parameters
MP params = (MP) gss.parameters.createAndFillImpl();
Map<String, Object[]> sortedMap = new TreeMap<>(gss.hyper_parameters);
// training_fame are no longer valid names.
if (sortedMap.containsKey("validation_frame")) {
sortedMap.put("valid", sortedMap.get("validation_frame"));
sortedMap.remove("validation_frame");
}
// Get/create a grid for given frame
// FIXME: Grid ID is not pass to grid search builder!
Key<Grid> destKey = gss.grid_id != null ? gss.grid_id.key() : null;
// Create target grid search object (keep it private for now)
// Start grid search and return the schema back with job key
Job<Grid> gsJob = GridSearch.startGridSearch(destKey, params, sortedMap, new DefaultModelParametersBuilderFactory<MP, P>(), (HyperSpaceSearchCriteria) gss.search_criteria.createAndFillImpl());
// Fill schema with job parameters
// FIXME: right now we have to remove grid parameters which we sent back
gss.hyper_parameters = null;
// TODO: looks like it's currently always 0
gss.total_models = gsJob._result.get().getModelCount();
gss.job = new JobV3(gsJob);
return gss;
}
use of water.api.schemas3.JobV3 in project h2o-3 by h2oai.
the class JobsHandler method fetch.
// called through reflection by RequestServer
@SuppressWarnings("unused")
public JobsV3 fetch(int version, JobsV3 s) {
Key key = s.job_id.key();
Value val = DKV.get(key);
if (null == val)
throw new IllegalArgumentException("Job is missing");
Iced ice = val.get();
if (!(ice instanceof Job))
throw new IllegalArgumentException("Must be a Job not a " + ice.getClass());
Job j = (Job) ice;
s.jobs = new JobV3[1];
// s.fillFromImpl(jobs);
try {
s.jobs[0] = (JobV3) SchemaServer.schema(version, j).fillFromImpl(j);
}// no special schema for this job subclass, so fall back to JobV3
catch (H2ONotFoundArgumentException e) {
s.jobs[0] = new JobV3().fillFromImpl(j);
}
return s;
}
use of water.api.schemas3.JobV3 in project h2o-3 by h2oai.
the class ParseHandler method parse.
// Entry point for parsing.
// called through reflection by RequestServer
@SuppressWarnings("unused")
public ParseV3 parse(int version, ParseV3 parse) {
ParserInfo parserInfo = ParserService.INSTANCE.getByName(parse.parse_type).info();
ParseSetup setup = new ParseSetup(parserInfo, parse.separator, parse.single_quotes, parse.check_header, parse.number_columns, delNulls(parse.column_names), ParseSetup.strToColumnTypes(parse.column_types), parse.domains, parse.na_strings, null, new ParseWriter.ParseErr[0], parse.chunk_size);
if (parse.source_frames == null)
throw new H2OIllegalArgumentException("Data for Frame '" + parse.destination_frame.name + "' is not available. Please check that the path is valid (for all H2O nodes).'");
Key[] srcs = new Key[parse.source_frames.length];
for (int i = 0; i < parse.source_frames.length; i++) srcs[i] = parse.source_frames[i].key();
parse.job = new JobV3(ParseDataset.parse(parse.destination_frame.key(), srcs, parse.delete_on_done, setup, parse.blocking)._job);
if (parse.blocking) {
Frame fr = DKV.getGet(parse.destination_frame.key());
parse.rows = fr.numRows();
}
return parse;
}
use of water.api.schemas3.JobV3 in project h2o-3 by h2oai.
the class CreateFrameHandler method run.
public JobV3 run(int version, CreateFrameV3 cf) {
if (cf.dest == null) {
cf.dest = new KeyV3.FrameKeyV3();
cf.dest.name = Key.rand();
}
CreateFrame cfr = new CreateFrame(cf.dest.key());
cf.fillImpl(cfr);
return new JobV3(cfr.execImpl());
}
Aggregations