Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fixed
^^^^^

* Fixed the AutoMate ``run_w_id.py`` wrapper to accept ``--viz``/``--visualizer`` and forward additional arguments to the delegated RL-Games train/play script.
68 changes: 45 additions & 23 deletions source/isaaclab_tasks/isaaclab_tasks/direct/automate/run_w_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,8 @@ def update_task_param(task_cfg, assembly_id, if_sbc, if_log_eval):
f.writelines(updated_lines)


def main():
parser = argparse.ArgumentParser(description="Update assembly_id and run training script.")
parser.add_argument(
"--cfg_path",
type=str,
help="Path to the file containing assembly_id.",
default="source/isaaclab_tasks/isaaclab_tasks/direct/automate/assembly_tasks_cfg.py",
)
parser.add_argument("--assembly_id", type=str, help="New assembly ID to set.")
parser.add_argument("--checkpoint", type=str, help="Checkpoint path.")
parser.add_argument("--num_envs", type=int, default=128, help="Number of parallel environment.")
parser.add_argument("--seed", type=int, default=-1, help="Random seed.")
parser.add_argument("--train", action="store_true", help="Run training mode.")
parser.add_argument("--log_eval", action="store_true", help="Log evaluation results.")
parser.add_argument("--max_iterations", type=int, default=1500, help="Number of iteration for policy learning.")
args = parser.parse_args()

if args.assembly_id == "ASSEMBLY_ID":
parser.error("replace ASSEMBLY_ID with an AutoMate assembly ID, for example 00032")

update_task_param(args.cfg_path, args.assembly_id, args.train, args.log_eval)

# build the command
def build_command(args, downstream_args):
"""Build the delegated Isaac Lab command for the selected AutoMate assembly task."""
if sys.platform.startswith("win"):
command = ["isaaclab.bat"]
else:
Expand All @@ -88,6 +67,49 @@ def main():
if args.checkpoint:
command.append(f"--checkpoint={args.checkpoint}")

if args.visualizer:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: if args.visualizer is not None: would be safer than truthiness — an empty string "" is falsy and would silently skip forwarding. Matches the default=None sentinel more precisely.

command.extend(["--visualizer", args.visualizer])

command.extend(downstream_args)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note (low risk): Since --num_envs, --seed, etc. are emitted above from parsed defaults, a user who also passes --num_envs=64 as a "downstream" arg will produce a duplicate flag. Whether last-wins depends on the downstream argparser. Consider a brief comment noting this or placing downstream_args before the explicit flags.


return command


def main():
parser = argparse.ArgumentParser(
description="Update assembly_id and run training script.",
epilog="Additional arguments are forwarded to the delegated RL-Games train/play script.",
allow_abbrev=False,
)
parser.add_argument(
"--cfg_path",
type=str,
help="Path to the file containing assembly_id.",
default="source/isaaclab_tasks/isaaclab_tasks/direct/automate/assembly_tasks_cfg.py",
)
parser.add_argument("--assembly_id", type=str, help="New assembly ID to set.")
parser.add_argument("--checkpoint", type=str, help="Checkpoint path.")
parser.add_argument("--num_envs", type=int, default=128, help="Number of parallel environment.")
parser.add_argument("--seed", type=int, default=-1, help="Random seed.")
parser.add_argument("--train", action="store_true", help="Run training mode.")
parser.add_argument("--log_eval", action="store_true", help="Log evaluation results.")
parser.add_argument("--max_iterations", type=int, default=1500, help="Number of iteration for policy learning.")
parser.add_argument(
"--visualizer",
"--viz",
type=str,
default=None,
help="Visualizer backend(s) to forward to the delegated RL-Games script, for example 'kit'.",
)
args, downstream_args = parser.parse_known_args()

if args.assembly_id == "ASSEMBLY_ID":
parser.error("replace ASSEMBLY_ID with an AutoMate assembly ID, for example 00032")

update_task_param(args.cfg_path, args.assembly_id, args.train, args.log_eval)
Comment on lines +106 to +109

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 --assembly_id can be None and silently corrupts the config

assembly_id has no required=True and no None guard — only the sentinel string "ASSEMBLY_ID" is caught. When --assembly_id is omitted entirely, args.assembly_id is None, update_task_param writes assembly_id = 'None' into assembly_tasks_cfg.py, and eval_filename becomes evaluation_None.h5, without any error being surfaced. This pre-dated the PR but the refactor is a natural point to add required=True or an explicit None check here.


command = build_command(args, downstream_args)

# Run the command
subprocess.run(command, check=True)

Expand Down
Loading