Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 68 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth:: 0
submodules: true
# LFS checkout here somehow causes issues when LFS stuff changes over time.
# So I do LFS manually in a step after.
Expand All @@ -81,9 +82,13 @@ jobs:
git lfs install --local
git lfs pull

- name: git status
run: |
git status
- &git_status
name: git status
run: git status

- &git_fsck
name: git fsck
run: git fsck --full

- name: Run pre-commit
uses: pre-commit/[email protected]
Expand Down Expand Up @@ -121,19 +126,22 @@ jobs:
pip install --no-cache-dir -e .
[ -e ./submodules/IsaacLab/_isaac_sim ] || ln -s /isaac-sim ./submodules/IsaacLab/_isaac_sim

# Run the tests (excluding the gr00t related tests)
- name: Run pytest excluding policy-related tests. First we run all tests without cameras.
run: /isaac-sim/python.sh -m pytest -sv -m "not with_cameras" isaaclab_arena/tests/ --ignore=isaaclab_arena/tests/policy/
- *git_status
- *git_fsck

- name: Run pytest excluding policy-related tests. Now we run all tests with cameras.
run: /isaac-sim/python.sh -m pytest -sv -m with_cameras isaaclab_arena/tests/ --ignore=isaaclab_arena/tests/policy/
# # Run the tests (excluding the gr00t related tests)
# - name: Run pytest excluding policy-related tests. First we run all tests without cameras.
# run: /isaac-sim/python.sh -m pytest -sv -m "not with_cameras" isaaclab_arena/tests/ --ignore=isaaclab_arena/tests/policy/

# - name: Run pytest excluding policy-related tests. Now we run all tests with cameras.
# run: /isaac-sim/python.sh -m pytest -sv -m with_cameras isaaclab_arena/tests/ --ignore=isaaclab_arena/tests/policy/


test_policy:
name: Run policy-related tests with GR00T & cuda12_8 deps
runs-on: [gpu]
timeout-minutes: 60
needs: [pre_commit]
# needs: [pre_commit]

container:
image: nvcr.io/nvstaging/isaac-amr/isaaclab_arena:cuda_gr00t
Expand All @@ -152,10 +160,51 @@ jobs:
- *git_lfs_step
- *install_project_step

# Run the policy (GR00T) related tests.
- name: Run policy-related pytest
run: /isaac-sim/python.sh -m pytest -sv isaaclab_arena/tests/policy/

- *git_status
- *git_fsck

# Debug
- name: Debug
run: find isaaclab_arena/tests/test_data/test_gr1_manip_lerobot/ -type f -print0 | xargs -0 sha256sum
# find isaaclab_arena/tests/test_data/test_gr1_manip_lerobot/ -type f -print0 | xargs -0 du -h
# run: find isaaclab_arena/tests/test_data/test_gr1_manip_lerobot/

# # Run the policy (GR00T) related tests.
# - name: Run policy-related pytest
# run: |
# sudo apt-get update && sudo apt-get install time
# /usr/bin/time -f 'Peak memory: %M KB' /isaac-sim/python.sh -m pytest -s isaaclab_arena/tests/policy/test_replay_lerobot_action_policy.py
# # run: /isaac-sim/python.sh -m pytest -sv isaaclab_arena/tests/policy/

# - name: Run command while tracking system memory
# run: |
# # Start memory sampling in the background
# (
# peak=0
# while true; do
# used=$(free -m | awk '/Mem:/ {print $3}')
# if [ "$used" -gt "$peak" ]; then peak=$used; fi
# echo $peak > peak_mem.txt
# sleep 1
# done
# ) &
# sampler_pid=$!

# # Run your command
# /isaac-sim/python.sh -m pytest -s isaaclab_arena/tests/policy/test_replay_lerobot_action_policy.py
# exit_code=$?

# # Stop the sampler
# kill $sampler_pid || true

# # Print peak system memory used (in MB)
# echo "Peak system memory: $(cat peak_mem.txt) MB"

# exit $exit_code

- name: Run test in main process
run: |
/isaac-sim/python.sh isaaclab_arena/examples/policy_runner.py --policy_type replay_lerobot --config_yaml_path isaaclab_arena/tests/test_data/test_gr1_manip_lerobot/test_gr1_manip_replay_action_config.yaml --max_steps 10 --trajectory_index 0 --headless --enable_cameras gr1_open_microwave --object microwave --embodiment gr1_joint

build_docs_pre_merge:
name: Build the docs (pre-merge)
Expand All @@ -172,6 +221,9 @@ jobs:
- *cleanup_step
- *checkout_step

- *git_status
- *git_fsck

# Build docs
- name: Build docs
run: |
Expand Down Expand Up @@ -202,6 +254,9 @@ jobs:
- *cleanup_step
- *checkout_step

- *git_status
- *git_fsck

