AI4Finance-Foundation / ElegantRL

Massively Parallel Deep Reinforcement Learning. 🔥
https://ai4finance.org
Other
3.62k stars 833 forks source link

Missing module "init_agent" in run.py #314

Open jiahau3 opened 1 year ago

jiahau3 commented 1 year ago

While testing the FinRL_MultiCrypto_Trading.ipynb notebook, it throws out an error in the following

ImportError Traceback (most recent call last) in <cell line: 1>() ----> 1 from agents.elegantrl_models import DRLAgent as DRLAgent_erl 2 from agents.rllib_models import DRLAgent as DRLAgent_rllib 3 from agents.stablebaselines3_models import DRLAgent as DRLAgent_sb3 4 from meta.data_processor import DataProcessor 5

/FinRL-Meta/agents/elegantrl_models.py in 6 from elegantrl.agents import AgentTD3 7 from elegantrl.train.config import Config ----> 8 from elegantrl.train.run import init_agent 9 from elegantrl.train.run import train_and_evaluate 10

ImportError: cannot import name 'init_agent' from 'elegantrl.train.run' (/usr/local/lib/python3.10/site-packages/elegantrl/train/run.py)

It looks like the function is removed and it was there in the previous version of run.py. Wondering if which version is proper for the notebook? Is it better to find the recent one which the function still exist to run or editing the notebook?

Many thanks in advance!

jiahau3 commented 1 year ago

@Yonv1943 Hi! Thanks for maintaining the code. I'd like to know how to use this version of script to run on the notebook FinRL_MultiCrypto_Trading.ipynb in FinRL tutorial repo.

CauchY75 commented 1 year ago

Same Error here !

Python version : 3.10.12

1) ImportError: cannot import name 'Arguments' from 'elegantrl.train.config 2) ImportError: cannot import name 'init_agent' from 'elegantrl.train.run'

Does anyone resolve this error ?

Quakumei commented 1 year ago

Same Error here !

Python version : 3.10.12

  1. ImportError: cannot import name 'Arguments' from 'elegantrl.train.config
  2. ImportError: cannot import name 'init_agent' from 'elegantrl.train.run'

Does anyone resolve this error ?

ImportError with Arguments is resolved when Arguments is changed to Config as mentioned in #256

According to https://github.com/AI4Finance-Foundation/FinRL/issues/450, that issue can be resolved by downgrading ElegantRL to version before 0.3.3, however other ImportError appear, namely, on ElegantRL 0.3.1, inability to import from elegantrl.agents.

Similar work on adapting notebooks to up-to-date version of ElegantRL is currently being made in #325, however, it doesn't seem completely relevant, although I haven't really looked into the changes.

However, the problem is not in the ElegantRL getting updates, the issue is in FinRL-meta repo which has not been updated to match new versions of ElegantRL, or notebook not having strict and clear version constrictions which would've enabled us to run the demo.

Such issue is also mentioned here https://github.com/AI4Finance-Foundation/FinRL-Meta/issues/291 and here https://github.com/AI4Finance-Foundation/FinRL-Meta/issues/86

Having tried downgrading, and .py script https://github.com/AI4Finance-Foundation/FinRL-Tutorials/blob/master/3-Practical/FinRL_MultiCrypto_Trading.py, and partly rewritten FinRL-Meta/agents/elegantrl_models.py to use Config I still run into the issue

Traceback (most recent call last):
  File "/home/quakuei/Desktop/docusketch/trading-bot/notebooks/FinRL-Meta/cock.py", line 15, in <module>
    from train import train
  File "/home/quakuei/Desktop/docusketch/trading-bot/notebooks/FinRL-Meta/train.py", line 1, in <module>
    from agents.elegantrl_models import DRLAgent as DRLAgent_erl
  File "/home/quakuei/Desktop/docusketch/trading-bot/notebooks/FinRL-Meta/agents/elegantrl_models.py", line 8, in <module>
    from elegantrl.train.run import init_agent
ImportError: cannot import name 'init_agent' from 'elegantrl.train.run' (/home/quakuei/Desktop/docusketch/trading-bot/venv/lib/python3.10/site-packages/elegantrl/train/run.py)

In overall, I think it would be safe to say that this issue relates more to development of FinRL-Meta repo, rather than ElegantRL.

In any case, it drastically worsens reproducibility.

In addition, if you try to use other libraries fo RL agents in the same script, you also run into issues, which is not good for the FinRL ease of use.

Tanakablack commented 4 months ago

@YangletLiu Please help. We are still facing this error. It seems no one managed to resolve it. Kindly update.

Anyways, thank you guys for these notebooks. I have been running a few notebooks, faced minor issues but I managed to resolve them and learnt a lot. Keep up the good work

YangletLiu commented 4 months ago

@YangletLiu Please help. We are still facing this error. It seems no one managed to resolve it. Kindly update.

Anyways, thank you guys for these notebooks. I have been running a few notebooks, faced minor issues but I managed to resolve them and learnt a lot. Keep up the good work

@Yonv1943 and @zhumingpassional may provide help here! Thanks in advance!

Tanakablack commented 4 months ago

@YangletLiu @Yonv1943 @zhumingpassional any update about this issue, is it fixed yet