File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed
ml-agents/mlagents/trainers Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ and this project adheres to
13
13
### Minor Changes
14
14
15
15
### Bug Fixes
16
+ ` mlagents-learn ` will now raise an error immediately if ` --num-envs ` is greater than 1 without setting the ` --env `
17
+ argument. (#4203 )
16
18
17
19
## [ 1.2.0-preview] - 2020-07-15
18
20
Original file line number Diff line number Diff line change @@ -600,9 +600,14 @@ class EnvironmentSettings:
600
600
env_path : Optional [str ] = parser .get_default ("env_path" )
601
601
env_args : Optional [List [str ]] = parser .get_default ("env_args" )
602
602
base_port : int = parser .get_default ("base_port" )
603
- num_envs : int = parser .get_default ("num_envs" )
603
+ num_envs : int = attr . ib ( default = parser .get_default ("num_envs" ) )
604
604
seed : int = parser .get_default ("seed" )
605
605
606
+ @num_envs .validator
607
+ def validate_num_envs (self , attribute , value ):
608
+ if value > 1 and self .env_path is None :
609
+ raise ValueError ("num_envs must be 1 if env_path is not set." )
610
+
606
611
607
612
@attr .s (auto_attribs = True )
608
613
class EngineSettings :
Original file line number Diff line number Diff line change 13
13
RewardSignalType ,
14
14
RewardSignalSettings ,
15
15
CuriositySettings ,
16
+ EnvironmentSettings ,
16
17
EnvironmentParameterSettings ,
17
18
ConstantSettings ,
18
19
UniformSettings ,
@@ -452,3 +453,18 @@ def test_exportable_settings(use_defaults):
452
453
check_dict_is_at_least (second_export , dict_export )
453
454
# Check that the two exports are the same
454
455
assert dict_export == second_export
456
+
457
+
458
+ def test_environment_settings ():
459
+ # default args
460
+ EnvironmentSettings ()
461
+
462
+ # 1 env is OK if no env_path
463
+ EnvironmentSettings (num_envs = 1 )
464
+
465
+ # multiple envs is OK if env_path is set
466
+ EnvironmentSettings (num_envs = 42 , env_path = "/foo/bar.exe" )
467
+
468
+ # Multiple environments with no env_path is an error
469
+ with pytest .raises (ValueError ):
470
+ EnvironmentSettings (num_envs = 2 )
You can’t perform that action at this time.
0 commit comments