hyperopt - freqai - docs and refactoring

This commit is contained in:
Wagner Costa Santos
2022-09-06 15:42:47 -03:00
parent 1820bc6832
commit 8d16dd804d
5 changed files with 29 additions and 111 deletions

View File

@@ -93,16 +93,6 @@ class FreqaiDataDrawer:
"model_filename": "", "trained_timestamp": 0,
"priority": 1, "first": True, "data_path": "", "extras": {}}
def __getstate__(self):
"""
Return state values to be pickled.
It's necessary to allow serialization in hyperopt
"""
return ({
"pair_dict": self.pair_dict,
"pair_dictionary_path": self.pair_dictionary_path
})
def load_drawer_from_disk(self):
"""
Locate and load a previously saved data drawer full of all pair model metadata in
@@ -165,22 +155,14 @@ class FreqaiDataDrawer:
# create a backup
shutil.copy(self.historic_predictions_path, self.historic_predictions_bkp_path)
def save_drawer_to_disk(self, live=False):
def save_drawer_to_disk(self):
"""
Save data drawer full of all pair model metadata in present model folder.
"""
if live:
with self.save_lock:
with open(self.pair_dictionary_path, 'w') as fp:
rapidjson.dump(
self.pair_dict, fp, default=self.np_encoder,
number_mode=rapidjson.NM_NATIVE)
else:
# save_lock it's not working with hyperopt
with self.save_lock:
with open(self.pair_dictionary_path, 'w') as fp:
rapidjson.dump(
self.pair_dict, fp, default=self.np_encoder,
number_mode=rapidjson.NM_NATIVE)
rapidjson.dump(self.pair_dict, fp, default=self.np_encoder,
number_mode=rapidjson.NM_NATIVE)
def save_follower_dict_to_disk(self):
"""
@@ -455,7 +437,7 @@ class FreqaiDataDrawer:
self.model_dictionary[coin] = model
self.pair_dict[coin]["model_filename"] = dk.model_filename
self.pair_dict[coin]["data_path"] = str(dk.data_path)
self.save_drawer_to_disk(dk.live)
self.save_drawer_to_disk()
return

View File

@@ -92,10 +92,9 @@ class IFreqaiModel(ABC):
def __getstate__(self):
"""
Return state values to be pickled.
It's necessary to allow serialization in hyperopt
Return an empty state to be pickled in hyperopt
"""
return ({"dd": self.dd})
return ({})
def assert_config(self, config: Dict[str, Any]) -> None: