浏览代码

don't allow --num-envs >1 with no --env (#4203)

* don't allow --num-envs >1 with no --env

* changelog

* PR feedback
/MLA-1734-demo-provider
GitHub 4 年前
当前提交
e318f96a
共有 3 个文件被更改,包括 24 次插入1 次删除
  1. 2
      com.unity.ml-agents/CHANGELOG.md
  2. 7
      ml-agents/mlagents/trainers/settings.py
  3. 16
      ml-agents/mlagents/trainers/tests/test_settings.py

2
com.unity.ml-agents/CHANGELOG.md


### Minor Changes
### Bug Fixes
`mlagents-learn` will now raise an error immediately if `--num-envs` is greater than 1 without setting the `--env`
argument. (#4203)
## [1.2.0-preview] - 2020-07-15

7
ml-agents/mlagents/trainers/settings.py


env_path: Optional[str] = parser.get_default("env_path")
env_args: Optional[List[str]] = parser.get_default("env_args")
base_port: int = parser.get_default("base_port")
num_envs: int = parser.get_default("num_envs")
num_envs: int = attr.ib(default=parser.get_default("num_envs"))
@num_envs.validator
def validate_num_envs(self, attribute, value):
if value > 1 and self.env_path is None:
raise ValueError("num_envs must be 1 if env_path is not set.")
@attr.s(auto_attribs=True)

16
ml-agents/mlagents/trainers/tests/test_settings.py


RewardSignalType,
RewardSignalSettings,
CuriositySettings,
EnvironmentSettings,
EnvironmentParameterSettings,
ConstantSettings,
UniformSettings,

check_dict_is_at_least(second_export, dict_export)
# Check that the two exports are the same
assert dict_export == second_export
def test_environment_settings():
# default args
EnvironmentSettings()
# 1 env is OK if no env_path
EnvironmentSettings(num_envs=1)
# multiple envs is OK if env_path is set
EnvironmentSettings(num_envs=42, env_path="/foo/bar.exe")
# Multiple environments with no env_path is an error
with pytest.raises(ValueError):
EnvironmentSettings(num_envs=2)
正在加载...
取消
保存