use of ml.comet.experiment.impl.rest.CreateExperimentRequest in project comet-java-sdk by comet-ml.
the class BaseExperiment method registerExperiment.
/**
* Synchronously registers experiment at the Comet server.
*
* @throws CometGeneralException if failed to register experiment.
*/
void registerExperiment() throws CometGeneralException {
if (StringUtils.isNotBlank(this.experimentKey)) {
getLogger().debug("Not registering a new experiment. Using previous experiment key {}", this.experimentKey);
return;
}
// do synchronous call to register experiment
try {
CreateExperimentResponse result = this.restApiClient.registerExperiment(new CreateExperimentRequest(this.workspaceName, this.projectName, this.experimentName)).blockingGet();
if (StringUtils.isBlank(result.getExperimentKey())) {
throw new CometGeneralException(getString(FAILED_REGISTER_EXPERIMENT));
}
this.experimentKey = result.getExperimentKey();
this.experimentLink = result.getLink();
this.workspaceName = result.getWorkspaceName();
this.projectName = result.getProjectName();
if (StringUtils.isBlank(this.experimentName)) {
this.experimentName = result.getName();
}
} catch (CometApiException ex) {
this.getLogger().error(getString(FAILED_REGISTER_EXPERIMENT), ex);
throw new CometGeneralException(getString(FAILED_REGISTER_EXPERIMENT), ex);
}
getLogger().info(getString(EXPERIMENT_CREATED, this.workspaceName, this.projectName, this.experimentName));
getLogger().info(getString(EXPERIMENT_LIVE, this.experimentLink));
}
Aggregations