Skip to content

Commit 0a3370e

Browse files
committed
⚰️ remove obsolete v1 workflows
1 parent 44f253b commit 0a3370e

9 files changed

Lines changed: 10 additions & 312 deletions

File tree

‎.betterleaks.toml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[extend]
2+
useDefault = true
3+
4+
[[allowlists]]
5+
description = "Dummy HMAC secret used in LocalResponse unit tests"
6+
condition = "AND"
7+
paths = ['''^src/test/.*\.java$''']
8+
regexes = ['''ogNjY44MhvKPGTtVsI8zG82JqWQa68woYQH''']

‎.betterleaksignore‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,5 @@
33

44
50e7a1a5deade5f3ea4f4478211fc29eb36bba86:src/test/java/com/mindee/v2/http/MindeeHttpApiV2Test.java:generic-credential-uri:73
55
fce24ac9d3dabfdc2ba2cae55a7dd83bbdc32244:src/main/java/com/mindee/input/URLInputSource.java:generic-credential-uri:68
6-
c17d58ed662f09341863cf80360ad265a8a7077e:src/test/java/com/mindee/v2/parsing/LocalResponseTest.java:generic-api-key:19
7-
6c390b1b76954f1b42f4acce9e7540a25a39f406:src/test/java/com/mindee/v1/parsing/LocalResponseTest.java:generic-api-key:21
8-
30192fe5af49c977f9a2680c3b5f2f231a47ff80:src/test/java/com/mindee/input/LocalResponseV2Test.java:generic-api-key:19
96
503570dd1ca44074c7da2c7f1f060e6eac546ad7:.github/workflows/_publish-code.yml:generic-password:29
10-
8a437effa2694ed811c09ec4b88af45c5073cda3:src/test/java/com/mindee/input/LocalResponseTest.java:generic-api-key:15
117
40ebc5e3d6d28e92097f99505aa908df7e557f38:.github/workflows/maven-publish.yml:generic-password:22

‎docs/code_samples/workflow_execution.txt‎

Lines changed: 0 additions & 40 deletions
This file was deleted.

‎src/main/java/com/mindee/v1/MindeeClient.java‎

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
import com.mindee.pdf.PDFInputOperator;
99
import com.mindee.v1.clientoptions.PollingOptions;
1010
import com.mindee.v1.clientoptions.PredictOptions;
11-
import com.mindee.v1.clientoptions.WorkflowOptions;
1211
import com.mindee.v1.http.Endpoint;
1312
import com.mindee.v1.http.MindeeApiV1;
1413
import com.mindee.v1.http.MindeeHttpApiV1;
1514
import com.mindee.v1.http.RequestParameters;
1615
import com.mindee.v1.parsing.common.AsyncPredictResponse;
1716
import com.mindee.v1.parsing.common.Inference;
1817
import com.mindee.v1.parsing.common.PredictResponse;
19-
import com.mindee.v1.parsing.common.WorkflowResponse;
2018
import com.mindee.v1.product.generated.GeneratedV1;
2119
import java.io.IOException;
2220
import java.net.URL;
@@ -476,58 +474,6 @@ private <T extends Inference> AsyncPredictResponse<T> enqueueAndParse(
476474
);
477475
}
478476

