Search in sources :

Example 1 with CreateExperimentRequest

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));
}
Also used : CreateExperimentRequest(ml.comet.experiment.impl.rest.CreateExperimentRequest) CreateExperimentResponse(ml.comet.experiment.impl.rest.CreateExperimentResponse) CometGeneralException(ml.comet.experiment.exception.CometGeneralException) CometApiException(ml.comet.experiment.exception.CometApiException)

Aggregations

CometApiException (ml.comet.experiment.exception.CometApiException)1 CometGeneralException (ml.comet.experiment.exception.CometGeneralException)1 CreateExperimentRequest (ml.comet.experiment.impl.rest.CreateExperimentRequest)1 CreateExperimentResponse (ml.comet.experiment.impl.rest.CreateExperimentResponse)1