- name: Install docker
run: |
apt-get update
Expand Down
76 changes: 38 additions & 38 deletions isaaclab_arena/tests/policy/test_convert_hdf5_to_lerobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,53 @@
from isaaclab_arena_gr00t.data_utils.io_utils import create_config_from_yaml


def test_g1_convert_hdf5_to_lerobot():
# Load expected data for comparison
expected_g1_parquet = pd.read_parquet(
TestConstants.test_data_dir + "/test_g1_locomanip_lerobot/data/chunk-000/episode_000000.parquet"
)
g1_ds_config = create_config_from_yaml(
TestConstants.test_data_dir + "/test_g1_locomanip_lerobot/test_g1_locomanip_config.yaml", Gr00tDatasetConfig
)
# def test_g1_convert_hdf5_to_lerobot():
# # Load expected data for comparison
# expected_g1_parquet = pd.read_parquet(
# TestConstants.test_data_dir + "/test_g1_locomanip_lerobot/data/chunk-000/episode_000000.parquet"
# )
# g1_ds_config = create_config_from_yaml(
# TestConstants.test_data_dir + "/test_g1_locomanip_lerobot/test_g1_locomanip_config.yaml", Gr00tDatasetConfig
# )

# Clean up any existing output directory
if g1_ds_config.lerobot_data_dir.exists():
# # Clean up any existing output directory
# if g1_ds_config.lerobot_data_dir.exists():

shutil.rmtree(g1_ds_config.lerobot_data_dir)
# shutil.rmtree(g1_ds_config.lerobot_data_dir)

# Run conversion
convert_hdf5_to_lerobot(g1_ds_config)
# # Run conversion
# convert_hdf5_to_lerobot(g1_ds_config)

# assert it has episodes.jsonl file
assert (g1_ds_config.lerobot_data_dir / "meta" / "episodes.jsonl").exists()
# # assert it has episodes.jsonl file
# assert (g1_ds_config.lerobot_data_dir / "meta" / "episodes.jsonl").exists()

# assert it has tasks.jsonl file
assert (g1_ds_config.lerobot_data_dir / "meta" / "tasks.jsonl").exists()
# # assert it has tasks.jsonl file
# assert (g1_ds_config.lerobot_data_dir / "meta" / "tasks.jsonl").exists()

# assert it has info.json file
assert (g1_ds_config.lerobot_data_dir / "meta" / "info.json").exists()
# # assert it has info.json file
# assert (g1_ds_config.lerobot_data_dir / "meta" / "info.json").exists()

# assert it has modality.json file
assert (g1_ds_config.lerobot_data_dir / "meta" / "modality.json").exists()
# # assert it has modality.json file
# assert (g1_ds_config.lerobot_data_dir / "meta" / "modality.json").exists()

# assert it has data/ folder has parquet files
parquet_files = list((g1_ds_config.lerobot_data_dir / "data").glob("**/*.parquet"))
assert len(parquet_files) == 1
# # assert it has data/ folder has parquet files
# parquet_files = list((g1_ds_config.lerobot_data_dir / "data").glob("**/*.parquet"))
# assert len(parquet_files) == 1

# assert it has videos/ folder has mp4 files
mp4_files = list((g1_ds_config.lerobot_data_dir / "videos").glob("**/*.mp4"))
assert len(mp4_files) == 1
# check parquet file contains expected columns
actual_df = pd.read_parquet(parquet_files[0])
expected_columns = set(expected_g1_parquet.columns)
actual_columns = set(actual_df.columns)
assert expected_columns.issubset(actual_columns), f"Missing columns: {expected_columns - actual_columns}"
# check parquet file data is the same as expected
assert actual_df.equals(expected_g1_parquet)
# # assert it has videos/ folder has mp4 files
# mp4_files = list((g1_ds_config.lerobot_data_dir / "videos").glob("**/*.mp4"))
# assert len(mp4_files) == 1
# # check parquet file contains expected columns
# actual_df = pd.read_parquet(parquet_files[0])
# expected_columns = set(expected_g1_parquet.columns)
# actual_columns = set(actual_df.columns)
# assert expected_columns.issubset(actual_columns), f"Missing columns: {expected_columns - actual_columns}"
# # check parquet file data is the same as expected
# assert actual_df.equals(expected_g1_parquet)

# remove lerobot_data_dir
shutil.rmtree(g1_ds_config.lerobot_data_dir.parent)
# # remove lerobot_data_dir
# shutil.rmtree(g1_ds_config.lerobot_data_dir.parent)


if __name__ == "__main__":
test_g1_convert_hdf5_to_lerobot()
# if __name__ == "__main__":
# test_g1_convert_hdf5_to_lerobot()
122 changes: 61 additions & 61 deletions isaaclab_arena/tests/policy/test_gr00t_closedloop_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,64 +78,64 @@ def get_tmp_config_file(input_config_file, tmp_path, model_path):
return output_config_file


