Skip to content
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
28 changes: 28 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Build outputs (regenerated inside the builder stage)
build/
.gradle/
out/

# IDE / editor / OS
.idea/
.vscode/
*.iml
.DS_Store

# Runtime & logs (never needed at build time)
logs/
tmp/
*.log

# Research / developer helpers never copied into the image
scripts/
doc/

# Markdown & meta — not copied into the image
*.md
LICENSE
.claude/
.github/

# Note: .git/ is intentionally NOT listed — Dockerfile.software COPYs it so
# Gradle can stamp revision.txt from `git rev-parse`.
20 changes: 10 additions & 10 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build unstable

on: [push]

concurrency:
concurrency:
group: gradle
# cancel-in-progress: true
cancel-in-progress: true


jobs:
Expand All @@ -22,14 +22,14 @@ jobs:
- name: Build with Gradle
run: ./gradlew build -x test

# - name: Test with Gradle Jacoco and Coveralls
# run: ./gradlew test jacocoTestReport coveralls --no-daemon
#
# - name: Coveralls GitHub Action
# uses: coverallsapp/github-action@v2
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# format: jacoco
- name: Test with Gradle Jacoco and Coveralls
run: ./gradlew test jacocoTestReport coveralls --no-daemon

- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
format: jacoco

docker-build:
needs: [ build ]
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile.software
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ ENV SOFTWARE_MENTIONS_OPTS="-Djava.library.path=/opt/grobid/grobid-home/lib/lin-

CMD ["./software-mentions/bin/software-mentions", "server", "software-mentions/resources/config/config.yml"]

# Container-level liveness probe. /service/isalive returns "true" when the
# Dropwizard server is up; models are loaded lazily on first request so we
# don't need to wait for them before reporting healthy.
# Using python3 (required by JEP/DeLFT so guaranteed present) instead of
# curl/wget to avoid depending on packages that may not ship in the GROBID
# base image.
HEALTHCHECK --interval=30s --timeout=5s --start-period=90s --retries=3 \
CMD python3 -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8060/service/isalive', timeout=4).status == 200 else 1)" || exit 1

LABEL \
authors="The contributors" \
org.label-schema.name="software-mentions" \
Expand Down
81 changes: 20 additions & 61 deletions src/main/java/org/grobid/core/engines/SoftwareDisambiguator.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,17 @@ public boolean checkIfAlive() {
url = new URL("http://" + nerd_host + "/service/isalive");

LOGGER.debug("Calling: " + url.toString());
//System.out.println("Calling: " + url.toString());
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet get = new HttpGet(url.toString());

CloseableHttpResponse response = null;
Scanner in = null;
try {
response = httpClient.execute(get);
//System.out.println(response.getStatusLine());
try (CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(get)) {
int code = response.getStatusLine().getStatusCode();
if (code != 200) {
LOGGER.error("Failed isalive service: HTTP error code : " + code);
return false;
} else {
result = true;
}
} finally {
if (in != null)
in.close();
if (response != null)
response.close();
}
} catch (MalformedURLException e) {
LOGGER.error("disambiguation service not available: MalformedURLException");
Expand All @@ -169,12 +159,11 @@ public boolean checkIfAlive() {
}

/**
* Check if the software customisation is ready on the entity-fishing server, if not load it
* Check if the software customisation is ready on the entity-fishing server, if not load it
*/
public void ensureCustomizationReady() {
boolean result = false;
URL url = null;
CloseableHttpResponse response = null;
try {
if ( (nerd_port != null) && (nerd_port.length() > 0) )
if (nerd_port.equals("443"))
Expand All @@ -185,24 +174,15 @@ public void ensureCustomizationReady() {
url = new URL("http://" + nerd_host + "/service/customisation/software");

LOGGER.debug("Calling: " + url.toString());
//System.out.println("Calling: " + url.toString());
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet get = new HttpGet(url.toString());
Scanner in = null;
try {
response = httpClient.execute(get);
//System.out.println(response.getStatusLine());
try (CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(get)) {
int code = response.getStatusLine().getStatusCode();
if (code != 200) {
LOGGER.error("Failed customization lookup service: HTTP error code : " + code);
} else {
result = true;
}
} finally {
if (in != null)
in.close();
if (response != null)
response.close();
}
} catch (MalformedURLException e) {
LOGGER.error("disambiguation service not available: MalformedURLException");
Expand Down Expand Up @@ -230,37 +210,27 @@ public void ensureCustomizationReady() {
cutomisationFile = new File(cutomisationFile.getAbsolutePath());
String json = FileUtils.readFileToString(cutomisationFile, "UTF-8");

CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost post = new HttpPost(url.toString());

//StringBody stringValue = new StringBody(json, ContentType.MULTIPART_FORM_DATA);
//StringBody stringName = new StringBody("software", ContentType.MULTIPART_FORM_DATA);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addTextBody("value", json);
builder.addTextBody("name", "software");
//builder.addPart("value", stringValue);
//builder.addPart("name", stringName);
HttpEntity entity = builder.build();
try {
post.setEntity(entity);
response = httpClient.execute(post);
//System.out.println(response.getStatusLine());

post.setEntity(entity);
try (CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(post)) {
int code = response.getStatusLine().getStatusCode();
if (code != 200) {
LOGGER.error("Failed loading software customisation: HTTP error code : " + code);
} else {
LOGGER.info("Software customisation loaded");
}
} finally {
if (response != null)
response.close();
}
} catch (MalformedURLException e) {
e.printStackTrace();
LOGGER.warn("MalformedURLException while loading software customisation", e);
} catch (IOException e) {
e.printStackTrace();
LOGGER.warn("I/O error while loading software customisation", e);
}
}
}
Expand Down Expand Up @@ -504,8 +474,6 @@ public String runNerd(List<SoftwareEntity> entities, List<LayoutToken> subtokens
url = new URL("http://" + nerd_host + ":" + nerd_port + "/service/" + RESOURCEPATH);
else
url = new URL("http://" + nerd_host + "/service/" + RESOURCEPATH);
//System.out.println("calling... " + url.toString());
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost post = new HttpPost(url.toString());
//post.addHeader("Content-Type", "application/json");
//post.addHeader("Accept", "application/json");
Expand Down Expand Up @@ -578,37 +546,28 @@ public String runNerd(List<SoftwareEntity> entities, List<LayoutToken> subtokens
builder.addPart("query", stringBody);
HttpEntity entity = builder.build();

CloseableHttpResponse response = null;
Scanner in = null;
try {
//post.setEntity(new UrlEncodedFormEntity(params));
post.setEntity(entity);
response = httpClient.execute(post);
// System.out.println(response.getStatusLine());

post.setEntity(entity);
try (CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(post)) {
int code = response.getStatusLine().getStatusCode();
if (code != 200) {
LOGGER.error("Failed annotating text segment: HTTP error code : " + code);
return null;
}

HttpEntity entityResp = response.getEntity();
in = new Scanner(entityResp.getContent());
while (in.hasNext()) {
output.append(in.next());
output.append(" ");
try (Scanner in = new Scanner(entityResp.getContent())) {
while (in.hasNext()) {
output.append(in.next());
output.append(" ");
}
}
EntityUtils.consume(entityResp);
} finally {
if (in != null)
in.close();
if (response != null)
response.close();
}
} catch (MalformedURLException e) {
e.printStackTrace();
LOGGER.warn("MalformedURLException while calling entity-fishing", e);
} catch (IOException e) {
e.printStackTrace();
LOGGER.warn("I/O error while calling entity-fishing", e);
}
return output.toString().trim();
}
Expand Down
Loading