forked from fcomlop/BabyBench2025_Starter_Kit
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_installation.py
More file actions
86 lines (75 loc) · 2.42 KB
/
test_installation.py
File metadata and controls
86 lines (75 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
Installation test for BabyBench. Checks required libraries, MIMo, simulations, and rendering
"""
def main():
print("Starting BabyBench installation test")
print("Checking libraries... ")
try:
import numpy as np
import os
import gymnasium as gym
import time
import argparse
#import cv2
import mujoco
import yaml
except ImportError as e:
print("Please check that the necessary libraries are installed")
print(e)
exit(1)
print("Checking MIMo... ")
try:
import mimoEnv
from mimoEnv.envs.mimo_env import MIMoEnv
import mimoEnv.utils as env_utils
import babybench.utils as bb_utils
except ImportError as e:
print("Please make sure you have MIMo installed")
print(e)
exit(1)
print("Checking config... ")
try:
with open('examples/config_test_installation.yml') as f:
config = yaml.safe_load(f)
for param in ['save_dir','behavior','scene','actuation_model',
'max_episode_steps','frame_skip','render_size','save_logs_every']:
_ = config[param]
except Exception as e:
print(f"Please make sure the necessary parameters are defined in the config. Missing: {param}")
print(e)
exit(1)
print("Checking environment initialization... ")
try:
env = bb_utils.make_env(config)
env.reset()
except Exception as e:
print("Error creating environment")
print(e)
exit(1)
print("Checking environment simulation... ")
try:
_ = env.step(env.action_space.sample())
except Exception as e:
print("Error taking step in environment")
print(e)
exit(1)
print("Checking image rendering... ")
try:
images = []
for _ in range(10):
_ = env.step(env.action_space.sample())
images.append(bb_utils.render(env))
except Exception as e:
print("Error rendering environment")
print(e)
exit(1)
print("Checking video rendering... ")
try:
bb_utils.evaluation_video(images, save_name=f'{config["save_dir"]}/videos/test_installation.avi', resolution=(480,480))
except Exception as e:
print("Error creating video")
print(e)
exit(1)
print("Installation test successful!")
if __name__ == '__main__':
main()