From 864046f18707836e082300b475bd464dc287f717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Wed, 4 Nov 2026 14:08:28 +0100 Subject: [PATCH] :coffin: remove obsolete workflow methods --- docs/code_samples/workflow_execution.txt | 28 ---- src/Mindee/V1/Client.cs | 83 ---------- src/Mindee/V1/Http/IHttpApi.cs | 13 -- src/Mindee/V1/Http/MindeeApi.cs | 61 -------- src/Mindee/V1/Http/WorkflowParameter.cs | 58 ------- .../V1/Parsing/Common/WorkflowResponse.cs | 25 --- .../V1/Workflow/WorkflowTest.cs | 13 -- .../V1/Workflow/WorklowTest.cs | 142 ------------------ 8 files changed, 423 deletions(-) delete mode 100644 docs/code_samples/workflow_execution.txt delete mode 100644 src/Mindee/V1/Http/WorkflowParameter.cs delete mode 100644 src/Mindee/V1/Parsing/Common/WorkflowResponse.cs delete mode 100644 tests/Mindee.UnitTests/V1/Workflow/WorklowTest.cs diff --git a/docs/code_samples/workflow_execution.txt b/docs/code_samples/workflow_execution.txt deleted file mode 100644 index 5bd896697..000000000 --- a/docs/code_samples/workflow_execution.txt +++ /dev/null @@ -1,28 +0,0 @@ -using Mindee; -using Mindee.Input; - -string apiKey = "my-api-key"; -string filePath = "/path/to/the/file.ext"; -string workflowId = "workflow-id"; - -// Construct a new client -Client mindeeClient = new Client(apiKey); - -// Load an input source as a path string -// Other input types can be used, as mentioned in the docs -var inputSource = new LocalInputSource(filePath); - -// Send the document to a workflow execution -var response = await mindeeClient.ExecuteWorkflowAsync(workflowId, inputSource); - -// Alternatively, you can give it an alias, a priority, or enable Retrieval-Augmented Generation: -// var response = await mindeeClient.ExecuteWorkflowAsync( -// workflowId, -// inputSource, -// new WorkflowOptions(alias: "my-alias", priority: ExecutionPriority.Low, rag: true)); - -// Print the execution ID to make sure it worked. -System.Console.WriteLine(response.Execution.Id); - -// Print the inference result. -// System.Console.WriteLine(response.Execution.Inference); diff --git a/src/Mindee/V1/Client.cs b/src/Mindee/V1/Client.cs index 3288f2377..4c214bc04 100644 --- a/src/Mindee/V1/Client.cs +++ b/src/Mindee/V1/Client.cs @@ -723,89 +723,6 @@ UrlInputSource inputSource return await PollForResultsAsync(enqueueResponse, pollingOptions, ct); } - /// - /// Send a local file to a workflow execution. - /// - /// The workflow id. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public async Task> ExecuteWorkflowAsync( - string workflowId, - LocalInputSource inputSource, - WorkflowOptions workflowOptions = null, - PageOptions pageOptions = null) - { - Logger?.LogInformation("Sending '{Filename}' to workflow '{WorkflowId}'...", inputSource.Filename, workflowId); - - if (pageOptions != null && inputSource.IsPdf()) - { - inputSource.FileBytes = _pdfOperation.Split( - new SplitQuery(inputSource.FileBytes, pageOptions)).File; - } - - workflowOptions ??= new WorkflowOptions(); - - return await _mindeeApi.PostWorkflowExecution( - workflowId, - new WorkflowParameter( - inputSource, - null, - workflowOptions.FullText, - workflowOptions.Alias, - workflowOptions.Priority, - workflowOptions.PublicUrl, - workflowOptions.Rag - )); - } - - /// - /// Send a remote file to a workflow execution. - /// - /// The workflow id. - /// - /// - /// - /// - /// - /// - /// - /// - /// - public async Task> ExecuteWorkflowAsync( - string workflowId, - UrlInputSource inputSource, - WorkflowOptions workflowOptions = null) - { - Logger?.LogInformation("Asynchronous parsing of {} ...", inputSource.FileUrl); - - if (workflowOptions == null) - { - workflowOptions = new WorkflowOptions(); - } - - return await _mindeeApi.PostWorkflowExecution( - workflowId, - new WorkflowParameter( - null, - inputSource, - workflowOptions.FullText, - workflowOptions.Alias, - workflowOptions.Priority, - workflowOptions.PublicUrl, - workflowOptions.Rag - )); - } - /// /// Load a local prediction. /// Typically used when wanting to load from a webhook callback. diff --git a/src/Mindee/V1/Http/IHttpApi.cs b/src/Mindee/V1/Http/IHttpApi.cs index d8f84fbad..ba55b0818 100644 --- a/src/Mindee/V1/Http/IHttpApi.cs +++ b/src/Mindee/V1/Http/IHttpApi.cs @@ -56,18 +56,5 @@ string jobId , CustomEndpoint endpoint = null , CancellationToken ct = default) where TModel : class, new(); - - /// - /// Send a document to a workflow. - /// - /// The ID of the workflow. - /// - /// - /// - /// Document type. - Task> PostWorkflowExecution( - string workflowId, - WorkflowParameter workflowParameter) - where TModel : class, new(); } } diff --git a/src/Mindee/V1/Http/MindeeApi.cs b/src/Mindee/V1/Http/MindeeApi.cs index ae2277975..faed749f8 100644 --- a/src/Mindee/V1/Http/MindeeApi.cs +++ b/src/Mindee/V1/Http/MindeeApi.cs @@ -141,67 +141,6 @@ string jobId return handledResponse; } - public async Task> PostWorkflowExecution( - string workflowId, - WorkflowParameter workflowParameter) - where TModel : class, new() - { - var request = new RestRequest( - $"/v1/workflows/{workflowId}/executions" - , Method.Post); - - AddWorkflowRequestParameters(workflowParameter, request); - - _logger?.LogInformation("HTTP POST to {RequestResource} ...", _baseUrl + request.Resource); - - var response = await _httpClient.ExecutePostAsync(request); - return ResponseHandler>(response); - } - - private static void AddWorkflowRequestParameters(WorkflowParameter workflowParameter, RestRequest request) - { - if (workflowParameter.LocalSource != null) - { - request.AddFile( - "document", - workflowParameter.LocalSource.FileBytes, - workflowParameter.LocalSource.Filename); - } - else if (workflowParameter.UrlSource != null) - { - request.AddParameter( - "document", - workflowParameter.UrlSource.FileUrl.ToString()); - } - - if (workflowParameter.FullText) - { - request.AddQueryParameter("full_text_ocr", "true"); - } - - if (workflowParameter.Alias != null) - { - request.AddParameter("alias", workflowParameter.Alias); - } - - if (workflowParameter.PublicUrl != null) - { - request.AddParameter("public_url", workflowParameter.PublicUrl); - } - - if (workflowParameter.Priority != null) - { - request.AddParameter( - "priority", - workflowParameter.Priority?.ToString().ToLower()); - } - - if (workflowParameter.Rag) - { - request.AddQueryParameter("rag", "true"); - } - } - private static void AddPredictRequestParameters(PredictParameter predictParameter, RestRequest request) { if (predictParameter.LocalSource != null) diff --git a/src/Mindee/V1/Http/WorkflowParameter.cs b/src/Mindee/V1/Http/WorkflowParameter.cs deleted file mode 100644 index ac219e321..000000000 --- a/src/Mindee/V1/Http/WorkflowParameter.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Mindee.Input; -using Mindee.V1.Parsing.Common; - -namespace Mindee.V1.Http -{ - /// - /// Parameter required to use the workflow feature. - /// - public class WorkflowParameter : GenericParameter - { - /// - /// Workflow parameters. - /// - /// Local input source containing the file. - /// Source URL to use. - /// - /// Whether to include the full text in the payload (compatible APIs only) - /// - /// - /// Alias to give to the document. - /// Priority to give to the document. - /// - /// A one-time use unique encrypted URL to sign in with without using credentials. - /// - /// - /// Whether to enable Retrieval-Augmented Generation. - public WorkflowParameter( - LocalInputSource localSource, - UrlInputSource urlSource, - bool fullText, - string alias, - ExecutionPriority? priority, - string publicUrl, - bool rag) : base(localSource, urlSource, - fullText, null, rag) - { - Alias = alias; - Priority = priority; - PublicUrl = publicUrl; - } - - /// - /// Alias to give to the file. - /// - public string Alias { get; } - - - /// - /// Priority to give to the execution. - /// - public ExecutionPriority? Priority { get; } - - /// - /// A unique, encrypted URL for accessing the document validation interface without requiring authentication. - /// - public string PublicUrl { get; } - } -} diff --git a/src/Mindee/V1/Parsing/Common/WorkflowResponse.cs b/src/Mindee/V1/Parsing/Common/WorkflowResponse.cs deleted file mode 100644 index 0597f3eaa..000000000 --- a/src/Mindee/V1/Parsing/Common/WorkflowResponse.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Text.Json.Serialization; -using Mindee.V1.Product.Generated; - -namespace Mindee.V1.Parsing.Common -{ - /// - /// Represents the server response after a document is sent to a workflow. - /// - public class WorkflowResponse : CommonResponse where TModel : class, new() - { - /// - /// Set the prediction model used to parse the document. - /// - [JsonPropertyName("execution")] - public Execution Execution { get; set; } - - - /// - /// Default product is GeneratedV1. - /// - public class Default : WorkflowResponse - { - } - } -} diff --git a/tests/Mindee.IntegrationTests/V1/Workflow/WorkflowTest.cs b/tests/Mindee.IntegrationTests/V1/Workflow/WorkflowTest.cs index eceabff1a..c62acc9e0 100644 --- a/tests/Mindee.IntegrationTests/V1/Workflow/WorkflowTest.cs +++ b/tests/Mindee.IntegrationTests/V1/Workflow/WorkflowTest.cs @@ -26,19 +26,6 @@ public WorkflowTest() _workflowId = Environment.GetEnvironmentVariable("Workflow__ID") ?? ""; } - [Fact(Timeout = 180000)] - public async Task Given_AWorkflowIdUpload_ShouldReturnACorrectWorkflowObject() - { - var currentDateTime = DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss"); - var alias = "dotnet-" + currentDateTime; - var options = new WorkflowOptions(alias, ExecutionPriority.Low, rag: true); - var response = await _client.ExecuteWorkflowAsync( - _workflowId, _ragMatchInputSource, options); - - Assert.Equal(ExecutionPriority.Low, response.Execution.Priority); - Assert.Equal(alias, response.Execution.File.Alias); - } - [Fact(Timeout = 180000)] public async Task Given_AWorkflowIdPredictCustom_ShouldPollAndMatchRag() { diff --git a/tests/Mindee.UnitTests/V1/Workflow/WorklowTest.cs b/tests/Mindee.UnitTests/V1/Workflow/WorklowTest.cs deleted file mode 100644 index a0390c491..000000000 --- a/tests/Mindee.UnitTests/V1/Workflow/WorklowTest.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System.Text.Json; -using Mindee.Input; -using Mindee.Pdf; -using Mindee.V1; -using Mindee.V1.Http; -using Mindee.V1.Parsing.Common; -using Mindee.V1.Product.Generated; -using Moq; - -namespace Mindee.UnitTests.V1.Workflow -{ - [Trait("Category", "V1")] - [Trait("Category", "Workflow")] - public abstract class WorklowTest - { - private readonly Client client; - private readonly Mock mindeeApi; - private readonly Mock mockedClient; - - protected WorklowTest() - { - mindeeApi = new Mock(); - var pdfOperation = new Mock(); - client = new Client(pdfOperation.Object, mindeeApi.Object); - mockedClient = new Mock(); - } - - [Fact] - public async Task GivenAWorkflowMockFileShouldReturnAValidWorkflowObject() - { - var file = new FileInfo(Constants.ResourcePath + "file_types/pdf/blank_1.pdf"); - var workflowResponse = - new WorkflowResponse { Execution = new Execution(), ApiRequest = null }; - - mindeeApi.Setup(api => api.PostWorkflowExecution( - It.IsAny(), - It.IsAny())) - .ReturnsAsync(workflowResponse); - - // Act - var execution = await client.ExecuteWorkflowAsync( - "", - new LocalInputSource(file)); - - // Assert - Assert.NotNull(execution); - mindeeApi.Verify(api => api.PostWorkflowExecution( - It.IsAny(), - It.IsAny()), Times.Once); - } - - [Fact] - public async Task SendingADocumentToAnExecutionShouldDeserializeResponseCorrectly() - { - var jsonFile = File.ReadAllText(Constants.V1ResourcePath + "workflows/success.json"); - var mockResponse = JsonSerializer.Deserialize>(jsonFile); - - mockedClient.Setup(mindeeClient => mindeeClient.ExecuteWorkflowAsync( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny())) - .ReturnsAsync(mockResponse); - - var workflowId = "07ebf237-ff27-4eee-b6a2-425df4a5cca6"; - var filePath = "Resources/products/financial_document/default_sample.jpg"; - var inputSource = new LocalInputSource(filePath); - - // Act - var response = await mockedClient.Object.ExecuteWorkflowAsync(workflowId, inputSource); - - // Assert - Assert.NotNull(response); - Assert.NotNull(response.ApiRequest); - Assert.Null(response.Execution.BatchName); - Assert.Null(response.Execution.CreatedAt); - Assert.Null(response.Execution.File.Alias); - Assert.Equal("default_sample.jpg", response.Execution.File.Name); - Assert.Equal("8c75c035-e083-4e77-ba3b-7c3598bd1d8a", response.Execution.Id); - Assert.Null(response.Execution.Inference); - Assert.Equal(ExecutionPriority.Medium, response.Execution.Priority); - Assert.Null(response.Execution.ReviewedAt); - Assert.Null(response.Execution.ReviewedPrediction); - Assert.Equal("processing", response.Execution.Status); - Assert.Equal("manual", response.Execution.Type); - Assert.Equal("2024-11-13T13:02:31.699190", - response.Execution.UploadedAt?.ToString("yyyy-MM-ddTHH:mm:ss.ffffff")); - Assert.Equal(workflowId, response.Execution.WorkflowId); - - mockedClient.Verify(mindeeClient => mindeeClient.ExecuteWorkflowAsync( - workflowId, - It.Is(source => source.Filename == inputSource.Filename), - It.IsAny(), - It.IsAny()), Times.Once); - } - - [Fact] - public async Task SendingADocumentToAnExecutionWithPriorityAndAliasShouldDeserializeResponseCorrectly() - { - var jsonFile = File.ReadAllText(Constants.V1ResourcePath + "workflows/success_low_priority.json"); - var mockResponse = JsonSerializer.Deserialize>(jsonFile); - - mockedClient.Setup(mindeeClient => mindeeClient.ExecuteWorkflowAsync( - It.IsAny(), - It.IsAny(), - It.IsAny(), - It.IsAny())) - .ReturnsAsync(mockResponse); - - var workflowId = "07ebf237-ff27-4eee-b6a2-425df4a5cca6"; - var filePath = Constants.V1ProductPath + "financial_document/default_sample.jpg"; - var inputSource = new LocalInputSource(filePath); - - // Act - var response = await mockedClient.Object.ExecuteWorkflowAsync(workflowId, inputSource); - - // Assert - Assert.NotNull(response); - Assert.NotNull(response.ApiRequest); - Assert.Null(response.Execution.BatchName); - Assert.Null(response.Execution.CreatedAt); - Assert.Equal("low-priority-sample-test", response.Execution.File.Alias); - Assert.Equal("default_sample.jpg", response.Execution.File.Name); - Assert.Equal("b743e123-e18c-4b62-8a07-811a4f72afd3", response.Execution.Id); - Assert.Null(response.Execution.Inference); - Assert.Equal(ExecutionPriority.Low, response.Execution.Priority); - Assert.Null(response.Execution.ReviewedAt); - Assert.Null(response.Execution.ReviewedPrediction); - Assert.Equal("processing", response.Execution.Status); - Assert.Equal("manual", response.Execution.Type); - Assert.Equal("2024-11-13T13:17:01.315179", - response.Execution.UploadedAt?.ToString("yyyy-MM-ddTHH:mm:ss.ffffff")); - Assert.Equal(workflowId, response.Execution.WorkflowId); - - mockedClient.Verify(mindeeClient => mindeeClient.ExecuteWorkflowAsync( - workflowId, - It.Is(source => source.Filename == inputSource.Filename), - It.IsAny(), - It.IsAny()), Times.Once); - } - } -}