Skip to content

Commit

Permalink
feat: signal update success to api
Browse files Browse the repository at this point in the history
  • Loading branch information
m90 committed Oct 26, 2023
1 parent a2dc395 commit d3d7e75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM maven:3.6.3-jdk-8 as jarjar

COPY ./ /tmp
WORKDIR /tmp
RUN mvn clean compile assembly:single
COPY ./pom.xml /tmp/pom.xml
RUN mvn clean install

COPY ./ /tmp
RUN mvn compile assembly:single


FROM openjdk:8-jdk-alpine
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/org/wikidata/query/rdf/tool/WbStackUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,31 +193,35 @@ private static JsonArray getBatchesFromApi() throws IOException {
}
}

private static void updateRemoteBatchStatus(int batchId, boolean success) {
System.err.printf("updateRemoteBatches called with %d, %b", batchId, success);
}

private static void updateBatch(JsonElement batchElement) {
// Get the values for the batch from the JSON
JsonObject batch = batchElement.getAsJsonObject();
String entityIDs = batch.get("entityIds").getAsString();
int batchId = batch.get("id").getAsInt();
JsonObject wiki = batch.get("wiki").getAsJsonObject();
String domain = wiki.get("domain").getAsString();
JsonObject wikiQsNamespace = wiki.get("wiki_queryservice_namespace").getAsJsonObject();
String qsBackend = wikiQsNamespace.get("backend").getAsString();
String qsNamespace = wikiQsNamespace.get("namespace").getAsString();

// Run the main Update class with our altered args
runUpdaterWithArgs(new String[]{
boolean updateWasSuccessful = runUpdaterWithArgs(new String[]{
"--wikibaseHost", domain,
"--ids", entityIDs,
"--entityNamespaces", wbStackUpdaterNamespaces,
"--sparqlUrl", "http://" + qsBackend + "/bigdata/namespace/" + qsNamespace + "/sparql",
"--wikibaseScheme", wbStackWikibaseScheme,
"--conceptUri", "https://" + domain
});

// TODO on success maybe report back?
updateRemoteBatchStatus(batchId, updateWasSuccessful);
}

@SuppressFBWarnings(value = "IMC_IMMATURE_CLASS_PRINTSTACKTRACE", justification = "We should introduce proper logging framework")
private static void runUpdaterWithArgs(String[] args) {
private static boolean runUpdaterWithArgs(String[] args) {
try {
Closer closer = Closer.create();

Expand All @@ -242,7 +246,9 @@ private static void runUpdaterWithArgs(String[] args) {
} catch (Exception e) {
System.err.println("Failed batch!");
e.printStackTrace();
return false;
}
return true;
}

private static String getProxyMapString( UpdateOptions options ) {
Expand Down

0 comments on commit d3d7e75

Please sign in to comment.