1313import polars as pl
1414from pydantic import validate_arguments
1515
16+ from dve .core_engine .exceptions import CriticalProcessingError
17+ from dve .core_engine .message import FeedbackMessage
1618import dve .reporting .excel_report as er
1719from dve .core_engine .backends .base .auditing import BaseAuditingManager
1820from dve .core_engine .backends .base .contract import BaseDataContract
1921from dve .core_engine .backends .base .core import EntityManager
2022from dve .core_engine .backends .base .reference_data import BaseRefDataLoader
2123from dve .core_engine .backends .base .rules import BaseStepImplementations
22- from dve .core_engine .backends .exceptions import MessageBearingError
24+ from dve .core_engine .backends .exceptions import (
25+ BackendError ,
26+ MessageBearingError ,
27+ ReaderLacksEntityTypeSupport ,
28+ )
2329from dve .core_engine .backends .readers import BaseFileReader
2430from dve .core_engine .backends .types import EntityType
2531from dve .core_engine .backends .utilities import dump_errors , stringify_model
@@ -44,13 +50,13 @@ class BaseDVEPipeline:
4450 def __init__ (
4551 self ,
4652 audit_tables : BaseAuditingManager ,
47- job_run_id : int ,
4853 data_contract : BaseDataContract ,
4954 step_implementations : Optional [BaseStepImplementations [EntityType ]],
5055 rules_path : Optional [URI ],
5156 processed_files_path : Optional [URI ],
5257 submitted_files_path : Optional [URI ],
5358 reference_data_loader : Optional [type [BaseRefDataLoader ]] = None ,
59+ job_run_id : Optional [int ] = None ,
5460 ):
5561 self ._submitted_files_path = submitted_files_path
5662 self ._processed_files_path = processed_files_path
@@ -265,30 +271,41 @@ def file_transformation(
265271 if not self .processed_files_path :
266272 raise AttributeError ("processed files path not provided" )
267273
274+ errors : list [FeedbackMessage ] = []
268275 submission_file_uri : URI = fh .joinuri (
269276 self .processed_files_path ,
270277 submission_info .submission_id ,
271278 submission_info .file_name_with_ext ,
272279 )
273280 try :
274- errors = self .write_file_to_parquet (
281+ errors . extend ( self .write_file_to_parquet (
275282 submission_file_uri , submission_info , self .processed_files_path
276- )
277- if errors :
278- dump_errors (
279- fh .joinuri (self .processed_files_path , submission_info .submission_id ),
280- "file_transformation" ,
281- errors ,
282- )
283- return submission_info .dict ()
284- return submission_info
285- except ValueError as exc :
286- self ._logger .error (f"File transformation write_file_to_parquet raised error: { exc } " )
287- return submission_info .dict ()
288- except Exception as exc : # pylint: disable=broad-except
283+ ))
284+
285+ except MessageBearingError as exc :
286+ self ._logger .error (f"Unexpected file transformation error: { exc } " )
287+ self ._logger .exception (exc )
288+ errors .extend (exc .messages )
289+
290+ except BackendError as exc : # pylint: disable=broad-except
289291 self ._logger .error (f"Unexpected file transformation error: { exc } " )
290292 self ._logger .exception (exc )
293+ errors .extend ([
294+ CriticalProcessingError (
295+ entities = None ,
296+ error_message = repr (exc ),
297+ messages = [],
298+ ).to_feedback_message ()
299+ ])
300+
301+ if errors :
302+ dump_errors (
303+ fh .joinuri (self .processed_files_path , submission_info .submission_id ),
304+ "file_transformation" ,
305+ errors ,
306+ )
291307 return submission_info .dict ()
308+ return submission_info
292309
293310 def file_transformation_step (
294311 self , pool : Executor , submissions_to_process : list [SubmissionInfo ]
@@ -321,6 +338,7 @@ def file_transformation_step(
321338 except Exception as exc : # pylint: disable=W0703
322339 self ._logger .error (f"File transformation raised exception: { exc } " )
323340 self ._logger .exception (exc )
341+ # TODO: write errors to file here (maybe processing errors - not to be seen by end user)
324342 failed_processing .append (sub_info )
325343 continue
326344
@@ -423,6 +441,7 @@ def data_contract_step(
423441 except Exception as exc : # pylint: disable=W0703
424442 self ._logger .error (f"Data Contract raised exception: { exc } " )
425443 self ._logger .exception (exc )
444+ # TODO: write errors to file here (maybe processing errors - not to be seen by end user)
426445 failed_processing .append (sub_info )
427446 continue
428447
@@ -562,6 +581,7 @@ def business_rule_step(
562581 except Exception as exc : # pylint: disable=W0703
563582 self ._logger .error (f"Business Rules raised exception: { exc } " )
564583 self ._logger .exception (exc )
584+ # TODO: write errors to file here (maybe processing errors - not to be seen by end user)
565585 failed_processing .append (sub_info )
566586 continue
567587
0 commit comments