浏览代码

Allow --version argument in mlagents-learn (#2942)

* allow --version argument in mlagents-learn

* Develop version print add strings (#2945)

* add __version__ to libs

* more version info

* use actual version
/develop-newnormalization
GitHub 5 年前
当前提交
28dbf4c5
共有 8 个文件被更改,包括 29 次插入6 次删除
  1. 1
      gym-unity/gym_unity/__init__.py
  2. 3
      gym-unity/setup.py
  3. 1
      ml-agents-envs/mlagents/envs/__init__.py
  4. 3
      ml-agents-envs/setup.py
  5. 1
      ml-agents/mlagents/trainers/__init__.py
  6. 13
      ml-agents/mlagents/trainers/learn.py
  7. 3
      ml-agents/setup.py
  8. 10
      utils/validate_versions.py

1
gym-unity/gym_unity/__init__.py


__version__ = "0.11.0"

3
gym-unity/setup.py


import sys
from setuptools import setup, find_packages
from setuptools.command.install import install
import gym_unity
VERSION = "0.11.0"
VERSION = gym_unity.__version__
class VerifyVersionCommand(install):

1
ml-agents-envs/mlagents/envs/__init__.py


__version__ = "0.11.0"

3
ml-agents-envs/setup.py


import sys
from setuptools import setup
from setuptools.command.install import install
import mlagents.envs
VERSION = "0.11.0"
VERSION = mlagents.envs.__version__
here = os.path.abspath(os.path.dirname(__file__))

1
ml-agents/mlagents/trainers/__init__.py


__version__ = "0.11.0"

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


from typing import Any, Callable, Optional, List, NamedTuple
import mlagents.trainers
import mlagents.envs
from mlagents import tf_utils
from mlagents.trainers.trainer_controller import TrainerController
from mlagents.trainers.exception import TrainerError

@staticmethod
def from_argparse(args: Any) -> "CommandLineOptions":
return CommandLineOptions(**vars(args))
def get_version_string() -> str:
return f""" Version information:\n
ml-agents: {mlagents.trainers.__version__},
ml-agents-envs: {mlagents.envs.__version__},
Communicator API: {UnityEnvironment.API_VERSION},
TensorFlow: {tf_utils.tf.__version__}
"""
def parse_command_line(argv: Optional[List[str]] = None) -> CommandLineOptions:

parser.add_argument(
"--cpu", default=False, action="store_true", help="Run with CPU only"
)
parser.add_argument("--version", action="version", version=get_version_string())
args = parser.parse_args(argv)
return CommandLineOptions.from_argparse(args)

3
ml-agents/setup.py


from setuptools import setup, find_namespace_packages
from setuptools.command.install import install
import mlagents.trainers
VERSION = "0.11.0"
VERSION = mlagents.trainers.__version__
here = os.path.abspath(os.path.dirname(__file__))

10
utils/validate_versions.py


import sys
from typing import Dict
VERSION_LINE_START = "VERSION = "
VERSION_LINE_START = "__version__ = "
DIRECTORIES = ["ml-agents", "ml-agents-envs", "gym-unity"]
DIRECTORIES = [
"ml-agents/mlagents/trainers",
"ml-agents-envs/mlagents/envs",
"gym-unity/gym_unity",
]
def extract_version_string(filename):

def check_versions() -> bool:
version_by_dir: Dict[str, str] = {}
for directory in DIRECTORIES:
path = os.path.join(directory, "setup.py")
path = os.path.join(directory, "__init__.py")
version = extract_version_string(path)
print(f"Found version {version} for {directory}")
version_by_dir[directory] = version

正在加载...
取消
保存