IROS-2025-Challenge-Manip / dataset_post_processing.py
JiantongChen's picture
Upload dataset_post_processing.py with huggingface_hub
76a137a verified
import argparse
import os
import subprocess
def execute_in_directory(directory, command):
original_dir = os.getcwd()
try:
os.chdir(directory)
result = subprocess.run(
command,
shell=True,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
# print(f"success:\n{result.stdout}")
return result.returncode
except subprocess.CalledProcessError as e:
print(f"error:\n{e.stderr}")
return e.returncode
finally:
os.chdir(original_dir)
def main(root_dir):
for root, _, files in os.walk(root_dir):
if "scene.usd" in files:
if os.path.exists(os.path.join(root, "SubUSDs")):
bash_command = "rm ./SubUSDs"
execute_in_directory(root, bash_command)
bash_command = "ln -s ../SubUSDs ./SubUSDs"
execute_in_directory(root, bash_command)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='add soft link file')
parser.add_argument('val_dataset_path',
type=str,
help='dataset path')
args = parser.parse_args()
main(args.val_dataset_path)