4545from dve .core_engine .backends .types import Entities , EntityType , StageSuccessful
4646from dve .core_engine .exceptions import CriticalProcessingError
4747from dve .core_engine .loggers import get_logger
48- from dve .core_engine .type_hints import URI , EntityName , Messages , TemplateVariables
48+ from dve .core_engine .type_hints import URI , DVEStageName , EntityName , Messages , TemplateVariables
4949
5050T_contra = TypeVar ("T_contra" , bound = AbstractStep , contravariant = True )
5151T = TypeVar ("T" , bound = AbstractStep )
@@ -88,6 +88,10 @@ class BaseStepImplementations(Generic[EntityType], ABC): # pylint: disable=too-
8888
8989 This will be populated from the generic annotation at class creation time.
9090
91+ """
92+ __stage_name__ : DVEStageName = "business_rules"
93+ """
94+ The name of the business rules DVE stage for use in auditing and logging
9195 """
9296
9397 def __init_subclass__ (cls , * _ , ** __ ) -> None :
@@ -367,13 +371,13 @@ def apply_sync_filters(
367371
368372 """
369373 filters_by_entity : dict [EntityName , list [DeferredFilter ]] = defaultdict (list )
370- feedback_errors_uri = get_feedback_errors_uri (working_directory , "business_rules" )
374+ feedback_errors_uri = get_feedback_errors_uri (working_directory , self . __stage_name__ )
371375 for rule in filters :
372376 filters_by_entity [rule .entity_name ].append (rule )
373377
374378 with BackgroundMessageWriter (
375379 working_directory = working_directory ,
376- dve_stage = "business_rules" ,
380+ dve_stage = self . __stage_name__ ,
377381 key_fields = key_fields ,
378382 logger = self .logger ,
379383 ) as msg_writer :
@@ -402,7 +406,7 @@ def apply_sync_filters(
402406 if not success :
403407 processing_errors_uri = dump_processing_errors (
404408 working_directory ,
405- "business_rules" ,
409+ self . __stage_name__ ,
406410 [
407411 CriticalProcessingError (
408412 "Issue occurred while applying filter logic" ,
@@ -431,7 +435,7 @@ def apply_sync_filters(
431435 if not success :
432436 processing_errors_uri = dump_processing_errors (
433437 working_directory ,
434- "business_rules" ,
438+ self . __stage_name__ ,
435439 [
436440 CriticalProcessingError (
437441 "Issue occurred while generating FeedbackMessages" ,
@@ -459,7 +463,7 @@ def apply_sync_filters(
459463 if not success :
460464 processing_errors_uri = dump_processing_errors (
461465 working_directory ,
462- "business_rules" ,
466+ self . __stage_name__ ,
463467 [
464468 CriticalProcessingError (
465469 "Issue occurred while generating FeedbackMessages" ,
@@ -497,7 +501,7 @@ def apply_sync_filters(
497501 if not success :
498502 processing_errors_uri = dump_processing_errors (
499503 working_directory ,
500- "business_rules" ,
504+ self . __stage_name__ ,
501505 [
502506 CriticalProcessingError (
503507 "Issue occurred while filtering error records" ,
@@ -525,7 +529,7 @@ def apply_sync_filters(
525529 if not success :
526530 processing_errors_uri = dump_processing_errors (
527531 working_directory ,
528- "business_rules" ,
532+ self . __stage_name__ ,
529533 [
530534 CriticalProcessingError (
531535 "Issue occurred while generating FeedbackMessages" ,
@@ -555,7 +559,7 @@ def apply_rules(
555559 """
556560 self .logger .info ("Applying business rules" )
557561 rules_and_locals : Iterable [tuple [Rule , TemplateVariables ]]
558- errors_uri = get_feedback_errors_uri (working_directory , "business_rules" )
562+ errors_uri = get_feedback_errors_uri (working_directory , self . __stage_name__ )
559563 if rule_metadata .templating_strategy == "upfront" :
560564 rules_and_locals = []
561565 for rule , local_variables in rule_metadata :
@@ -584,7 +588,7 @@ def apply_rules(
584588 if not success :
585589 processing_errors_uri = dump_processing_errors (
586590 working_directory ,
587- "business_rules" ,
591+ self . __stage_name__ ,
588592 [
589593 CriticalProcessingError (
590594 "Issue occurred while applying pre filter steps" ,
@@ -593,14 +597,16 @@ def apply_rules(
593597 ],
594598 )
595599 if pre_sync_messages :
596- dump_feedback_errors (working_directory , "business_rules" , pre_sync_messages )
600+ dump_feedback_errors (
601+ working_directory , self .__stage_name__ , pre_sync_messages
602+ )
597603
598604 return processing_errors_uri , False
599605 # if not a failure, ensure we keep track of any informational messages
600606 pre_sync_messages .extend (stage_messages )
601607 # if all successful, ensure we write out all informational messages
602608 if pre_sync_messages :
603- dump_feedback_errors (working_directory , "business_rules" , pre_sync_messages )
609+ dump_feedback_errors (working_directory , self . __stage_name__ , pre_sync_messages )
604610
605611 sync_steps = []
606612 for rule , local_variables in rules_and_locals :
@@ -634,7 +640,7 @@ def apply_rules(
634640 if not success :
635641 processing_errors_uri = dump_processing_errors (
636642 working_directory ,
637- "business_rules" ,
643+ self . __stage_name__ ,
638644 [
639645 CriticalProcessingError (
640646 "Issue occurred while applying post filter steps" ,
@@ -644,15 +650,15 @@ def apply_rules(
644650 )
645651 if post_sync_messages :
646652 dump_feedback_errors (
647- working_directory , "business_rules" , post_sync_messages
653+ working_directory , self . __stage_name__ , post_sync_messages
648654 )
649655
650656 return processing_errors_uri , False
651657 # if not a failure, ensure we keep track of any informational messages
652658 post_sync_messages .extend (stage_messages )
653659 # if all successful, ensure we write out all informational messages
654660 if post_sync_messages :
655- dump_feedback_errors (working_directory , "business_rules" , post_sync_messages )
661+ dump_feedback_errors (working_directory , self . __stage_name__ , post_sync_messages )
656662 return errors_uri , True
657663
658664 def read_parquet (self , path : URI , ** kwargs ) -> EntityType :
0 commit comments