|
@@ -1,5 +1,3 @@
|
|
|
-import minigrid.wrappers
|
|
|
-
|
|
|
__author__ = "Feng Gu"
|
|
|
__email__ = "contact@fenggu.me"
|
|
|
|
|
@@ -7,13 +5,13 @@ __email__ = "contact@fenggu.me"
|
|
|
isort:skip_file
|
|
|
"""
|
|
|
|
|
|
-import inspect
|
|
|
import os
|
|
|
import re
|
|
|
|
|
|
from gymnasium.envs.registration import registry
|
|
|
from tqdm import tqdm
|
|
|
from utils import trim
|
|
|
+from itertools import chain
|
|
|
|
|
|
readme_path = os.path.join(
|
|
|
os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
|
|
@@ -28,6 +26,7 @@ all_envs = list(registry.values())
|
|
|
|
|
|
filtered_envs_by_type = {}
|
|
|
env_names = []
|
|
|
+babyai_envs = {}
|
|
|
|
|
|
# Obtain filtered list
|
|
|
for env_spec in tqdm(all_envs):
|
|
@@ -35,11 +34,18 @@ for env_spec in tqdm(all_envs):
|
|
|
split = env_spec.entry_point.split(".")
|
|
|
# ignore gymnasium.envs.env_type:Env
|
|
|
env_module = split[0]
|
|
|
- if env_module != "minigrid":
|
|
|
+
|
|
|
+ if len(split) > 2 and "babyai" in split[2]:
|
|
|
+ curr_babyai_env = split[2]
|
|
|
+ babyai_env_name = curr_babyai_env.split(":")[1]
|
|
|
+ babyai_envs[babyai_env_name] = env_spec
|
|
|
+ elif env_module == "minigrid":
|
|
|
+ env_name = split[1]
|
|
|
+ filtered_envs_by_type[env_name] = env_spec
|
|
|
+ # if env_module != "minigrid":
|
|
|
+ else:
|
|
|
continue
|
|
|
|
|
|
- env_name = split[1]
|
|
|
- filtered_envs_by_type[env_name] = env_spec
|
|
|
|
|
|
filtered_envs = {
|
|
|
env[0]: env[1]
|
|
@@ -49,7 +55,15 @@ filtered_envs = {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-for env_name, env_spec in filtered_envs.items():
|
|
|
+filtered_babyai_envs = {
|
|
|
+ env[0]: env[1]
|
|
|
+ for env in sorted(
|
|
|
+ babyai_envs.items(),
|
|
|
+ key=lambda item: item[1].entry_point.split(".")[1],
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+for env_name, env_spec in chain(filtered_envs.items(), filtered_babyai_envs.items()):
|
|
|
made = env_spec.make()
|
|
|
|
|
|
docstring = trim(made.unwrapped.__doc__)
|
|
@@ -87,136 +101,3 @@ title: {title_env_name}
|
|
|
file = open(v_path, "w+", encoding="utf-8")
|
|
|
file.write(all_text)
|
|
|
file.close()
|
|
|
-
|
|
|
-
|
|
|
-# gen /environments/index.md
|
|
|
-index_texts = """---
|
|
|
-firstpage:
|
|
|
-lastpage:
|
|
|
----
|
|
|
-
|
|
|
-"""
|
|
|
-env_index_toctree = """
|
|
|
-```{toctree}
|
|
|
-:hidden:
|
|
|
-"""
|
|
|
-sections = []
|
|
|
-
|
|
|
-with open(readme_path) as f:
|
|
|
- readme = f.read()
|
|
|
-
|
|
|
- """
|
|
|
- sections = [description, publications, installation, basic usage, wrappers, design, included environments&etc]
|
|
|
- """
|
|
|
- sections = readme.split("<br>")
|
|
|
- index_texts += sections[6]
|
|
|
- index_texts += env_index_toctree
|
|
|
-
|
|
|
- for env_name in env_names:
|
|
|
- index_texts += env_name + "\n"
|
|
|
-
|
|
|
- index_texts += """\n```\n"""
|
|
|
- f.close()
|
|
|
-
|
|
|
-output_path = os.path.join(
|
|
|
- os.path.dirname(os.path.dirname(__file__)),
|
|
|
- "environments",
|
|
|
- "index.md",
|
|
|
-)
|
|
|
-
|
|
|
-# output index.md
|
|
|
-with open(output_path, "w+") as f:
|
|
|
- f.write(index_texts)
|
|
|
- f.close()
|
|
|
-
|
|
|
-# gen /environments/design.md
|
|
|
-design_path = os.path.join(
|
|
|
- os.path.dirname(os.path.dirname(__file__)),
|
|
|
- "environments",
|
|
|
- "design.md",
|
|
|
-)
|
|
|
-
|
|
|
-design_texts = """---
|
|
|
-layout: "contents"
|
|
|
-title: Design
|
|
|
-firstpage:
|
|
|
----\n"""
|
|
|
-
|
|
|
-design_texts += sections[5]
|
|
|
-
|
|
|
-with open(design_path, "w+") as f:
|
|
|
- f.write(design_texts)
|
|
|
- f.close()
|
|
|
-
|
|
|
-
|
|
|
-# gen /environments/wrappers.md
|
|
|
-
|
|
|
-wrappers_path = os.path.join(
|
|
|
- os.path.dirname(os.path.dirname(__file__)),
|
|
|
- "api",
|
|
|
- "wrappers.md",
|
|
|
-)
|
|
|
-
|
|
|
-wrappers_texts = (
|
|
|
- """---
|
|
|
-title: Wrappers
|
|
|
-lastpage:
|
|
|
----\n"""
|
|
|
- + sections[4]
|
|
|
- + "\n"
|
|
|
-)
|
|
|
-
|
|
|
-for name, obj in inspect.getmembers(minigrid.wrappers):
|
|
|
- if inspect.isclass(obj) and obj.__doc__ is not None:
|
|
|
- formatted_doc = " ".join(trim(obj.__doc__).split())
|
|
|
- wrappers_texts += f"""## {name}
|
|
|
-{formatted_doc}\n\n"""
|
|
|
-
|
|
|
-with open(wrappers_path, "w+") as f:
|
|
|
- f.write(wrappers_texts)
|
|
|
- f.close()
|
|
|
-
|
|
|
-
|
|
|
-# gen content/pubs.md
|
|
|
-
|
|
|
-pubs_path = os.path.join(
|
|
|
- os.path.dirname(os.path.dirname(__file__)),
|
|
|
- "content",
|
|
|
- "pubs.md",
|
|
|
-)
|
|
|
-
|
|
|
-pubs_texts = (
|
|
|
- """---
|
|
|
-layout: "contents"
|
|
|
-title: Publications
|
|
|
-firstpage:
|
|
|
----\n#List of Publications\n"""
|
|
|
- + sections[1]
|
|
|
- + "\n"
|
|
|
-)
|
|
|
-
|
|
|
-with open(pubs_path, "w+") as f:
|
|
|
- f.write(pubs_texts)
|
|
|
- f.close()
|
|
|
-
|
|
|
-# gen content/basic_usage.md
|
|
|
-
|
|
|
-pubs_path = os.path.join(
|
|
|
- os.path.dirname(os.path.dirname(__file__)),
|
|
|
- "content",
|
|
|
- "basic_usage.md",
|
|
|
-)
|
|
|
-
|
|
|
-pubs_texts = (
|
|
|
- """---
|
|
|
-layout: "contents"
|
|
|
-title: Basic Usage
|
|
|
-firstpage:
|
|
|
----\n"""
|
|
|
- + sections[3]
|
|
|
- + "\n"
|
|
|
-)
|
|
|
-
|
|
|
-with open(pubs_path, "w+") as f:
|
|
|
- f.write(pubs_texts)
|
|
|
- f.close()
|