use of ml.comet.experiment.registrymodel.ModelOverview in project comet-java-sdk by comet-ml.
the class CometApiImpl method updateRegistryModel.
private void updateRegistryModel(@NonNull String registryName, @NonNull String workspace, @NonNull RegistryModelUpdateRequest request) {
// get registry model details
Optional<ModelOverview> overviewOptional = this.getRegistryModelDetails(registryName, workspace);
if (!overviewOptional.isPresent()) {
throw new ModelNotFoundException(getString(REGISTRY_MODEL_NOT_FOUND, workspace, registryName));
}
// update registry model details
request.setRegistryModelId(overviewOptional.get().getRegistryModelId());
String errorMsg = getString(FAILED_TO_UPDATE_REGISTRY_MODEL, workspace, registryName, request);
RestApiResponse response = this.executeSyncRequest(this.restApiClient::updateRegistryModel, request, errorMsg);
this.checkRestApiResponse(response, errorMsg);
}
use of ml.comet.experiment.registrymodel.ModelOverview in project comet-java-sdk by comet-ml.
the class CometApiImpl method getRegistryModelVersion.
@Override
public Optional<ModelVersionOverview> getRegistryModelVersion(@NonNull String registryName, @NonNull String workspace, @NonNull String version) {
Optional<ModelOverview> overviewOptional = this.getRegistryModelDetails(registryName, workspace);
if (!overviewOptional.isPresent()) {
return Optional.empty();
}
ModelOverview overview = overviewOptional.get();
if (overview.getVersions() == null || overview.getVersions().size() == 0) {
String msg = getString(FAILED_TO_GET_REGISTRY_MODEL_VERSIONS, workspace, registryName);
this.logger.error(msg);
throw new ModelNotFoundException(msg);
}
return overview.getVersions().stream().filter(versionOverview -> Objects.equals(versionOverview.getVersion(), version)).findFirst();
}
use of ml.comet.experiment.registrymodel.ModelOverview in project comet-java-sdk by comet-ml.
the class CometApiTest method testUpdateRegistryModelVersion.
@Test
public void testUpdateRegistryModelVersion() {
String modelName = String.format("%s-%d", SOME_MODEL_NAME, System.currentTimeMillis());
// register model with defaults
//
registerModelWithDefaults(modelName);
// wait for registry model to be processed by backend
//
Awaitility.await("failed to get registry model").pollInterval(1, TimeUnit.SECONDS).atMost(60, TimeUnit.SECONDS).until(() -> COMET_API.getRegistryModelDetails(modelName, SHARED_EXPERIMENT.getWorkspaceName()).isPresent());
// update model's version
//
String comment = "testUpdateRegistryModelVersion comment";
List<String> stages = Collections.singletonList("testUpdateRegistryModelVersion");
COMET_API.updateRegistryModelVersion(modelName, SHARED_EXPERIMENT.getWorkspaceName(), DEFAULT_MODEL_VERSION, comment, stages);
// get registry model and check that it was updated
//
Awaitility.await("failed to get registry model").pollInterval(1, TimeUnit.SECONDS).atMost(60, TimeUnit.SECONDS).until(() -> COMET_API.getRegistryModelDetails(modelName, SHARED_EXPERIMENT.getWorkspaceName()).isPresent());
Optional<ModelOverview> overviewOptional = COMET_API.getRegistryModelDetails(modelName, SHARED_EXPERIMENT.getWorkspaceName());
assertTrue(overviewOptional.isPresent(), "model expected");
ModelOverview modelOverview = overviewOptional.get();
assertNotNull(modelOverview.getVersions(), "versions list expected");
assertEquals(1, modelOverview.getVersions().size(), "wrong versions list size");
ModelVersionOverview versionOverview = modelOverview.getVersions().get(0);
assertEquals(comment, versionOverview.getComment(), "wrong comment");
assertEquals(stages, versionOverview.getStages(), "wrong stages");
}
use of ml.comet.experiment.registrymodel.ModelOverview in project comet-java-sdk by comet-ml.
the class CometApiTest method testGetRegistryModelDetails_not_found.
@Test
public void testGetRegistryModelDetails_not_found() {
String modelName = String.format("%s-%d", SOME_MODEL_NAME, System.currentTimeMillis());
// try to get not existing model
//
Optional<ModelOverview> overviewOptional = COMET_API.getRegistryModelDetails(modelName, SHARED_EXPERIMENT.getWorkspaceName());
assertFalse(overviewOptional.isPresent());
}
use of ml.comet.experiment.registrymodel.ModelOverview in project comet-java-sdk by comet-ml.
the class CometApiTest method testGetRegistryModelDetails.
@Test
public void testGetRegistryModelDetails() {
String modelName = String.format("%s-%d", SOME_MODEL_NAME, System.currentTimeMillis());
// register model with defaults
//
String registryName = registerModelWithDefaults(modelName);
// get model details and check results
//
Optional<ModelOverview> overviewOptional = COMET_API.getRegistryModelDetails(registryName, SHARED_EXPERIMENT.getWorkspaceName());
assertTrue(overviewOptional.isPresent(), "overview expected");
ModelOverview overview = overviewOptional.get();
assertEquals(registryName, overview.getModelName(), "wrong name");
assertEquals(SOME_DESCRIPTION, overview.getDescription(), "wrong description");
assertTrue(overview.isPublic(), "must be public");
assertEquals(1L, overview.getNumberOfVersions(), "wrong number of versions");
assertNotNull(overview.getUserName(), "user name expected");
assertNotNull(overview.getCreatedAt(), "createdAt expected");
assertNotNull(overview.getLastUpdated(), "last updated expected");
assertNotNull(overview.getVersions(), "at least one version expected");
ModelVersionOverview version = overview.getVersions().get(0);
assertEquals("1.0.0", version.getVersion(), "wrong version");
assertEquals(SOME_COMMENT, version.getComment(), "wrong version's comment");
assertEquals(Collections.singletonList(SOME_STAGE), version.getStages(), "wrong stages");
assertNotNull(version.getUserName(), "user name expected");
assertNotNull(version.getRestApiUrl(), "REST API URL missing");
assertNotNull(version.getCreatedAt(), "createdAt expected");
assertNotNull(version.getLastUpdated(), "last updated expected");
assertNotNull(version.getAssets(), "assets expected");
String[] fileNames = toAssetFileNames(assetFolderFiles);
assertEquals(fileNames.length, version.getAssets().size(), "wrong assets number");
}
Aggregations