1414from fbclient .event_types import FlagEvent , Metric , MetricEvent , UserEvent
1515from fbclient .interfaces import DataUpdateStatusProvider
1616from fbclient .status import DataUpdateStatusProviderImpl
17- from fbclient .status_types import State
1817from fbclient .streaming import Streaming , _data_to_dict
1918from fbclient .update_processor import NullUpdateProcessor
2019from fbclient .utils import (cast_variation_by_flag_type , check_uwsgi , log ,
@@ -67,7 +66,10 @@ def __init__(self, config: Config, start_wait: float = 15.):
6766 raise ValueError ("Config is not valid" )
6867
6968 self ._config = config
70- self ._config .validate ()
69+ if self ._config .is_offline :
70+ log .info ("FB Python SDK: SDK is in offline mode" )
71+ else :
72+ self ._config .validate ()
7173
7274 # init components
7375 # event processor
@@ -90,15 +92,11 @@ def __init__(self, config: Config, start_wait: float = 15.):
9092 if not isinstance (self ._update_processor , NullUpdateProcessor ):
9193 log .info ("FB Python SDK: Waiting for Client initialization in %s seconds" % str (start_wait ))
9294
93- if isinstance (self ._data_storage , NullDataStorage ) or not self ._data_storage .initialized :
95+ if isinstance (self ._data_storage , NullDataStorage ) or ( not self ._data_storage .initialized and not self . _config . is_offline ) :
9496 log .warning ("FB Python SDK: SDK just returns default variation because of no data found in the given environment" )
9597
9698 update_processor_ready .wait (start_wait )
97- if self ._config .is_offline :
98- log .info ("FB Python SDK: SDK is in offline mode" )
99- elif self ._update_processor .initialized :
100- log .info ("FB Python SDK: SDK initialization is completed" )
101- else :
99+ if not self ._update_processor .initialized :
102100 log .warning ("FB Python SDK: SDK was not successfully initialized" )
103101 else :
104102 log .info ("FB Python SDK: SDK starts in asynchronous mode" )
@@ -374,13 +372,10 @@ def initialize_from_external_json(self, json_str: str) -> bool:
374372 :param json_str: feature flags, segments...etc in the json format
375373 :return: True if the initialization is well done
376374 """
377- if self ._config .is_offline and json_str :
375+ if self ._config .is_offline :
378376 all_data = json .loads (json_str )
379377 if valide_all_data (all_data ):
380378 version , data = _data_to_dict (all_data ['data' ])
381- res = self ._update_status_provider .init (data , version )
382- if res :
383- self ._update_status_provider .update_state (State .ok_state ())
384- return res
379+ return self ._update_status_provider .init (data , version )
385380
386381 return False
0 commit comments