ensure follower sends back null arrays in case leader hasnt created a model file yet

This commit is contained in:
robcaulk 2022-05-31 01:48:48 +02:00
parent 29d2f59f12
commit 45f4f0f603
2 changed files with 8 additions and 3 deletions

View File

@ -60,7 +60,9 @@ class FreqaiDataDrawer:
def get_pair_dict_info(self, metadata: dict) -> Tuple[str, int, bool, bool]:
pair_in_dict = self.pair_dict.get(metadata['pair'])
data_path_set = self.pair_dict.get(metadata['pair'], {}).get('data_path', None)
return_null_array = False
if pair_in_dict:
model_filename = self.pair_dict[metadata['pair']]['model_filename']
trained_timestamp = self.pair_dict[metadata['pair']]['trained_timestamp']
@ -70,9 +72,10 @@ class FreqaiDataDrawer:
model_filename = self.pair_dict[metadata['pair']]['model_filename'] = ''
coin_first = self.pair_dict[metadata['pair']]['first'] = True
trained_timestamp = self.pair_dict[metadata['pair']]['trained_timestamp'] = 0
else:
logger.warning(f'Follow mode could not find current pair {metadata["pair"]} in'
f'pair_dictionary at path {self.full_path}, sending null values'
if not data_path_set and self.follow_mode:
logger.warning(f'Follower could not find current pair {metadata["pair"]} in '
f'pair_dictionary at path {self.full_path}, sending null values '
'back to strategy.')
return_null_array = True

View File

@ -197,6 +197,7 @@ class IFreqaiModel(ABC):
# if the files do not yet exist, the follower returns null arrays to strategy
if self.follow_mode and return_null_array:
logger.info('Returning null array from follower')
self.data_drawer.return_null_values_to_strategy(dataframe, dh)
return dh
@ -225,6 +226,7 @@ class IFreqaiModel(ABC):
elif self.training_on_separate_thread and not self.follow_mode:
logger.info("FreqAI training a new model on background thread.")
elif self.follow_mode:
dh.set_paths(metadata, trained_timestamp)
logger.info('FreqAI instance set to follow_mode, finding existing pair'
f'using { self.identifier }')