use of ml.comet.experiment.asset.RemoteAsset in project comet-java-sdk by comet-ml.
the class AssetUtilsTest method testCreateRemoteAsset_fileNameSelection.
@ParameterizedTest
@CsvSource({ "s3://bucket/folder/file.extension, someFileName, someFileName", "s3://bucket/folder/file.extension,, file.extension", "s3://bucket,, " + REMOTE_FILE_NAME_DEFAULT })
public void testCreateRemoteAsset_fileNameSelection(URI uri, String fileName, String expectedFileName) {
RemoteAsset asset = createRemoteAsset(uri, ofNullable(fileName), false, empty(), empty());
assertNotNull(asset);
assertEquals(expectedFileName, asset.getLogicalPath());
}
use of ml.comet.experiment.asset.RemoteAsset in project comet-java-sdk by comet-ml.
the class BaseExperimentAsync method sendArtifactAssetAsync.
/**
* Attempts to send given {@link ArtifactAsset} or its subclass asynchronously.
*
* @param asset the artifact asset.
* @param <T> the type of the artifact asset.
* @return the {@link Single} which can be used to subscribe for operation results.
*/
private <T extends ArtifactAsset> Single<RestApiResponse> sendArtifactAssetAsync(@NonNull final T asset) {
Single<RestApiResponse> single;
Scheduler scheduler = Schedulers.io();
if (asset.isRemote()) {
// remote asset
single = validateAndGetExperimentKey().subscribeOn(scheduler).concatMap(experimentKey -> getRestApiClient().logRemoteAsset((RemoteAsset) asset, experimentKey));
} else {
// local asset
single = validateAndGetExperimentKey().subscribeOn(scheduler).concatMap(experimentKey -> getRestApiClient().logAsset(asset, experimentKey));
}
return single.doOnSuccess(restApiResponse -> checkAndLogAssetResponse(restApiResponse, getLogger(), asset)).doOnError(throwable -> getLogger().error(getString(FAILED_TO_SEND_LOG_ARTIFACT_ASSET_REQUEST, asset), throwable));
}
use of ml.comet.experiment.asset.RemoteAsset in project comet-java-sdk by comet-ml.
the class AssetUtilsTest method testCreateRemoteAsset_correctTypeCheck.
@Test
public void testCreateRemoteAsset_correctTypeCheck() throws URISyntaxException {
URI uri = new URI("s3://bucket/folder/someFile");
RemoteAsset asset = createRemoteAsset(uri, empty(), false, empty(), empty());
assertNotNull(asset);
assertEquals(ASSET.type(), asset.getType());
String expected = NOTEBOOK.type();
asset = createRemoteAsset(uri, empty(), false, empty(), Optional.of(expected));
assertNotNull(asset);
assertEquals(expected, asset.getType());
}
Aggregations