Skip to content

run_recorded.py: AttributeError: 'str' object has no attribute '__name__' when replaying with the recorded env config #29

Description

@rakhimovv

Description

First, thanks for the faithful-replay work in a9b83ab — restoring the recorded env config is exactly what I needed for reproducible playback.

I ran into a crash on that path at current main (9db0aaf). examples/run_recorded.py fails while building the env, before the episode starts, when it restores the recorded env_cfg.json. Passing --env-config current works, which narrows it to the sidecar restore rather than the replay itself.

The cause appears to be subtask conditionals coming back as strings. examples/recorded_data/RubiksCubeAndBananaTask/env_cfg.json stores them as str(partial):

/subtasks[0]/conditions/rubiks_cube[0][0] =
  "functools.partial(<function object_grabbed at 0x796faeb54fe0>, object='rubiks_cube')"

In robolab/core/replay/env_config.py, _overlay reaches the isinstance(value, list) branch (lines 141-151). Since the elements are lists ([str, float]) rather than dicts, it assigns the list verbatim, replacing the live (partial, score) tuples with those strings. The callable(target) guard at line 160, which would have converted them, only applies to a scalar string — so strings nested inside a list never reach it.

conditionals_state_machine.py:555 then calls func_as_str() on a str, and function_loader.py:22 does func.__name__.

This is reached by default rather than under an opt-in flag: run_recorded.py:91 sets robolab.constants.VERBOSE = True unconditionally, and conditionals_state_machine.py:113 gates the printing on exactly that flag.

Reproduction

python examples/run_recorded.py --headless

# or, equivalently
python examples/run_recorded.py --task RubiksCubeAndBananaTask --headless --validate-states

Both use the bundled examples/recorded_data/RubiksCubeAndBananaTask/, with the default --env-config recorded.

Observed behavior

Subtask 1 'pick_and_place': Overall: 0/4 (score=0.00), Object progress: [rubiks_cube: 0/2(score=0.00), banana: 0/2(score=0.00)], logical: all
  rubiks_cube (0/2) (score=0.00):
Terminated with error: 'str' object has no attribute '__name__'
Traceback (most recent call last):
  File "examples/run_recorded.py", line 214, in <module>
    main()
  File "examples/run_recorded.py", line 152, in main
    env, env_cfg = create_env(scene,
  File "robolab/core/environments/runtime.py", line 214, in create_env
    env = RobolabEnv(env_cfg)
  [... env / manager construction through isaaclab's recorder_manager ...]
  File "robolab/core/events/subtask_recorder.py", line 39, in <listcomp>
    SubtaskStateMachine(
  File "robolab/core/task/subtask_state_machine.py", line 59, in __init__
    self._initialize_state_machine()
  File "robolab/core/task/subtask_state_machine.py", line 80, in _initialize_state_machine
    self.conditionals_state_machine = ConditionalsStateMachine(
  File "robolab/core/task/conditionals_state_machine.py", line 81, in __init__
    self._initialize_tracker()
  File "robolab/core/task/conditionals_state_machine.py", line 113, in _initialize_tracker
    self._print_current_state()
  File "robolab/core/task/conditionals_state_machine.py", line 583, in _print_current_state
    subtask_str = generate_subtask_string(obj_name, i, current_idx, conditional_func, score)
  File "robolab/core/task/conditionals_state_machine.py", line 555, in generate_subtask_string
    subtask_str = func_as_str(conditional_func)
  File "robolab/core/utils/function_loader.py", line 31, in func_as_str
    func_name, params = get_callable_info(func)
  File "robolab/core/utils/function_loader.py", line 22, in get_callable_info
    func_name = func.__name__
AttributeError: 'str' object has no attribute '__name__'

There is a secondary problem in the handler: run_recorded.py:218 calls simulation_app.close() on the half-constructed env and hangs there, so the process never reaches the sys.exit(1) on the next line. Every one of my runs had to be killed by an external timeout (observed at 400s, 1800s and 1802s) rather than exiting non-zero.

Expected behavior

The episode replays, as it does with the current config:

Running RubiksCubeAndBananaTask_run0: 'Put the cube and the banana in the bowl'
Task Name               Success    %     95% CI         Score(total) ...
RubiksCubeAndBananaTask 1/1      100.0%  [15.8-98.7]    1.000        ...

(trailing columns trimmed for width; the process exits 0)

Reproducibility

Four runs, all identical, so this does not appear to be hardware- or environment-dependent:

environment result
H100 80GB, driver 580.126.16, local checkout AttributeError
same, with --validate-states AttributeError
same, second clean serial run AttributeError
RTX PRO 6000 Blackwell, separate container, fresh uv sync, repo extracted fresh AttributeError

In the container run, pytest tests/ was 202/202 and the other five examples/ scripts exited 0, so the environments themselves look healthy.

Possibly related

#20 reports this same command at 0aef241 completing with score: 0.0 rather than raising. a9b83ab is an ancestor of 0aef241 (git merge-base --is-ancestor confirms), so the overlay was already in place for that run. I have not bisected the 13 commits between 0aef241 and 9db0aaf, so I can't say whether something changed in between; robolab/core/task/conditionals.py changed substantially in 75210b1 (multi-gripper conditional support), which seemed the most plausible place to look if this is a regression. Happy to bisect if that would help.

Environment

  • RoboLab: 9db0aaf (main)
  • Isaac Sim 5.0.0 / Isaac Lab 2.2.0, installed with uv sync -p 3.11 --extra isaac50
  • Python 3.11.15
  • GPUs: NVIDIA H100 80GB (driver 580.126.16) and NVIDIA RTX PRO 6000 Blackwell
  • OS: Linux 5.15.0-179-generic

I'm glad to put up a PR if that's useful — CONTRIBUTING.md asks for an Issue first on robolab/core/ changes, which is why I'm starting here. Happy to follow whatever shape you'd prefer for the fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions