public final class OnlineExperimentImpl extends Object implements OnlineExperiment
OnlineExperiment to work with Comet API asynchronously.| Modifier and Type | Method and Description |
|---|---|
void |
addTag(@NonNull String tag)
Synchronous version that waits for result or exception.
|
void |
addTag(@NonNull String tag,
Optional<io.reactivex.rxjava3.functions.Action> onComplete)
Asynchronous version that only logs any received exceptions or failures.
|
static ml.comet.experiment.impl.OnlineExperimentBuilderImpl |
builder()
Returns builder to be used to create properly configured instance of this class.
|
void |
close()
Allows using
OnlineExperiment with try-with-resources statement with automatic closing after usage. |
void |
end()
Tells Comet that the Experiment is complete and release all associated resources.
|
List<ExperimentAssetLink> |
getAssetList(@NonNull AssetType type)
Get experiment asset list.
|
String |
getContext()
Gets the current context identifier as recorded in the
OnlineExperiment object locally. |
long |
getEpoch()
Gets the current epoch as recorded by the Experiment object locally.
|
String |
getExperimentKey()
Get the experiment key returned by Comet.
|
Optional<String> |
getExperimentLink()
Get the experiment link returned by Comet.
|
String |
getExperimentName()
Get experiment name.
|
GitMetadataRest |
getGitMetadata()
Get experiment git metadata.
|
Optional<String> |
getGraph()
Get experiment graph data.
|
Optional<String> |
getHtml()
Get experiment html.
|
protected abstract org.slf4j.Logger |
getLogger()
Returns logger instance associated with particular experiment.
|
List<ValueMinMaxDto> |
getLogOther()
Get experiment log other data.
|
ExperimentMetadataRest |
getMetadata()
Get experiment metadata.
|
List<ValueMinMaxDto> |
getMetrics()
Get experiment metrics.
|
Optional<String> |
getOutput()
Get experiment output data.
|
List<ValueMinMaxDto> |
getParameters()
Get experiment parameters.
|
String |
getProjectName()
Get project name of the experiment.
|
long |
getStep()
Gets the current step as recorded by the Experiment object locally.
|
List<String> |
getTags()
Get experiment tags.
|
String |
getWorkspaceName()
Get workspace name of the experiment.
|
void |
logAssetFolder(@NonNull File folder,
boolean logFilePath) |
void |
logAssetFolder(@NonNull File folder,
boolean logFilePath,
boolean recursive) |
void |
logAssetFolder(@NonNull File folder,
boolean logFilePath,
boolean recursive,
@NonNull ExperimentContext context)
Logs all the files located in the given folder as assets.
|
void |
logCode(@NonNull File file)
Allows you to report code for the experiment.
|
void |
logCode(@NonNull File file,
@NonNull ExperimentContext context)
Allows you to report code for the experiment.
|
void |
logCode(@NonNull String code,
@NonNull String fileName)
Allows you to report code for the experiment.
|
void |
logCode(@NonNull String code,
@NonNull String fileName,
@NonNull ExperimentContext context)
Allows you to report code for the experiment.
|
void |
logEndTime(long endTimeMillis)
Synchronous version that waits for result or exception.
|
void |
logGitMetadata(GitMetadata gitMetadata)
Synchronous version that waits for result or exception.
|
void |
logGraph(@NonNull String graph)
Synchronous version that waits for result or exception.
|
void |
logHtml(@NonNull String html,
boolean override)
Synchronous version that waits for result or exception.
|
void |
logLine(String line,
long offset,
boolean stderr)
Send output logs to Comet.
|
void |
logLine(String line,
long offset,
boolean stderr,
String context)
Synchronous version that waits for result or exception.
|
void |
logMetric(String metricName,
Object metricValue) |
void |
logMetric(@NonNull String metricName,
@NonNull Object metricValue,
@NonNull ExperimentContext context)
Synchronous version that waits for result or exception.
|
void |
logMetric(String metricName,
Object metricValue,
long step)
Logs a metric with Comet.
|
void |
logMetric(String metricName,
Object metricValue,
long step,
long epoch)
Logs a metric with Comet.
|
void |
logOther(@NonNull String key,
@NonNull Object value)
Synchronous version that waits for result or exception.
|
void |
logParameter(@NonNull String parameterName,
@NonNull Object paramValue)
Logs a param with Comet under the current experiment step.
|
void |
logParameter(String parameterName,
Object paramValue,
@NonNull ExperimentContext context)
Synchronous version that waits for result or exception.
|
void |
logParameter(@NonNull String parameterName,
@NonNull Object paramValue,
long step)
Logs a param with Comet.
|
void |
logRemoteAsset(@NonNull URI uri,
boolean overwrite) |
void |
logRemoteAsset(@NonNull URI uri,
@NonNull String fileName,
boolean overwrite) |
void |
logRemoteAsset(@NonNull URI uri,
String fileName,
boolean overwrite,
Map<String,Object> metadata) |
void |
logRemoteAsset(@NonNull URI uri,
String fileName,
boolean overwrite,
Map<String,Object> metadata,
@NonNull ExperimentContext context)
Logs a Remote Asset identified by a
URI. |
void |
logStartTime(long startTimeMillis)
Synchronous version that waits for result or exception.
|
void |
nextEpoch()
Increments the epoch that the experiment is on.
|
void |
nextStep()
Increments the step that the experiment is on.
|
void |
setContext(String context)
Sets the context identifier for any logs and uploaded files.
|
void |
setEpoch(long epoch)
Sets the current epoch for the experiment.
|
void |
setExperimentName(@NonNull String experimentName)
Sets the experiment name.
|
void |
setInterceptStdout()
Turn on intercept of stdout and stderr and the logging of both in Comet.
|
void |
setStep(long step)
Sets the current step for the experiment.
|
void |
stopInterceptStdout()
Turn off intercept of stdout and stderr and turns off their logging in Comet.
|
void |
uploadAsset(@NonNull File asset,
boolean overwrite) |
void |
uploadAsset(@NonNull File asset,
boolean overwrite,
@NonNull ExperimentContext context)
Upload an asset to be associated with the experiment, for example the trained weights of a neural net.
|
void |
uploadAsset(@NonNull File asset,
boolean overwrite,
long step,
long epoch)
Upload an asset to be associated with the experiment, for example the trained weights of a neural net.
|
void |
uploadAsset(@NonNull File asset,
@NonNull String fileName,
boolean overwrite) |
void |
uploadAsset(@NonNull File asset,
@NonNull String fileName,
boolean overwrite,
@NonNull ExperimentContext context)
Upload an asset to be associated with the experiment, for example the trained weights of a neural net.
|
void |
uploadAsset(@NonNull File asset,
@NonNull String fileName,
boolean overwrite,
long step)
Upload an asset under the current experiment step to be associated with the experiment,
for example the trained weights of a neural net.
|
void |
uploadAsset(@NonNull File asset,
String fileName,
boolean overwrite,
long step,
long epoch)
Upload an asset to be associated with the experiment, for example the trained weights of a neural net.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAssetList, getExperimentKey, getExperimentName, getGitMetadata, getGraph, getHtml, getLogOther, getMetadata, getMetrics, getOutput, getParameters, getProjectName, getTags, getWorkspaceName, setExperimentName, uploadAssetpublic void end()
Experimentend in interface Experimentpublic void close()
throws Exception
OnlineExperiment with try-with-resources statement with automatic closing after usage.close in interface AutoCloseableException - if an exception occurs.public void setInterceptStdout()
throws IOException
OnlineExperimentsetInterceptStdout in interface OnlineExperimentIOException - if an I/O exception occurs.public void stopInterceptStdout()
throws IOException
OnlineExperimentstopInterceptStdout in interface OnlineExperimentIOException - if an I/O exception occurs.public void nextStep()
OnlineExperimentnextStep in interface OnlineExperimentpublic long getStep()
OnlineExperimentgetStep in interface OnlineExperimentpublic void setStep(long step)
OnlineExperimentsetStep in interface OnlineExperimentstep - the current step of the experiment.public void nextEpoch()
OnlineExperimentnextEpoch in interface OnlineExperimentpublic long getEpoch()
OnlineExperimentgetEpoch in interface OnlineExperimentpublic void setEpoch(long epoch)
OnlineExperimentsetEpoch in interface OnlineExperimentepoch - the current epoch for the experiment.public void setContext(String context)
OnlineExperimentsetContext in interface OnlineExperimentcontext - the context identifier to be associated with any log records, files, and assets.public String getContext()
OnlineExperimentOnlineExperiment object locally.getContext in interface OnlineExperimentpublic Optional<String> getExperimentLink()
ExperimentgetExperimentLink in interface Experimentpublic void logMetric(@NonNull
@NonNull String metricName,
@NonNull
@NonNull Object metricValue,
@NonNull
@NonNull ExperimentContext context)
logMetric in interface ExperimentmetricName - The name for the metric to be loggedmetricValue - The new value for the metric. If the values for a metric are plottable we will plot themcontext - the context to be associated with the parameter.public void logMetric(String metricName, Object metricValue, long step, long epoch)
ExperimentlogMetric in interface ExperimentmetricName - The name for the metric to be loggedmetricValue - The new value for the metric. If the values for a metric are plottable we will plot themstep - The current step for this metric, this will set the given step for this experimentepoch - The current epoch for this metric, this will set the given epoch for this experiment.public void logMetric(String metricName, Object metricValue, long step)
OnlineExperimentlogMetric in interface OnlineExperimentmetricName - The name for the metric to be loggedmetricValue - The new value for the metric. If the values for a metric are plottable we will plot themstep - The current step for this metric, this will set the given step for this experimentpublic void logMetric(String metricName, Object metricValue)
logMetric in interface OnlineExperimentpublic void logParameter(@NonNull
@NonNull String parameterName,
@NonNull
@NonNull Object paramValue)
OnlineExperimentlogParameter in interface OnlineExperimentparameterName - The name of the param being loggedparamValue - The value for the param being loggedpublic void logParameter(@NonNull
@NonNull String parameterName,
@NonNull
@NonNull Object paramValue,
long step)
ExperimentlogParameter in interface ExperimentparameterName - The name of the param being loggedparamValue - The value for the param being loggedstep - The current step for this metric, this will set the given step for this experiment.public void logParameter(String parameterName, Object paramValue, @NonNull @NonNull ExperimentContext context)
logParameter in interface ExperimentparameterName - The name of the param being loggedparamValue - The value for the param being loggedcontext - the context to be associated with the parameter.public void logHtml(@NonNull
@NonNull String html,
boolean override)
logHtml in interface Experimenthtml - A block of html to be sent to Cometoverride - Whether previous html sent should be deleted.
If true the old html will be deleted.public void logOther(@NonNull
@NonNull String key,
@NonNull
@NonNull Object value)
logOther in interface Experimentkey - The key for the data to be storedvalue - The value for said keypublic void addTag(@NonNull
@NonNull String tag)
addTag in interface Experimenttag - The tag to be addedpublic void logGraph(@NonNull
@NonNull String graph)
logGraph in interface Experimentgraph - The graph to be logged.public void logStartTime(long startTimeMillis)
logStartTime in interface ExperimentstartTimeMillis - When you want to say that the experiment startedpublic void logEndTime(long endTimeMillis)
logEndTime in interface ExperimentendTimeMillis - When you want to say that the experiment endedpublic void logGitMetadata(GitMetadata gitMetadata)
logGitMetadata in interface ExperimentgitMetadata - The Git Metadata for the experiment.public void logLine(String line, long offset, boolean stderr)
OnlineExperimentlogLine in interface OnlineExperimentline - Text to be loggedoffset - Offset describes the place for current text to be insertedstderr - the flag to indicate if this is StdErr message.public void logLine(String line, long offset, boolean stderr, String context)
logLine in interface Experimentline - Text to be loggedoffset - Offset describes the place for current text to be insertedstderr - the flag to indicate if this is StdErr message.context - the context to be associated with the parameter.public void logAssetFolder(@NonNull
@NonNull File folder,
boolean logFilePath,
boolean recursive,
@NonNull
@NonNull ExperimentContext context)
OnlineExperimentlogAssetFolder in interface OnlineExperimentfolder - the folder you want to log.logFilePath - if true, log the file path with each file.recursive - if true, recurse the folder.context - the experiment context to be associated with the logged assets.public void logAssetFolder(@NonNull
@NonNull File folder,
boolean logFilePath,
boolean recursive)
logAssetFolder in interface OnlineExperimentpublic void logAssetFolder(@NonNull
@NonNull File folder,
boolean logFilePath)
logAssetFolder in interface OnlineExperimentpublic void uploadAsset(@NonNull
@NonNull File asset,
@NonNull
@NonNull String fileName,
boolean overwrite,
@NonNull
@NonNull ExperimentContext context)
ExperimentuploadAsset in interface Experimentasset - The asset to be storedfileName - The file name under which the asset should be stored in Comet. E.g. "someFile.txt"overwrite - Whether to overwrite files of the same name in Cometcontext - the context to be associated with the asset.public void uploadAsset(@NonNull
@NonNull File asset,
boolean overwrite,
@NonNull
@NonNull ExperimentContext context)
ExperimentuploadAsset in interface Experimentasset - The file asset to be stored. The name of the file will be used as assets identifier on Comet.overwrite - Whether to overwrite files of the same name in Cometcontext - the context to be associated with the asset.public void uploadAsset(@NonNull
@NonNull File asset,
boolean overwrite,
long step,
long epoch)
ExperimentuploadAsset in interface Experimentasset - The file asset to be stored. The name of the file will be used as assets identifier on Comet.overwrite - Whether to overwrite files of the same name in Cometstep - the step to be associated with the assetepoch - the epoch to be associated with the assetpublic void uploadAsset(@NonNull
@NonNull File asset,
@NonNull
@NonNull String fileName,
boolean overwrite,
long step)
OnlineExperimentuploadAsset in interface OnlineExperimentasset - The asset to be storedfileName - The file name under which the asset should be stored in Comet. E.g. "someFile.txt"overwrite - Whether to overwrite files of the same name in Cometstep - The step to be associated with assetpublic void uploadAsset(@NonNull
@NonNull File asset,
@NonNull
@NonNull String fileName,
boolean overwrite)
uploadAsset in interface OnlineExperimentpublic void uploadAsset(@NonNull
@NonNull File asset,
boolean overwrite)
uploadAsset in interface OnlineExperimentpublic void logRemoteAsset(@NonNull
@NonNull URI uri,
String fileName,
boolean overwrite,
Map<String,Object> metadata,
@NonNull
@NonNull ExperimentContext context)
OnlineExperimentURI. A Remote Asset is an asset but its content is not uploaded
and stored on Comet. Rather a link for its location is stored, so you can identify and distinguish
between two experiment using different version of a dataset stored somewhere else.logRemoteAsset in interface OnlineExperimenturi - the URI pointing to the remote asset location. There is no imposed format,
and it could be a private link.fileName - the optional "name" of the remote asset, could be a dataset name, a model file name.overwrite - if true will overwrite all existing assets with the same name.metadata - Some additional data to attach to the remote asset.
The dictionary values must be JSON compatible.context - the experiment context to be associated with the logged assets.public void logRemoteAsset(@NonNull
@NonNull URI uri,
String fileName,
boolean overwrite,
Map<String,Object> metadata)
logRemoteAsset in interface OnlineExperimentpublic void logRemoteAsset(@NonNull
@NonNull URI uri,
@NonNull
@NonNull String fileName,
boolean overwrite)
logRemoteAsset in interface OnlineExperimentpublic void logRemoteAsset(@NonNull
@NonNull URI uri,
boolean overwrite)
logRemoteAsset in interface OnlineExperimentpublic void logCode(@NonNull
@NonNull String code,
@NonNull
@NonNull String fileName,
@NonNull
@NonNull ExperimentContext context)
ExperimentlogCode in interface Experimentcode - Code to be sent to CometfileName - Name of source file to be displayed on UI 'code' tabcontext - the context to be associated with the asset.public void logCode(@NonNull
@NonNull File file,
@NonNull
@NonNull ExperimentContext context)
ExperimentlogCode in interface Experimentfile - Asset with source code to be sentcontext - the context to be associated with the asset.public void logCode(@NonNull
@NonNull String code,
@NonNull
@NonNull String fileName)
ExperimentlogCode in interface Experimentcode - Code to be sent to CometfileName - Name of source file to be displayed on UI 'code' tabpublic void logCode(@NonNull
@NonNull File file)
ExperimentlogCode in interface Experimentfile - Asset with source code to be sentpublic static ml.comet.experiment.impl.OnlineExperimentBuilderImpl builder()
public void addTag(@NonNull
@NonNull String tag,
Optional<io.reactivex.rxjava3.functions.Action> onComplete)
tag - The tag to be addedonComplete - The optional action to be invoked when this operation asynchronously completes.
Can be null if not interested in completion signal.protected abstract org.slf4j.Logger getLogger()
public String getExperimentKey()
ExperimentgetExperimentKey in interface Experimentpublic String getProjectName()
ExperimentgetProjectName in interface Experimentpublic String getWorkspaceName()
ExperimentgetWorkspaceName in interface Experimentpublic String getExperimentName()
ExperimentgetExperimentName in interface Experimentpublic void setExperimentName(@NonNull
@NonNull String experimentName)
ExperimentsetExperimentName in interface ExperimentexperimentName - The new name for the experimentpublic void uploadAsset(@NonNull
@NonNull File asset,
String fileName,
boolean overwrite,
long step,
long epoch)
ExperimentuploadAsset in interface Experimentasset - The asset to be storedfileName - The file name under which the asset should be stored in Comet. E.g. "someFile.txt"overwrite - Whether to overwrite files of the same name in Cometstep - the step to be associated with the assetepoch - the epoch to be associated with the assetpublic ExperimentMetadataRest getMetadata()
ExperimentgetMetadata in interface Experimentpublic GitMetadataRest getGitMetadata()
ExperimentgetGitMetadata in interface Experimentpublic Optional<String> getHtml()
ExperimentgetHtml in interface Experimentpublic Optional<String> getOutput()
ExperimentgetOutput in interface Experimentpublic Optional<String> getGraph()
ExperimentgetGraph in interface Experimentpublic List<ValueMinMaxDto> getParameters()
ExperimentgetParameters in interface Experimentpublic List<ValueMinMaxDto> getMetrics()
ExperimentgetMetrics in interface Experimentpublic List<ValueMinMaxDto> getLogOther()
ExperimentgetLogOther in interface Experimentpublic List<String> getTags()
ExperimentgetTags in interface Experimentpublic List<ExperimentAssetLink> getAssetList(@NonNull @NonNull AssetType type)
ExperimentgetAssetList in interface Experimenttype - the type of assets to be included.Copyright © 2021. All rights reserved.