Skip to content
Merged
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
24 changes: 0 additions & 24 deletions docs/code_samples/workflow_execution.txt

This file was deleted.

79 changes: 0 additions & 79 deletions src/V1/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,56 +227,6 @@ private function makeEnqueueRequest(
return new AsyncPredictResponse($predictionType, $response['data']);
}

/**
* Makes the request to send a document to a workflow.
*
* @param string $predictionType Name of the product's class.
* @param InputSource $inputDoc Input file.
* @param string $workflowId ID of the workflow.
* @param PredictMethodOptions $options Prediction Options.
* @throws MindeeV1HttpException Throws if the API sent an error.
* @throws MindeeApiException Throws if the API sent an error,
* or if the prediction type isn't recognized or if a field can't be deserialized.
*/
private function makeWorkflowExecutionRequest(
string $predictionType,
InputSource $inputDoc,
string $workflowId,
PredictMethodOptions $options
): WorkflowResponse {
$workflowRouterSettings = new MindeeWorkflowApi($this->apiKey, $workflowId);
$options->endpoint = new WorkflowEndpoint($workflowRouterSettings);
if (!$options->pageOptions->isEmpty()) {
if ($inputDoc instanceof LocalInputSource) {
$this->cutDocPages($inputDoc, $options->pageOptions);
} else {
throw new MindeeApiException(
"Cannot edit non-local input sources.",
ErrorCode::USER_OPERATION_ERROR
);
}
}
$response = ResponseValidation::cleanRequestData($options->endpoint->executeWorkflowRequestPost(
$inputDoc,
$options->workflowOptions
));
if (!ResponseValidation::isValidWorkflowResponse($response)) {
throw MindeeV1HttpException::handleError(
"workflows/$workflowId/executions",
$response
);
}
try {
return new WorkflowResponse($predictionType, $response['data']);
} catch (Exception $e) {
throw new MindeeApiException(
"Unable to create workflow response for $predictionType",
ErrorCode::API_UNPROCESSABLE_ENTITY,
previous: $e
);
}
}

/**
* Makes the request to send a document to a synchronous endpoint.
*
Expand Down Expand Up @@ -462,33 +412,4 @@ public function loadPrediction(
);
}
}

/**
* Sends a document to a workflow.
*
* @param InputSource $inputDoc Input File.
* @param string $workflowId ID of the workflow.
* @param WorkflowOptions|null $options Prediction Options.
* @param PageOptions|null $pageOptions Options to apply to the PDF file.
*/
public function executeWorkflow(
InputSource $inputDoc,
string $workflowId,
?WorkflowOptions $options = null,
?PageOptions $pageOptions = null
): WorkflowResponse {
$options ??= new WorkflowOptions();
if ($pageOptions !== null && $inputDoc instanceof LocalInputSource && $inputDoc->isPdf()) {
$this->cutDocPages($inputDoc, $pageOptions);
}

$predictMethodOptions = new PredictMethodOptions();
$predictMethodOptions->setWorkflowOptions($options);
return $this->makeWorkflowExecutionRequest(
GeneratedV1::class,
$inputDoc,
$workflowId,
$predictMethodOptions
);
}
}
Comment thread
ianardee marked this conversation as resolved.
20 changes: 0 additions & 20 deletions tests/V1/Workflow/WorkflowTestFunctional.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,6 @@ protected function setUp(): void
);
}

public function testWorkflow(): void
{
$currentDateTime = date('Y-m-d-H:i:s');
$options = new WorkflowOptions(
"php-" . $currentDateTime,
"low",
false,
null,
true
);
$response = $this->mindeeClient->executeWorkflow(
$this->inputSource,
$this->workflowId,
$options
);
self::assertSame(202, $response->apiRequest->statusCode);
self::assertSame("php-$currentDateTime", $response->execution->file->alias);
self::assertSame("low", $response->execution->priority);
}

public function testWorkflowPollingWithRAG(): void
{
$options = new PredictMethodOptions();
Expand Down
Loading