https://www.comet.com official Java SDK
version Maven Central license javadoc
| Branch | Tests | Coverage | Linting | Code Security |
|---|---|---|---|---|
| master | CI | codecov | Lint Code Base | CodeQL |
<dependencies>
<dependency>
<groupId>ml.comet</groupId>
<artifactId>comet-java-client</artifactId>
<version>1.1.14</version>
</dependency>
</dependencies>
OnlineExperiment experiment = ExperimentBuilder.OnlineExperiment() .withApiKey("someApiKey") .withProjectName("someProject") .withWorkspace("someWorkspace") .build(); experiment.setExperimentName("My experiment"); experiment.logParameter("batch_size", "500"); experiment.logMetric("strMetric", 123); experiment.end();
The OnlineExperiment also can be used with try-with-resources statement which automatically
handles call to the experiment.end().
try (OnlineExperiment experiment = ExperimentBuilder.OnlineExperiment() .withApiKey("someApiKey") .withProjectName("someProject") .withWorkspace("someWorkspace") .build()) { experiment.setExperimentName("My experiment"); experiment.logParameter("batch_size", "500"); experiment.logMetric("strMetric", 123); } catch (Exception e) { e.printStackTrace(); }
The configuration parameters search order as following (first-listed are higher priority):
- system properties or environment variables
- configuration file set by call to
withConfigOverride(java.io.File) application.conf(all resources on the classpath with this name)reference.conf(all resources on the classpath with this name)
It is possible to override some or all configuration parameters programmatically when
you create a new experiment's instance using ExperimentBuilder
factory.
// Setting specific configuration parameters with builder ExperimentBuilder.OnlineExperiment().withApiKey("someApiKey").build(); // Override configuration file (can have partial keys) ExperimentBuilder.OnlineExperiment().withConfigOverride(new File("/tmp/comet.conf")).build(); // Read from environment variables OR from configuration file in classpath (application.conf) ExperimentBuilder.OnlineExperiment().build();
COMET_API_KEY
COMET_PROJECT_NAME
COMET_WORKSPACE_NAME
COMET_BASE_URL
COMET_MAX_AUTH_RETRIES
- You also can check
- For more usage examples refer to tests