479-
/**
480-
* Send a local file to a workflow execution.
481-
*
482-
* @param workflowId ID of the workflow to send the document to.
483-
* @param localInputSource A local input source file.
484-
* @param workflowOptions Options for the workflow execution.
485-
* @return A workflow response.
486-
* @throws IOException Throws if the file can't be accessed.
487-
*/
488-
public WorkflowResponse<GeneratedV1> executeWorkflow(
489-
String workflowId,
490-
LocalInputSource localInputSource,
491-
WorkflowOptions workflowOptions
492-
) throws IOException {
493-
return this.mindeeApi
494-
.executeWorkflowPost(
495-
GeneratedV1.class,
496-
workflowId,
497-
RequestParameters
498-
.builder()
499-
.file(localInputSource.getFile())
500-
.fileName(localInputSource.getFilename())
501-
.workflowOptions(workflowOptions)
502-
.build()
503-
);
504-
}
505-
506-
/**
507-
* Send a local file to a workflow execution.
508-
*
509-
* @param workflowId ID of the workflow to send the document to.
510-
* @param localInputSource A local input source file.
511-
* @return A workflow response.
512-
* @throws IOException Throws if the file can't be accessed.
513-
*/
514-
public WorkflowResponse<GeneratedV1> executeWorkflow(
515-
String workflowId,
516-
LocalInputSource localInputSource
517-
) throws IOException {
518-
return this.mindeeApi
519-
.executeWorkflowPost(
520-
GeneratedV1.class,
521-
workflowId,
522-
RequestParameters
523-
.builder()
524-
.file(localInputSource.getFile())
525-
.fileName(localInputSource.getFilename())
526-
.workflowOptions(WorkflowOptions.builder().build())
527-
.build()
528-
);
529-
}
530-
531477
/**
532478
* Send a local file to a Standard prediction API and parse the results.
533479
*

‎src/main/java/com/mindee/v1/http/MindeeApiV1.java‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.mindee.v1.parsing.common.AsyncPredictResponse;
55
import com.mindee.v1.parsing.common.Inference;
66
import com.mindee.v1.parsing.common.PredictResponse;
7-
import com.mindee.v1.parsing.common.WorkflowResponse;
87
import java.io.IOException;
98

109
/**
@@ -38,13 +37,4 @@ public abstract <DocT extends Inference> PredictResponse<DocT> predictPost(
3837
Endpoint endpoint,
3938
RequestParameters requestParameters
4039
) throws IOException;
41-
42-
/**
43-
* Execute a workflow.
44-
*/
45-
public abstract <DocT extends Inference> WorkflowResponse<DocT> executeWorkflowPost(
46-
Class<DocT> documentClass,
47-
String workflowId,
48-
RequestParameters requestParameters
49-
) throws IOException;
5040
}

