2020
2121import pandas as pd
2222from colorama import Fore , Style
23+ from tqdm import tqdm
2324
2425from feast import utils
2526from feast .entity import Entity
@@ -341,6 +342,12 @@ def materialize_incremental(
341342 feature_view = self ._registry .get_feature_view (name , self .project )
342343 feature_views_to_materialize .append (feature_view )
343344
345+ _print_materialization_log (
346+ None ,
347+ end_date ,
348+ len (feature_views_to_materialize ),
349+ self .config .online_store .type ,
350+ )
344351 # TODO paging large loads
345352 for feature_view in feature_views_to_materialize :
346353 start_date = feature_view .most_recent_end_time
@@ -352,11 +359,23 @@ def materialize_incremental(
352359 )
353360 start_date = datetime .utcnow () - feature_view .ttl
354361 provider = self ._get_provider ()
355- _print_materialization_log (start_date , end_date , feature_view )
362+ print (
363+ f"{ Style .BRIGHT + Fore .GREEN } { feature_view .name } { Style .RESET_ALL } "
364+ f" from { Style .BRIGHT + Fore .GREEN } { start_date .replace (microsecond = 0 ).astimezone ()} { Style .RESET_ALL } "
365+ f" to { Style .BRIGHT + Fore .GREEN } { end_date .replace (microsecond = 0 ).astimezone ()} { Style .RESET_ALL } :"
366+ )
367+
368+ def tqdm_builder (length ):
369+ return tqdm (total = length , ncols = 100 )
370+
356371 provider .materialize_single_feature_view (
357- feature_view , start_date , end_date , self ._registry , self .project
372+ feature_view ,
373+ start_date ,
374+ end_date ,
375+ self ._registry ,
376+ self .project ,
377+ tqdm_builder ,
358378 )
359- print (" done!" )
360379
361380 def materialize (
362381 self ,
@@ -406,14 +425,28 @@ def materialize(
406425 feature_view = self ._registry .get_feature_view (name , self .project )
407426 feature_views_to_materialize .append (feature_view )
408427
428+ _print_materialization_log (
429+ start_date ,
430+ end_date ,
431+ len (feature_views_to_materialize ),
432+ self .config .online_store .type ,
433+ )
409434 # TODO paging large loads
410435 for feature_view in feature_views_to_materialize :
411436 provider = self ._get_provider ()
412- _print_materialization_log (start_date , end_date , feature_view )
437+ print (f"{ Style .BRIGHT + Fore .GREEN } { feature_view .name } { Style .RESET_ALL } :" )
438+
439+ def tqdm_builder (length ):
440+ return tqdm (total = length , ncols = 100 )
441+
413442 provider .materialize_single_feature_view (
414- feature_view , start_date , end_date , self ._registry , self .project
443+ feature_view ,
444+ start_date ,
445+ end_date ,
446+ self ._registry ,
447+ self .project ,
448+ tqdm_builder ,
415449 )
416- print (" done!" )
417450
418451 def get_online_features (
419452 self , feature_refs : List [str ], entity_rows : List [Dict [str , Any ]],
@@ -600,11 +633,19 @@ def _get_table_entity_keys(
600633 return entity_key_protos
601634
602635
603- def _print_materialization_log (start_date , end_date , feature_view ):
604- print (
605- f"Materializing feature view { Style .BRIGHT + Fore .GREEN } { feature_view .name } { Style .RESET_ALL } "
606- f" from { Style .BRIGHT + Fore .GREEN } { start_date .astimezone ()} { Style .RESET_ALL } "
607- f" to { Style .BRIGHT + Fore .GREEN } { end_date .astimezone ()} { Style .RESET_ALL } " ,
608- end = "" ,
609- flush = True ,
610- )
636+ def _print_materialization_log (
637+ start_date , end_date , num_feature_views : int , online_store : str
638+ ):
639+ if start_date :
640+ print (
641+ f"Materializing { Style .BRIGHT + Fore .GREEN } { num_feature_views } { Style .RESET_ALL } feature views"
642+ f" from { Style .BRIGHT + Fore .GREEN } { start_date .replace (microsecond = 0 ).astimezone ()} { Style .RESET_ALL } "
643+ f" to { Style .BRIGHT + Fore .GREEN } { end_date .replace (microsecond = 0 ).astimezone ()} { Style .RESET_ALL } "
644+ f" into the { Style .BRIGHT + Fore .GREEN } { online_store } { Style .RESET_ALL } online store.\n "
645+ )
646+ else :
647+ print (
648+ f"Materializing { Style .BRIGHT + Fore .GREEN } { num_feature_views } { Style .RESET_ALL } feature views"
649+ f" to { Style .BRIGHT + Fore .GREEN } { end_date .replace (microsecond = 0 ).astimezone ()} { Style .RESET_ALL } "
650+ f" into the { Style .BRIGHT + Fore .GREEN } { online_store } { Style .RESET_ALL } online store.\n "
651+ )
0 commit comments