Skip to content

Commit

Permalink
fix/text-extractor-fix-workflow (#638)
Browse files Browse the repository at this point in the history
* text exrtactor fix backend workflow changes

* small change on error log

* Update backend/workflow_manager/endpoint/destination.py

Co-authored-by: Hari John Kuriakose <[email protected]>
Signed-off-by: Chandrasekharan M <[email protected]>

* Fixed flake8 issue

---------

Signed-off-by: Chandrasekharan M <[email protected]>
Co-authored-by: Chandrasekharan M <[email protected]>
Co-authored-by: Hari John Kuriakose <[email protected]>
Co-authored-by: Chandrasekharan M <[email protected]>
  • Loading branch information
4 people authored Sep 20, 2024
1 parent c9bfbfd commit 012ffdf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions backend/workflow_manager/endpoint/destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
import logging
import os
from typing import Any, Optional
from typing import Any, Optional, Union

import fsspec
import magic
Expand Down Expand Up @@ -279,7 +279,10 @@ def insert_into_db(self, input_file_path: str) -> None:
if not data:
return
# Remove metadata from result
data.pop("metadata", None)
# Tool text-extractor returns data in the form of string.
# Don't pop out metadata in this case.
if isinstance(data, dict):
data.pop("metadata", None)
values = DatabaseUtils.get_columns_and_values(
column_mode_str=column_mode,
data=data,
Expand Down Expand Up @@ -404,7 +407,7 @@ def get_result(self, file_history: Optional[FileHistory] = None) -> Optional[Any
output_file = os.path.join(self.execution_dir, WorkflowFileType.INFILE)
metadata: dict[str, Any] = self.get_workflow_metadata()
output_type = self.get_output_type(metadata)
result: Optional[Any] = None
result: Union[dict[str, Any], str] = ""
try:
# TODO: SDK handles validation; consider removing here.
mime = magic.Magic()
Expand Down

0 comments on commit 012ffdf

Please sign in to comment.