@@ -310,9 +310,8 @@ class _FlowBuilderState:
310
310
engine_flow_builder : _engine .FlowBuilder
311
311
field_name_builder : _NameBuilder
312
312
313
- def __init__ (self , / , name : str | None = None ):
314
- flow_name = _flow_name_builder .build_name (name , prefix = "_flow_" )
315
- self .engine_flow_builder = _engine .FlowBuilder (get_full_flow_name (flow_name ))
313
+ def __init__ (self , full_name : str ):
314
+ self .engine_flow_builder = _engine .FlowBuilder (full_name )
316
315
self .field_name_builder = _NameBuilder ()
317
316
318
317
def get_data_slice (self , v : Any ) -> _engine .DataSlice :
@@ -464,9 +463,13 @@ class Flow:
464
463
"""
465
464
A flow describes an indexing pipeline.
466
465
"""
466
+ _name : str
467
+ _full_name : str
467
468
_lazy_engine_flow : Callable [[], _engine .Flow ]
468
469
469
- def __init__ (self , engine_flow_creator : Callable [[], _engine .Flow ]):
470
+ def __init__ (self , name : str , full_name : str , engine_flow_creator : Callable [[], _engine .Flow ]):
471
+ self ._name = name
472
+ self ._full_name = full_name
470
473
engine_flow = None
471
474
lock = Lock ()
472
475
def _lazy_engine_flow () -> _engine .Flow :
@@ -497,7 +500,7 @@ def build_tree(label: str, lines: list):
497
500
tree .children .append (section_node )
498
501
return tree
499
502
500
- def _get_spec (self , verbose : bool = False ) -> list [ tuple [ str , str , int ]] :
503
+ def _get_spec (self , verbose : bool = False ) -> _engine . RenderedSpec :
501
504
return self ._lazy_engine_flow ().get_spec (output_mode = "verbose" if verbose else "concise" )
502
505
503
506
def _get_schema (self ) -> list [tuple [str , str , str ]]:
@@ -509,12 +512,19 @@ def __str__(self):
509
512
def __repr__ (self ):
510
513
return repr (self ._lazy_engine_flow ())
511
514
515
+ @property
516
+ def name (self ) -> str :
517
+ """
518
+ Get the name of the flow.
519
+ """
520
+ return self ._name
521
+
512
522
@property
513
523
def full_name (self ) -> str :
514
524
"""
515
525
Get the full name of the flow.
516
526
"""
517
- return self ._lazy_engine_flow (). name ()
527
+ return self ._full_name
518
528
519
529
def update (self ) -> _engine .IndexUpdateInfo :
520
530
"""
@@ -555,14 +565,16 @@ def _create_lazy_flow(name: str | None, fl_def: Callable[[FlowBuilder, DataScope
555
565
Create a flow without really building it yet.
556
566
The flow will be built the first time when it's really needed.
557
567
"""
568
+ flow_name = _flow_name_builder .build_name (name , prefix = "_flow_" )
569
+ flow_full_name = get_full_flow_name (flow_name )
558
570
def _create_engine_flow () -> _engine .Flow :
559
- flow_builder_state = _FlowBuilderState (name = name )
571
+ flow_builder_state = _FlowBuilderState (flow_full_name )
560
572
root_scope = DataScope (
561
573
flow_builder_state , flow_builder_state .engine_flow_builder .root_scope ())
562
574
fl_def (FlowBuilder (flow_builder_state ), root_scope )
563
575
return flow_builder_state .engine_flow_builder .build_flow (execution_context .event_loop )
564
576
565
- return Flow (_create_engine_flow )
577
+ return Flow (flow_name , flow_full_name , _create_engine_flow )
566
578
567
579
568
580
_flows_lock = Lock ()
@@ -695,7 +707,7 @@ async def _flow_info_async(self) -> TransformFlowInfo:
695
707
return self ._lazy_flow_info
696
708
697
709
async def _build_flow_info_async (self ) -> TransformFlowInfo :
698
- flow_builder_state = _FlowBuilderState (name = self ._flow_name )
710
+ flow_builder_state = _FlowBuilderState (self ._flow_name )
699
711
sig = inspect .signature (self ._flow_fn )
700
712
if len (sig .parameters ) != len (self ._flow_arg_types ):
701
713
raise ValueError (
0 commit comments