use importlib instead of __import___

This commit is contained in:
robcaulk 2022-11-24 19:04:35 +01:00
parent 00d2a01bf0
commit 73c458d47b

View File

@ -1,4 +1,5 @@
import collections import collections
import importlib
import logging import logging
import re import re
import shutil import shutil
@ -573,8 +574,8 @@ class FreqaiDataDrawer:
from tensorflow import keras from tensorflow import keras
model = keras.models.load_model(dk.data_path / f"{dk.model_filename}_model.h5") model = keras.models.load_model(dk.data_path / f"{dk.model_filename}_model.h5")
elif self.model_type == 'stable_baselines': elif self.model_type == 'stable_baselines':
mod = __import__('stable_baselines3', fromlist=[ mod = importlib.import_module(
self.freqai_info['rl_config']['model_type']]) 'stable_baselines3', self.freqai_info['rl_config']['model_type'])
MODELCLASS = getattr(mod, self.freqai_info['rl_config']['model_type']) MODELCLASS = getattr(mod, self.freqai_info['rl_config']['model_type'])
model = MODELCLASS.load(dk.data_path / f"{dk.model_filename}_model") model = MODELCLASS.load(dk.data_path / f"{dk.model_filename}_model")