def test_g1_locomanip_gr00t_closedloop_policy_runner_single_env(gr00t_finetuned_model_path, tmp_path):
# Write a new temporary config file with the finetuned model path.
default_config_file = (
TestConstants.test_data_dir + "/test_g1_locomanip_lerobot/test_g1_locomanip_gr00t_closedloop_config.yaml"
)
config_file = get_tmp_config_file(default_config_file, tmp_path, gr00t_finetuned_model_path)

# Run the model
args = [TestConstants.python_path, f"{TestConstants.examples_dir}/policy_runner.py"]
args.append("--policy_type")
args.append("gr00t_closedloop")
args.append("--policy_config_yaml_path")
args.append(config_file)
args.append("--num_steps")
args.append(str(NUM_STEPS))
if HEADLESS:
args.append("--headless")
if ENABLE_CAMERAS:
args.append("--enable_cameras")
# example env
args.append("galileo_g1_locomanip_pick_and_place")
args.append("--object")
args.append("brown_box")
args.append("--embodiment")
args.append("g1_wbc_joint")
run_subprocess(args)


def test_g1_locomanip_gr00t_closedloop_policy_runner_multi_envs(gr00t_finetuned_model_path, tmp_path):
# Write a new temporary config file with the finetuned model path.
default_config_file = (
TestConstants.test_data_dir + "/test_g1_locomanip_lerobot/test_g1_locomanip_gr00t_closedloop_config.yaml"
)
config_file = get_tmp_config_file(default_config_file, tmp_path, gr00t_finetuned_model_path)

# Run the model
args = [TestConstants.python_path, f"{TestConstants.examples_dir}/policy_runner.py"]
args.append("--policy_type")
args.append("gr00t_closedloop")
args.append("--policy_config_yaml_path")
args.append(config_file)
args.append("--num_steps")
args.append(str(NUM_STEPS))
args.append("--num_envs")
args.append(str(NUM_ENVS))
if HEADLESS:
args.append("--headless")
if ENABLE_CAMERAS:
args.append("--enable_cameras")
# example env
args.append("galileo_g1_locomanip_pick_and_place")
args.append("--object")
args.append("brown_box")
args.append("--embodiment")
args.append("g1_wbc_joint")
run_subprocess(args)


if __name__ == "__main__":
test_g1_locomanip_gr00t_closedloop_policy_runner_single_env()
test_g1_locomanip_gr00t_closedloop_policy_runner_multi_envs()
# def test_g1_locomanip_gr00t_closedloop_policy_runner_single_env(gr00t_finetuned_model_path, tmp_path):
# # Write a new temporary config file with the finetuned model path.
# default_config_file = (
# TestConstants.test_data_dir + "/test_g1_locomanip_lerobot/test_g1_locomanip_gr00t_closedloop_config.yaml"
# )
# config_file = get_tmp_config_file(default_config_file, tmp_path, gr00t_finetuned_model_path)

# # Run the model
# args = [TestConstants.python_path, f"{TestConstants.examples_dir}/policy_runner.py"]
# args.append("--policy_type")
# args.append("gr00t_closedloop")
# args.append("--policy_config_yaml_path")
# args.append(config_file)
# args.append("--num_steps")
# args.append(str(NUM_STEPS))
# if HEADLESS:
# args.append("--headless")
# if ENABLE_CAMERAS:
# args.append("--enable_cameras")
# # example env
# args.append("galileo_g1_locomanip_pick_and_place")
# args.append("--object")
# args.append("brown_box")
# args.append("--embodiment")
# args.append("g1_wbc_joint")
# run_subprocess(args)


# def test_g1_locomanip_gr00t_closedloop_policy_runner_multi_envs(gr00t_finetuned_model_path, tmp_path):
# # Write a new temporary config file with the finetuned model path.
# default_config_file = (
# TestConstants.test_data_dir + "/test_g1_locomanip_lerobot/test_g1_locomanip_gr00t_closedloop_config.yaml"
# )
# config_file = get_tmp_config_file(default_config_file, tmp_path, gr00t_finetuned_model_path)

# # Run the model
# args = [TestConstants.python_path, f"{TestConstants.examples_dir}/policy_runner.py"]
# args.append("--policy_type")
# args.append("gr00t_closedloop")
# args.append("--policy_config_yaml_path")
# args.append(config_file)
# args.append("--num_steps")
# args.append(str(NUM_STEPS))
# args.append("--num_envs")
# args.append(str(NUM_ENVS))
# if HEADLESS:
# args.append("--headless")
# if ENABLE_CAMERAS:
# args.append("--enable_cameras")
# # example env
# args.append("galileo_g1_locomanip_pick_and_place")
# args.append("--object")
# args.append("brown_box")
# args.append("--embodiment")
# args.append("g1_wbc_joint")
# run_subprocess(args)


# if __name__ == "__main__":
# test_g1_locomanip_gr00t_closedloop_policy_runner_single_env()
# test_g1_locomanip_gr00t_closedloop_policy_runner_multi_envs()
Loading
Loading