Switch from local_env to Docker for running Qlib

This commit is contained in:
WinstonLiyt
2024-07-12 03:30:25 +00:00
parent 033589bbe0
commit 6fb12fc753
2 changed files with 8 additions and 6 deletions
@@ -106,13 +106,15 @@ class QlibFactorRunner(TaskGenerator[QlibFactorExperiment]):
combined_factors = combined_factors.sort_index()
new_columns = pd.MultiIndex.from_product([['feature'], combined_factors.columns])
combined_factors.columns = new_columns
# logger.info(combined_factors)
# Save the combined factors to a pickle file
combined_factors_path = DIRNAME / 'env_factor/combined_factors_df.pkl'
with open(combined_factors_path, 'wb') as f:
pickle.dump(combined_factors, f)
""" Docker run
# Docker run
# Call Docker, pass the combined factors to Docker, and generate backtest results
qtde = QTDockerEnv()
qtde.prepare()
@@ -132,8 +134,8 @@ class QlibFactorRunner(TaskGenerator[QlibFactorExperiment]):
with open(pkl_path, 'rb') as f:
result = pickle.load(f)
"""
"""
# TODO: Implement the Docker run in the following way
# Local run
# Clean up any previous run artifacts by deleting the mlruns directory
@@ -166,9 +168,9 @@ class QlibFactorRunner(TaskGenerator[QlibFactorExperiment]):
with open(pickle_file, 'rb') as f:
result = pickle.load(f)
"""
exp.result = result
# Check if the result is valid and is a DataFrame
if isinstance(result, pd.DataFrame):
if not result.empty:
+1 -1
View File
@@ -125,7 +125,7 @@ class DockerConf(BaseModel):
QLIB_TORCH_IMAGE = DockerConf(
image="linlanglv/qlib_image_nightly_pytorch:nightly",
image="linlanglv/qlib_image_nightly_pytorch:240711",
mount_path="/workspace",
default_entry="qrun conf.yaml",
extra_volumes={Path("~/.qlib/").expanduser().resolve(): "/root/.qlib/"},