浏览代码

Moving env_strip to validate_environment_path

/asymm-envs
Alphonso Crawford 5 年前
当前提交
2a154bf3
共有 2 个文件被更改,包括 12 次插入18 次删除
  1. 22
      ml-agents-envs/mlagents_envs/environment.py
  2. 8
      ml-agents/mlagents/trainers/learn.py

22
ml-agents-envs/mlagents_envs/environment.py


@staticmethod
def validate_environment_path(env_path: str) -> Optional[str]:
# Strip out executable extensions if passed
env_path = (
env_path.strip()
.replace(".app", "")
.replace(".exe", "")
.replace(".x86_64", "")
.replace(".x86", "")
)
true_filename = os.path.basename(os.path.normpath(env_path))
logger.debug("The true file name is {}".format(true_filename))
if not (glob.glob(env_path) or glob.glob(env_path + ".*")):
return None

return launch_string
def executable_launcher(self, file_name, docker_training, no_graphics, args):
file_name = (
file_name.strip()
.replace(".app", "")
.replace(".exe", "")
.replace(".x86_64", "")
.replace(".x86", "")
)
true_filename = os.path.basename(os.path.normpath(file_name))
logger.debug("The true file name is {}".format(true_filename))
launch_string = self.validate_environment_path(file_name)
if launch_string is None:
self._close()

true_filename
file_name
)
)
else:

8
ml-agents/mlagents/trainers/learn.py


env_args: Optional[List[str]],
) -> Callable[[int, List[SideChannel]], BaseEnv]:
if env_path is not None:
# Strip out executable extensions if passed
env_path = (
env_path.strip()
.replace(".app", "")
.replace(".exe", "")
.replace(".x86_64", "")
.replace(".x86", "")
)
launch_string = UnityEnvironment.validate_environment_path(env_path)
if launch_string is None:
raise UnityEnvironmentException(

正在加载...
取消
保存