ray-project / ray

Ray is an AI compute engine. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
34.23k stars 5.81k forks source link

[RLlib] Windows CLI, cmd.exe, powershell parsing json arguments JSONDecodeError #35492

Open I3lacx opened 1 year ago

I3lacx commented 1 year ago

What happened + What you expected to happen

Following the installation on the Getting started page. Starting with a clean python 3.8.16 anaconda environment on Windows 10 running in cmd.exe, following these steps:

pip install "ray[rllib]" tensorflow
rllib train --algo DQN --env CartPole-v1 --stop '{"training_iteration": 30}'

After solving some issues mentioned in #35491 I receive:

No such command "30}'".

When running the command through powershell, the error is:

JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

When removing --stop '{"training_iteration": 30}' from the arguments, the training starts. Following the same steps on a Windows 11 system causes the same issue. Following the same steps in WSL works without issue.

Versions / Dependencies

Tested on Windows 10, Windows 11 Using cmd.exe, powershell Python=3.8

output_pip_list.txt

Reproduction script

Starting with a clean python 3.8.16 anaconda environment on Windows 10 running in cmd.exe, following the steps from the Getting started page + hotfix for missing dependency:

pip install "ray[rllib]" tensorflow tensorflow-probabilities
rllib train --algo DQN --env CartPole-v1 --stop '{"training_iteration": 30}'

Issue Severity

None

Rohan138 commented 1 year ago

Try escaping the \"; so '{\"training_iteration\": 30}'

I3lacx commented 1 year ago

Thanks, this trick worked in powershell, so running: rllib train --algo DQN --env CartPole-v1 --stop '{\"training_iteration\": 30}' --framework tf2 is running for me on windows.

It did not work for cmd, but I found a different workaround (which does not work for powershell). Using " outside and "" inside seems to pass them correctly to the code: rllib train --algo DQN --env CartPole-v1 --stop "{""training_iteration"": 30}" --framework tf2

The issue is resolved for me, and I guess this can not really be fixed through code, so maybe some form of documentation can be added to guide windows users?