‎src/main/java/com/mindee/v1/http/MindeeHttpApiV1.java‎

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.mindee.v1.parsing.common.ErrorDetails;
1212
import com.mindee.v1.parsing.common.Inference;
1313
import com.mindee.v1.parsing.common.PredictResponse;
14-
import com.mindee.v1.parsing.common.WorkflowResponse;
1514
import java.io.IOException;
1615
import java.net.URISyntaxException;
1716
import java.net.URL;
@@ -44,7 +43,7 @@ public final class MindeeHttpApiV1 extends MindeeApiV1 {
4443
private static final ObjectMapper mapper = JsonMapper.builder().findAndAddModules().build();
4544
private final Function<Endpoint, String> buildProductPredicBasetUrl = this::buildProductPredictBaseUrl;
4645
private final Function<String, String> buildWorkflowPredictBaseUrl = this::buildWorkflowPredictBaseUrl;
47-
private final Function<String, String> buildWorkflowExecutionBaseUrl = this::buildWorkflowExecutionUrl;
46+
4847
/**
4948
* The MindeeSetting needed to make the api call.
5049
*/
@@ -74,14 +73,9 @@ public final class MindeeHttpApiV1 extends MindeeApiV1 {
7473
* Only needs to be set if the api calls need to be directed through internal URLs.
7574
*/
7675
private final Function<Endpoint, String> documentUrlFromEndpoint;
77-
/**
78-
* The function used to generate the Job status URL for workflow execution calls.
79-
* Only needs to be set if the api calls need to be directed through internal URLs.
80-
*/
81-
private final Function<String, String> workflowUrlFromId;
8276

8377
public MindeeHttpApiV1(MindeeSettings mindeeSettings) {
84-
this(mindeeSettings, null, null, null, null, null, null);
78+
this(mindeeSettings, null, null, null, null, null);
8579
}
8680

8781
@Builder
@@ -91,7 +85,6 @@ private MindeeHttpApiV1(
9185
Function<Endpoint, String> urlFromEndpoint,
9286
Function<Endpoint, String> asyncUrlFromEndpoint,
9387
Function<Endpoint, String> documentUrlFromEndpoint,
94-
Function<String, String> workflowUrlFromEndpoint,
9588
Function<String, String> asyncUrlFromWorkflow
9689
) {
9790
this.mindeeSettings = mindeeSettings;
@@ -128,12 +121,6 @@ private MindeeHttpApiV1(
128121
this.documentUrlFromEndpoint = this.buildProductPredicBasetUrl
129122
.andThen((url) -> url.concat("/documents/queue/"));
130123
}
131-
132-
if (workflowUrlFromEndpoint != null) {
133-
this.workflowUrlFromId = workflowUrlFromEndpoint;
134-
} else {
135-
this.workflowUrlFromId = this.buildWorkflowExecutionBaseUrl;
136-
}
137124
}
138125

139126
/**
@@ -260,41 +247,6 @@ public <DocT extends Inference> AsyncPredictResponse<DocT> predictAsyncPost(
260247
}
261248
}
262249

263-
/**
264-
* POST a prediction request for a workflow response.
265-
*/
266-
public <DocT extends Inference> WorkflowResponse<DocT> executeWorkflowPost(
267-
Class<DocT> documentClass,
268-
String workflowId,
269-
RequestParameters requestParameters
270-
) throws IOException {
271-
272-
String url = workflowUrlFromId.apply(workflowId);
273-
HttpPost post = buildHttpPost(url, requestParameters);
274-
275-
JavaType parametricType = mapper
276-
.getTypeFactory()
277-
.constructParametricType(WorkflowResponse.class, documentClass);
278-
try (CloseableHttpClient httpClient = httpClientBuilder.build()) {
279-
return httpClient.execute(post, response -> {
280-
HttpEntity responseEntity = response.getEntity();
281-
int statusCode = response.getCode();
282-
if (isInvalidStatusCode(statusCode)) {
283-
throw getHttpError(parametricType, response);
284-
}
285-
if (responseEntity.getContentLength() == 0) {
286-
throw new MindeeException("Empty response from server.");
287-
}
288-
String rawResponse = readRawResponse(responseEntity);
289-
WorkflowResponse<DocT> mappedResponse = mapper.readValue(rawResponse, parametricType);
290-
mappedResponse.setRawResponse(rawResponse);
291-
return mappedResponse;
292-
});
293-
} catch (IOException err) {
294-
throw new MindeeException(err.getMessage(), err);
295-
}
296-
}
297-
298250
private <ResponseT extends ApiResponse> MindeeHttpExceptionV1 getHttpError(
299251
JavaType parametricType,
300252
ClassicHttpResponse response
@@ -344,10 +296,6 @@ private String buildWorkflowPredictBaseUrl(String workflowId) {
344296
return this.mindeeSettings.getBaseUrl() + "/workflows/" + workflowId;
345297
}
346298

347-
private String buildWorkflowExecutionUrl(String workflowId) {
348-
return this.mindeeSettings.getBaseUrl() + "/workflows/" + workflowId + "/executions";
349-
}
350-
351299
private HttpPost buildHttpPost(
352300
String url,
353301
RequestParameters requestParameters

‎src/test/java/com/mindee/v1/FakeMindeeApiV1.java‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,4 @@ public <DocT extends Inference> PredictResponse<DocT> predictPost(
5959
) throws IOException {
6060
return (PredictResponse<DocT>) predictResponse;
6161
}
62-
63-
@Override
64-
public <DocT extends Inference> WorkflowResponse<DocT> executeWorkflowPost(
65-
Class<DocT> documentClass,
66-
String workflowId,
67-
RequestParameters requestParameters
68-
) throws IOException {
69-
return (WorkflowResponse<DocT>) workflowResponse;
70-
}
7162
}

‎src/test/java/com/mindee/v1/workflow/WorkflowIT.java‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@
55
import com.mindee.input.LocalInputSource;
66
import com.mindee.v1.MindeeClient;
77
import com.mindee.v1.clientoptions.PredictOptions;
8-
import com.mindee.v1.clientoptions.WorkflowOptions;
98
import com.mindee.v1.parsing.common.AsyncPredictResponse;
10-
import com.mindee.v1.parsing.common.Execution;
11-
import com.mindee.v1.parsing.common.ExecutionPriority;
12-
import com.mindee.v1.parsing.common.WorkflowResponse;
139
import com.mindee.v1.product.financialdocument.FinancialDocumentV1;
14-
import com.mindee.v1.product.generated.GeneratedV1;
1510
import java.io.IOException;
1611
import java.time.LocalDateTime;
1712
import java.time.format.DateTimeFormatter;
@@ -37,22 +32,6 @@ static void clientSetUp() throws IOException {
3732
);
3833
}
3934

40-
@Test
41-
public void givenAWorkflowIdUploadShouldReturnACorrectWorkflowObject() throws IOException {
42-
43-
WorkflowOptions options = WorkflowOptions
44-
.builder()
45-
.alias("java-" + currentDateTime)
46-
.priority(ExecutionPriority.LOW)
47-
.rag(true)
48-
.build();
49-
WorkflowResponse<GeneratedV1> response = client
50-
.executeWorkflow(workflowId, financialDocumentInputSource, options);
51-
Execution<GeneratedV1> execution = response.getExecution();
52-
Assertions.assertEquals("low", execution.getPriority());
53-
Assertions.assertEquals("java-" + currentDateTime, execution.getFile().getAlias());
54-
}
55-
5635
@Test
5736
public void GivenAWorkflowIdPredictCustomShouldPollAndNotMatchRag() throws IOException, InterruptedException {
5837

0 commit comments

Comments
 (0)