improve multithreaded training queue system

This commit is contained in:
robcaulk
2022-05-24 15:28:38 +02:00
parent 31ae2b3060
commit 58b5abbaa6
2 changed files with 22 additions and 5 deletions

View File

@@ -18,7 +18,7 @@ class FreqaiDataDrawer:
This object remains persistent throughout live/dry, unlike FreqaiDataKitchen, which is
reinstantiated for each coin.
"""
def __init__(self, full_path: Path):
def __init__(self, full_path: Path, pair_whitelist):
# dictionary holding all pair metadata necessary to load in from disk
self.pair_dict: Dict[str, Any] = {}
@@ -27,6 +27,8 @@ class FreqaiDataDrawer:
self.pair_data_dict: Dict[str, Any] = {}
self.full_path = full_path
self.load_drawer_from_disk()
self.training_queue: Dict[str, int] = {}
self.create_training_queue(pair_whitelist)
def load_drawer_from_disk(self):
exists = Path(self.full_path / str('pair_dictionary.json')).resolve().exists()
@@ -71,3 +73,15 @@ class FreqaiDataDrawer:
self.pair_dict[metadata['pair']]['trained_timestamp'] = 0
self.pair_dict[metadata['pair']]['priority'] = 1
return
def create_training_queue(self, pairs: list) -> None:
for i, pair in enumerate(pairs):
self.training_queue[pair] = i + 1
def pair_to_end_of_training_queue(self, pair: str) -> None:
# march all pairs up in the queue
for p in self.training_queue:
self.training_queue[p] -= 1
# send pair to end of queue
self.training_queue[pair] = len(self.training_queue)