Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ingest Terra metrics #478

Merged
merged 20 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions THIRD-PARTY-LICENSES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ Lists of 417 third-party dependencies.
(The Apache Software License, Version 2.0) docker-java-core (com.github.docker-java:docker-java-core:3.3.0 - https://github.com/docker-java/docker-java)
(The Apache Software License, Version 2.0) docker-java-transport (com.github.docker-java:docker-java-transport:3.3.0 - https://github.com/docker-java/docker-java)
(The Apache Software License, Version 2.0) docker-java-transport-httpclient5 (com.github.docker-java:docker-java-transport-httpclient5:3.3.0 - https://github.com/docker-java/docker-java)
(Apache Software License, Version 2.0) dockstore-common (io.dockstore:dockstore-common:1.15.0-alpha.13 - no url defined)
(Apache Software License, Version 2.0) dockstore-integration-testing (io.dockstore:dockstore-integration-testing:1.15.0-alpha.13 - no url defined)
(Apache Software License, Version 2.0) dockstore-language-plugin-parent (io.dockstore:dockstore-language-plugin-parent:1.15.0-alpha.13 - no url defined)
(Apache Software License, Version 2.0) dockstore-webservice (io.dockstore:dockstore-webservice:1.15.0-alpha.13 - no url defined)
(Apache Software License, Version 2.0) dockstore-common (io.dockstore:dockstore-common:1.15.0-SNAPSHOT - no url defined)
denis-yuen marked this conversation as resolved.
Show resolved Hide resolved
(Apache Software License, Version 2.0) dockstore-integration-testing (io.dockstore:dockstore-integration-testing:1.15.0-SNAPSHOT - no url defined)
(Apache Software License, Version 2.0) dockstore-language-plugin-parent (io.dockstore:dockstore-language-plugin-parent:1.15.0-SNAPSHOT - no url defined)
(Apache Software License, Version 2.0) dockstore-webservice (io.dockstore:dockstore-webservice:1.15.0-SNAPSHOT - no url defined)
(Apache License 2.0) Dropwizard (io.dropwizard:dropwizard-core:4.0.2 - http://www.dropwizard.io/4.0.2/dropwizard-bom/dropwizard-dependencies/dropwizard-parent/dropwizard-core)
(Apache License 2.0) Dropwizard Asset Bundle (io.dropwizard:dropwizard-assets:4.0.2 - http://www.dropwizard.io/4.0.2/dropwizard-bom/dropwizard-dependencies/dropwizard-parent/dropwizard-assets)
(Apache License 2.0) Dropwizard Authentication (io.dropwizard:dropwizard-auth:4.0.2 - http://www.dropwizard.io/4.0.2/dropwizard-bom/dropwizard-dependencies/dropwizard-parent/dropwizard-auth)
Expand Down Expand Up @@ -309,9 +309,9 @@ Lists of 417 third-party dependencies.
(MIT License) liquibase-slf4j (com.mattbertolini:liquibase-slf4j:5.0.0 - https://github.com/mattbertolini/liquibase-slf4j)
(Apache License 2.0) localstack-utils (cloud.localstack:localstack-utils:0.2.22 - http://localstack.cloud)
(Apache Software Licenses) Log4j Implemented Over SLF4J (org.slf4j:log4j-over-slf4j:2.0.9 - http://www.slf4j.org)
(Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Access Module (ch.qos.logback:logback-access:1.4.11 - http://logback.qos.ch/logback-access)
(Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Classic Module (ch.qos.logback:logback-classic:1.4.11 - http://logback.qos.ch/logback-classic)
(Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Core Module (ch.qos.logback:logback-core:1.4.11 - http://logback.qos.ch/logback-core)
(Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Access Module (ch.qos.logback:logback-access:1.4.12 - http://logback.qos.ch/logback-access)
(Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Classic Module (ch.qos.logback:logback-classic:1.4.12 - http://logback.qos.ch/logback-classic)
(Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Core Module (ch.qos.logback:logback-core:1.4.12 - http://logback.qos.ch/logback-core)
(Apache License, Version 2.0) (MIT License) Logstash Logback Encoder (net.logstash.logback:logstash-logback-encoder:4.11 - https://github.com/logstash/logstash-logback-encoder)
(Apache License, Version 2.0) Lucene Core (org.apache.lucene:lucene-core:8.7.0 - https://lucene.apache.org/lucene-parent/lucene-core)
(MIT) mbknor-jackson-jsonSchema (com.kjetland:mbknor-jackson-jsonschema_2.12:1.0.34 - https://github.com/mbknor/mbknor-jackson-jsonSchema)
Expand Down Expand Up @@ -354,7 +354,7 @@ Lists of 417 third-party dependencies.
(Apache License, Version 2.0) Objenesis (org.objenesis:objenesis:3.2 - http://objenesis.org/objenesis)
(The Apache Software License, Version 2.0) okhttp (com.squareup.okhttp3:okhttp:4.10.0 - https://square.github.io/okhttp/)
(The Apache Software License, Version 2.0) okio (com.squareup.okio:okio-jvm:3.0.0 - https://github.com/square/okio/)
(Apache Software License, Version 2.0) openapi-java-client (io.dockstore:openapi-java-client:1.15.0-alpha.13 - no url defined)
(Apache Software License, Version 2.0) openapi-java-client (io.dockstore:openapi-java-client:1.15.0-SNAPSHOT - no url defined)
(The Apache License, Version 2.0) OpenCensus (io.opencensus:opencensus-api:0.31.0 - https://github.com/census-instrumentation/opencensus-java)
(Apache 2) opencsv (com.opencsv:opencsv:5.7.1 - http://opencsv.sf.net)
(Apache 2.0) optics (io.circe:circe-optics_2.13:0.14.1 - https://github.com/circe/circe-optics)
Expand Down Expand Up @@ -395,7 +395,7 @@ Lists of 417 third-party dependencies.
(Apache License 2.0) swagger-core-jakarta (io.swagger.core.v3:swagger-core-jakarta:2.2.15 - https://github.com/swagger-api/swagger-core/modules/swagger-core-jakarta)
(Apache License 2.0) swagger-integration-jakarta (io.swagger.core.v3:swagger-integration-jakarta:2.2.15 - https://github.com/swagger-api/swagger-core/modules/swagger-integration-jakarta)
(Apache Software License, Version 2.0) swagger-java-bitbucket-client (io.dockstore:swagger-java-bitbucket-client:2.0.3 - no url defined)
(Apache Software License, Version 2.0) swagger-java-client (io.dockstore:swagger-java-client:1.15.0-alpha.13 - no url defined)
(Apache Software License, Version 2.0) swagger-java-client (io.dockstore:swagger-java-client:1.15.0-SNAPSHOT - no url defined)
(Apache Software License, Version 2.0) swagger-java-discourse-client (io.dockstore:swagger-java-discourse-client:2.0.1 - no url defined)
(Apache Software License, Version 2.0) swagger-java-quay-client (io.dockstore:swagger-java-quay-client:2.0.2 - no url defined)
(Apache Software License, Version 2.0) swagger-java-sam-client (io.dockstore:swagger-java-sam-client:2.0.2 - no url defined)
Expand Down
14 changes: 14 additions & 0 deletions metricsaggregator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
Expand All @@ -144,6 +152,10 @@
<groupId>javax.money</groupId>
<artifactId>money-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down Expand Up @@ -278,6 +290,8 @@
<usedDependency>org.glassfish.jersey.inject:jersey-hk2</usedDependency>
<usedDependency>javax.money:money-api</usedDependency>
<usedDependency>org.javamoney.moneta:moneta-core</usedDependency>
<usedDependency>ch.qos.logback:logback-classic</usedDependency>
<usedDependency>ch.qos.logback:logback-core</usedDependency>
</usedDependencies>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
}

@Parameters(commandNames = { "submit-validation-data" }, commandDescription = "Formats workflow validation data specified in a file then submits it to Dockstore")
public static class SubmitValidationData extends CommandLineArgs {
public static class SubmitValidationData extends CommandLineArgs {
@Parameter(names = {"-c", "--config"}, description = "The config file path.")
private File config = new File("./" + MetricsAggregatorClient.CONFIG_FILE_NAME);

Expand Down Expand Up @@ -78,4 +78,45 @@
return platform;
}
}

@Parameters(commandNames = { "submit-terra-metrics" }, commandDescription = "Formats workflow validation data specified in a file then submits it to Dockstore")
public static class SubmitTerraMetrics extends CommandLineArgs {
@Parameter(names = {"-c", "--config"}, description = "The config file path.")
private File config = new File("./" + MetricsAggregatorClient.CONFIG_FILE_NAME);


@Parameter(names = {"-d", "--data"}, description = "The file path to the CSV file containing workflow metrics from Terra. The first line of the file should contain the CSV fields: workflow_id,status,workflow_start,workflow_end,workflow_runtime_minutes,source_url", required = true)
private String dataFilePath;

@Parameter(names = {"-r", "--recordSkipped"}, description = "Record skipped executions and the reason skipped to a CSV file")
private boolean recordSkippedExecutions;

public File getConfig() {
return config;

Check warning on line 95 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/CommandLineArgs.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/CommandLineArgs.java#L95

Added line #L95 was not covered by tests
}


public String getDataFilePath() {
return dataFilePath;

Check warning on line 100 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/CommandLineArgs.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/CommandLineArgs.java#L100

Added line #L100 was not covered by tests
}

public boolean isRecordSkippedExecutions() {
return recordSkippedExecutions;

Check warning on line 104 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/CommandLineArgs.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/CommandLineArgs.java#L104

Added line #L104 was not covered by tests
}

/**
* Headers for the input data file
*/
public enum TerraMetricsCsvHeaders {
workflow_id, status, workflow_start, workflow_end, workflow_runtime_minutes, source_url

Check warning on line 111 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/CommandLineArgs.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/CommandLineArgs.java#L110-L111

Added lines #L110 - L111 were not covered by tests
}

/**
* Headers for the output file containing workflow executions that were skipped.
* The headers are the same as the input file headers, with the addition of a "reason" header indicating why an execution was skipped
*/
public enum SkippedTerraMetricsCsvHeaders {
workflow_id, status, workflow_start, workflow_end, workflow_runtime_minutes, source_url, reason_skipped

Check warning on line 119 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/CommandLineArgs.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/CommandLineArgs.java#L118-L119

Added lines #L118 - L119 were not covered by tests
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static io.dockstore.utils.CLIConstants.FAILURE_EXIT_CODE;
import static io.dockstore.utils.ConfigFileUtils.getConfiguration;
import static io.dockstore.utils.DockstoreApiClientUtils.setupApiClient;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.MissingCommandException;
Expand All @@ -27,9 +28,9 @@
import io.dockstore.metricsaggregator.MetricsAggregatorConfig;
import io.dockstore.metricsaggregator.MetricsAggregatorS3Client;
import io.dockstore.metricsaggregator.client.cli.CommandLineArgs.AggregateMetricsCommand;
import io.dockstore.metricsaggregator.client.cli.CommandLineArgs.SubmitTerraMetrics;
import io.dockstore.metricsaggregator.client.cli.CommandLineArgs.SubmitValidationData;
import io.dockstore.openapi.client.ApiClient;
import io.dockstore.openapi.client.Configuration;
import io.dockstore.openapi.client.api.ExtendedGa4GhApi;
import io.dockstore.openapi.client.model.ExecutionsRequestBody;
import io.dockstore.openapi.client.model.ValidationExecution;
Expand All @@ -38,6 +39,8 @@
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import org.apache.commons.configuration2.INIConfiguration;
Expand All @@ -56,19 +59,22 @@

private static final Logger LOG = LoggerFactory.getLogger(MetricsAggregatorClient.class);


public MetricsAggregatorClient() {

}

public static void main(String[] args) {
final Instant startTime = Instant.now();
MetricsAggregatorClient metricsAggregatorClient = new MetricsAggregatorClient();
final CommandLineArgs commandLineArgs = new CommandLineArgs();
final JCommander jCommander = new JCommander(commandLineArgs);
final AggregateMetricsCommand aggregateMetricsCommand = new AggregateMetricsCommand();
final SubmitValidationData submitValidationData = new SubmitValidationData();
final SubmitTerraMetrics submitTerraMetrics = new SubmitTerraMetrics();

jCommander.addCommand(aggregateMetricsCommand);
jCommander.addCommand(submitValidationData);
jCommander.addCommand(submitTerraMetrics);

try {
jCommander.parse(args);
Expand Down Expand Up @@ -117,20 +123,35 @@
try {
final MetricsAggregatorConfig metricsAggregatorConfig = new MetricsAggregatorConfig(config.get());
metricsAggregatorClient.submitValidationData(metricsAggregatorConfig, submitValidationData.getValidator(),
submitValidationData.getValidatorVersion(), submitValidationData.getDataFilePath(), submitValidationData.getPlatform());
submitValidationData.getValidatorVersion(), submitValidationData.getDataFilePath(),
submitValidationData.getPlatform());
} catch (Exception e) {
LOG.error("Could not submit validation metrics to Dockstore", e);
System.exit(FAILURE_EXIT_CODE);
}
}
}
}
} else if ("submit-terra-metrics".equals(jCommander.getParsedCommand())) {
if (submitTerraMetrics.isHelp()) {
jCommander.usage();

Check warning on line 135 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/MetricsAggregatorClient.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/MetricsAggregatorClient.java#L135

Added line #L135 was not covered by tests
} else {
final Optional<INIConfiguration> config = getConfiguration(submitTerraMetrics.getConfig());

Check warning on line 137 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/MetricsAggregatorClient.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/MetricsAggregatorClient.java#L137

Added line #L137 was not covered by tests
if (config.isEmpty()) {
System.exit(FAILURE_EXIT_CODE);

Check warning on line 139 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/MetricsAggregatorClient.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/MetricsAggregatorClient.java#L139

Added line #L139 was not covered by tests
denis-yuen marked this conversation as resolved.
Show resolved Hide resolved
}

private ApiClient setupApiClient(String serverUrl, String token) {
ApiClient apiClient = Configuration.getDefaultApiClient();
apiClient.setBasePath(serverUrl);
apiClient.addDefaultHeader("Authorization", "Bearer " + token);
return apiClient;
try {
final MetricsAggregatorConfig metricsAggregatorConfig = new MetricsAggregatorConfig(config.get());
final TerraMetricsSubmitter submitTerraMetricsCommand = new TerraMetricsSubmitter(metricsAggregatorConfig,

Check warning on line 144 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/MetricsAggregatorClient.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/MetricsAggregatorClient.java#L143-L144

Added lines #L143 - L144 were not covered by tests
submitTerraMetrics);
submitTerraMetricsCommand.submitMetrics();
} catch (Exception e) {
LOG.error("Could not submit terra metrics to Dockstore", e);
System.exit(FAILURE_EXIT_CODE);
}

Check warning on line 150 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/MetricsAggregatorClient.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/MetricsAggregatorClient.java#L146-L150

Added lines #L146 - L150 were not covered by tests
}
}
final Instant endTime = Instant.now();
LOG.info("{} took {}", jCommander.getParsedCommand(), Duration.between(startTime, endTime));
}

private void aggregateMetrics(MetricsAggregatorConfig config) throws URISyntaxException {
Expand All @@ -147,8 +168,8 @@
metricsAggregatorS3Client.aggregateMetrics(extendedGa4GhApi);
}


private void submitValidationData(MetricsAggregatorConfig config, ValidatorToolEnum validator, String validatorVersion, String dataFilePath, Partner platform) throws IOException {
private void submitValidationData(MetricsAggregatorConfig config, ValidatorToolEnum validator, String validatorVersion,
String dataFilePath, Partner platform) throws IOException {
ApiClient apiClient = setupApiClient(config.getDockstoreServerUrl(), config.getDockstoreToken());
ExtendedGa4GhApi extendedGa4GhApi = new ExtendedGa4GhApi(apiClient);

Expand Down Expand Up @@ -179,17 +200,16 @@
continue;
}
String dateExecuted = lineComponents[DATE_EXECUTED_INDEX];
ValidationExecution validationExecution = new ValidationExecution()
.validatorTool(validator)
.validatorToolVersion(validatorVersion)
.isValid(isValid);
ValidationExecution validationExecution = new ValidationExecution().validatorTool(validator)
.validatorToolVersion(validatorVersion).isValid(isValid);
validationExecution.setDateExecuted(dateExecuted);
ExecutionsRequestBody executionsRequestBody = new ExecutionsRequestBody().validationExecutions(List.of(validationExecution));

try {
extendedGa4GhApi.executionMetricsPost(executionsRequestBody, platform.toString(), trsId, versionName,
"Validation executions submitted using dockstore-support metricsaggregator");
System.out.printf("Submitted validation metrics for tool ID %s, version %s, %s validated by %s %s on platform %s%n", trsId, versionName, isValid ? "successfully" : "unsuccessfully", validator, validatorVersion, platform);
System.out.printf("Submitted validation metrics for tool ID %s, version %s, %s validated by %s %s on platform %s%n", trsId,
versionName, isValid ? "successfully" : "unsuccessfully", validator, validatorVersion, platform);
} catch (Exception e) {
// Could end up here if the workflow no longer exists. Log then continue processing
LOG.error("Could not submit validation executions to Dockstore for workflow {}", csvLine, e);
Expand Down
Loading