Search in sources :

Example 6 with QueryParamName

use of ml.comet.experiment.impl.constants.QueryParamName in project comet-java-sdk by comet-ml.

the class RestApiUtils method assetQueryParameters.

/**
 * Extracts query parameters from the provided {@link Asset}.
 *
 * @param asset         the {@link AssetImpl} to extract HTTP query parameters from.
 * @param experimentKey the key of the Comet experiment.
 * @return the map with query parameters.
 */
public static Map<QueryParamName, String> assetQueryParameters(@NonNull final AssetImpl asset, @NonNull String experimentKey) {
    Map<QueryParamName, String> queryParams = new HashMap<>();
    queryParams.put(EXPERIMENT_KEY, experimentKey);
    queryParams.put(TYPE, asset.getType());
    putNotNull(queryParams, OVERWRITE, asset.getOverwrite());
    putNotNull(queryParams, FILE_NAME, asset.getLogicalPath());
    putNotNull(queryParams, EXTENSION, asset.getFileExtension());
    if (asset.getExperimentContext().isPresent()) {
        ExperimentContext context = asset.getExperimentContext().get();
        putNotNull(queryParams, CONTEXT, context.getContext());
        putNotNull(queryParams, STEP, context.getStep());
        putNotNull(queryParams, EPOCH, context.getEpoch());
    }
    if (asset.getGroupingName().isPresent()) {
        queryParams.put(GROUPING_NAME, asset.getGroupingName().get());
    }
    return queryParams;
}
Also used : HashMap(java.util.HashMap) ExperimentContext(ml.comet.experiment.context.ExperimentContext) QueryParamName(ml.comet.experiment.impl.constants.QueryParamName)

Aggregations

QueryParamName (ml.comet.experiment.impl.constants.QueryParamName)6 HashMap (java.util.HashMap)5 FormParamName (ml.comet.experiment.impl.constants.FormParamName)4 Request (org.asynchttpclient.Request)4 Test (org.junit.jupiter.api.Test)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 StringPart (org.asynchttpclient.request.body.multipart.StringPart)3 File (java.io.File)2 ByteArrayPart (org.asynchttpclient.request.body.multipart.ByteArrayPart)2 FilePart (org.asynchttpclient.request.body.multipart.FilePart)2 CONTENT_TYPE (io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE)1 APPLICATION_JSON (io.netty.handler.codec.http.HttpHeaderValues.APPLICATION_JSON)1 APPLICATION_OCTET_STREAM (io.netty.handler.codec.http.HttpHeaderValues.APPLICATION_OCTET_STREAM)1 MULTIPART_FORM_DATA (io.netty.handler.codec.http.HttpHeaderValues.MULTIPART_FORM_DATA)1 TEXT_PLAIN (io.netty.handler.codec.http.HttpHeaderValues.TEXT_PLAIN)1 URI (java.net.URI)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ArtifactAsset (ml.comet.experiment.artifact.ArtifactAsset)1 ExperimentContext (ml.comet.experiment.context.ExperimentContext)1