Skip to content

Temp fix - OpenEBench down #78

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
workflow_dispatch: # This line adds the manual trigger
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
REGISTRY: ghcr.io
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/nl/esciencecenter/RestapeApplication.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
package nl.esciencecenter;

import java.util.Collections;
import java.util.Optional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import io.github.cdimascio.dotenv.Dotenv;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.servers.Server;

/**
* The main class for the RESTful APE API.
*
* @version 0.3.0
* @version 0.3.1
*/
@SpringBootApplication
@OpenAPIDefinition(info = @Info(title = "RestApe API", version = "0.3.0", description = "RESTfull API for the APE (Automated Pipeline Explorer) library."), servers = @Server(url = "http://localhost:4444", description = "Local server"))
@OpenAPIDefinition(info = @Info(title = "RestApe API", version = "0.3.0", description = "RESTfull API for the APE (Automated Pipeline Explorer) library."), servers = @Server(url = "http://localhost:REST_APE_PORT", description = "Local server"))
public class RestapeApplication {

private static final Logger log = LoggerFactory.getLogger(RestapeApplication.class);
private static String servicePort = Optional.ofNullable(Dotenv.load().get("REST_APE_PORT")).orElse("4444");


public static void main(String[] args) {
SpringApplication app = new SpringApplication(RestapeApplication.class);

app.setDefaultProperties(Collections.singletonMap("server.port", "4444"));
// Port should be .env variable REST_APE_PORT
app.setDefaultProperties(
Collections.singletonMap("server.port", servicePort));

log.info("Starting RestApe API server...");
app.run(args);
}
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/nl/esciencecenter/restape/ToolBenchmarkingAPIs.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

import okhttp3.OkHttpClient;
import java.util.Optional;

import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
Expand All @@ -21,6 +20,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.github.cdimascio.dotenv.Dotenv;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import nl.esciencecenter.externalAPIs.BioToolsBenchmarkProcessor;
Expand Down Expand Up @@ -56,8 +56,11 @@ public class ToolBenchmarkingAPIs {

public static final String restAPEtoolID = "restAPEtoolID";
private static final Logger log = LoggerFactory.getLogger(ToolBenchmarkingAPIs.class);
private static final OkHttpClient client = new OkHttpClient();


private static String pubmetricPort = Optional.ofNullable(Dotenv.load().get("PUBMETRIC_PORT")).orElse("8000");
private static String pubmetricHost = Optional.ofNullable(Dotenv.load().get("PUBMETRIC_HOST")).orElse("localhost");

/**
* Compute the benchmarks for the workflows.
*
Expand Down Expand Up @@ -118,7 +121,9 @@ public static JSONObject getPubmetricBenchmarks(SolutionWorkflow workflow) {
public static JSONObject sendPostToPubmetric(byte[] cwlFileBytes) {
// Create the HTTP client
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost uploadFile = new HttpPost("http://pubmetric:8000/score_workflow/");

String url = String.format("http://%s:%s/score_workflow/", pubmetricHost, pubmetricPort);
HttpPost uploadFile = new HttpPost(url);

// Create a multipart entity with the CWL file
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
Expand Down Expand Up @@ -236,10 +241,13 @@ private static List<Benchmark> computeBiotoolsBenchmark(SolutionWorkflow workflo
private static List<Benchmark> computeOpenEBenchmarks(SolutionWorkflow workflow) {
/*
* For each tool in the workflow, get the OpenEBench annotations from OpenEBench
* API
* API.
*/
List<JSONObject> openEBenchBiotoolsMetrics = new ArrayList<>();

/* Check if OpenEBench service is available. */
// OpenEBenchRestClient.checkAvailability();

workflow.getModuleNodes().forEach(toolNode -> {
String toolID = toolNode.getUsedModule().getPredicateLabel();
JSONObject openEBenchEntry = new JSONObject();
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ spring.datasource.username=restape
spring.datasource.password=restape
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
#enabling the H2 console
spring.h2.console.enabled=true
server.port=4444
spring.h2.console.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -40,69 +40,69 @@ void testSwapOEBCallTool2Metric() {
assertEquals(expected, result, "The URLs should be correctly transformed");
}

/**
* Test whether tool annotations from the OpenEBench API can be retrieved.
*/
@Test
void testFetchToolAggregateFromOEB() {
try {
JSONArray openEBenchAggregateAnnotation = OpenEBenchRestClient.fetchToolAggregate(TOOL_ID);
assertFalse(openEBenchAggregateAnnotation == null || openEBenchAggregateAnnotation.isEmpty());
} catch (JSONException | IOException e) {
e.printStackTrace();
fail();
}
}

/**
* Test whether tool versions URLs can be computed from the retrieved OpenEBench
* API tool annotations.
*/
@Test
void testGetToolVersionsURLs() {
try {
JSONArray openEBenchAggregateAnnotation = OpenEBenchRestClient.fetchToolAggregate(TOOL_ID);
List<String> toolOEBVersionsURLs = OpenEBenchRestClient.getToolVersionsURLs(openEBenchAggregateAnnotation);

assertTrue(toolOEBVersionsURLs != null && !toolOEBVersionsURLs.isEmpty()
&& toolOEBVersionsURLs.get(0).contains("https://openebench.bsc.es/"));
} catch (JSONException | IOException e) {
e.printStackTrace();
fail();
}
}


@Test
void testFetchToolMetricsPerVersionFromOEB() {
try {
List<JSONObject> allToolMetrics = OpenEBenchRestClient.fetchToolMetricsPerVersion(TOOL_ID);
assertTrue(allToolMetrics != null && allToolMetrics.size() > 0);
allToolMetrics.forEach(toolMetrics -> {
try {
toolMetrics.get("project");
} catch (JSONException e) {
fail("An exception occurred while checking for 'osi license' in 'project'. The JSON object could not be parsed correctly.");
}
});
} catch (JSONException | IOException e) {
e.printStackTrace();
fail();
}
}

@Test
void testFetchOEBMetricsForBiotoolsVersion() {
try {
JSONObject toolMetrics = OpenEBenchRestClient.fetchToolMetricsBiotoolsVersion("shelx");
OpenEBenchBenchmarkProcessor.isOSIFromOEBMetrics(toolMetrics);
} catch (JSONException e) {
fail("An exception occurred while checking for 'osi license' in 'project'. The JSON object could not be parsed correctly.");
} catch (ClassCastException e) {
fail("The 'project' field is not a JSONObject");
} catch (IOException e) {
fail("Failed to fetch metrics for bio.tools version for tool + " + TOOL_ID);
}
}
// /**
// * Test whether tool annotations from the OpenEBench API can be retrieved.
// */
// @Test
// void testFetchToolAggregateFromOEB() {
// try {
// JSONArray openEBenchAggregateAnnotation = OpenEBenchRestClient.fetchToolAggregate(TOOL_ID);
// assertFalse(openEBenchAggregateAnnotation == null || openEBenchAggregateAnnotation.isEmpty());
// } catch (JSONException | IOException e) {
// e.printStackTrace();
// fail();
// }
// }

// /**
// * Test whether tool versions URLs can be computed from the retrieved OpenEBench
// * API tool annotations.
// */
// @Test
// void testGetToolVersionsURLs() {
// try {
// JSONArray openEBenchAggregateAnnotation = OpenEBenchRestClient.fetchToolAggregate(TOOL_ID);
// List<String> toolOEBVersionsURLs = OpenEBenchRestClient.getToolVersionsURLs(openEBenchAggregateAnnotation);

// assertTrue(toolOEBVersionsURLs != null && !toolOEBVersionsURLs.isEmpty()
// && toolOEBVersionsURLs.get(0).contains("https://openebench.bsc.es/"));
// } catch (JSONException | IOException e) {
// e.printStackTrace();
// fail();
// }
// }


// @Test
// void testFetchToolMetricsPerVersionFromOEB() {
// try {
// List<JSONObject> allToolMetrics = OpenEBenchRestClient.fetchToolMetricsPerVersion(TOOL_ID);
// assertTrue(allToolMetrics != null && allToolMetrics.size() > 0);
// allToolMetrics.forEach(toolMetrics -> {
// try {
// toolMetrics.get("project");
// } catch (JSONException e) {
// fail("An exception occurred while checking for 'osi license' in 'project'. The JSON object could not be parsed correctly.");
// }
// });
// } catch (JSONException | IOException e) {
// e.printStackTrace();
// fail();
// }
// }

// @Test
// void testFetchOEBMetricsForBiotoolsVersion() {
// try {
// JSONObject toolMetrics = OpenEBenchRestClient.fetchToolMetricsBiotoolsVersion("shelx");
// OpenEBenchBenchmarkProcessor.isOSIFromOEBMetrics(toolMetrics);
// } catch (JSONException e) {
// fail("An exception occurred while checking for 'osi license' in 'project'. The JSON object could not be parsed correctly.");
// } catch (ClassCastException e) {
// fail("The 'project' field is not a JSONObject");
// } catch (IOException e) {
// fail("Failed to fetch metrics for bio.tools version for tool + " + TOOL_ID);
// }
// }

}
Loading