add test script
This commit is contained in:
@@ -1,20 +1,17 @@
|
||||
import os
|
||||
import os.path
|
||||
|
||||
import tqdm
|
||||
from metadrive.envs.scenario_env import ScenarioEnv
|
||||
from metadrive.policy.replay_policy import ReplayEgoCarPolicy
|
||||
|
||||
from scenarionet import SCENARIONET_PACKAGE_PATH
|
||||
from scenarionet.builder.utils import combine_multiple_dataset, read_dataset_summary, read_scenario
|
||||
from scenarionet.verifier.utils import verify_loading_into_metadrive
|
||||
|
||||
|
||||
def test_combine_multiple_dataset():
|
||||
dataset_name = "nuscenes"
|
||||
original_dataset_path = os.path.join(SCENARIONET_PACKAGE_PATH, "test", "test_dataset", dataset_name)
|
||||
original_dataset_path = os.path.join(SCENARIONET_PACKAGE_PATH, "tests", "test_dataset", dataset_name)
|
||||
dataset_paths = [original_dataset_path + "_{}".format(i) for i in range(5)]
|
||||
|
||||
output_path = os.path.join(SCENARIONET_PACKAGE_PATH, "test", "combine")
|
||||
output_path = os.path.join(SCENARIONET_PACKAGE_PATH, "tests", "combine")
|
||||
combine_multiple_dataset(output_path,
|
||||
*dataset_paths,
|
||||
force_overwrite=True,
|
||||
@@ -24,16 +21,7 @@ def test_combine_multiple_dataset():
|
||||
summary, sorted_scenarios, mapping = read_dataset_summary(dataset_path)
|
||||
for scenario_file in sorted_scenarios:
|
||||
read_scenario(os.path.join(dataset_path, mapping[scenario_file], scenario_file))
|
||||
|
||||
env = ScenarioEnv({"agent_policy": ReplayEgoCarPolicy,
|
||||
"num_scenarios": 10,
|
||||
"horizon": 1000,
|
||||
"data_directory": output_path})
|
||||
try:
|
||||
for i in tqdm.tqdm(range(10), desc="Test env loading"):
|
||||
env.reset(force_seed=i)
|
||||
finally:
|
||||
env.close()
|
||||
verify_loading_into_metadrive(dataset_path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user