Skip to content

Commit 904809c

Browse files
cagataycaliStrands Robot Agent
authored andcommitted
fix(lerobot): catch TypeError from dataclass field ordering in policy resolution
lerobot's internal dataclasses can raise TypeError ('non-default argument follows default argument') when imported in newer versions. This causes resolve_policy_class_by_name to propagate TypeError instead of falling through to ImportError. Catch TypeError alongside ImportError in all resolution strategies so the function degrades gracefully.
1 parent 49db20d commit 904809c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

strands_robots/policies/lerobot_local/resolution.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def resolve_policy_class_by_name(policy_type: str) -> type[Any]:
208208
and hasattr(obj, "from_pretrained")
209209
):
210210
return obj
211-
except ImportError:
211+
except (ImportError, TypeError):
212212
pass
213213

214214
# Strategy 2: Direct package-level import
@@ -223,15 +223,15 @@ def resolve_policy_class_by_name(policy_type: str) -> type[Any]:
223223
and hasattr(obj, "from_pretrained")
224224
):
225225
return obj
226-
except ImportError:
226+
except (ImportError, TypeError):
227227
pass
228228

229229
# Strategy 3: Legacy get_policy_class (LeRobot <0.4)
230230
try:
231231
from lerobot.policies.factory import get_policy_class
232232

233233
return get_policy_class(policy_type)
234-
except (ImportError, AttributeError, RuntimeError):
234+
except (ImportError, AttributeError, RuntimeError, TypeError):
235235
pass
236236

237237
# Strategy 4: PreTrainedPolicy - only if it's NOT abstract
@@ -240,7 +240,7 @@ def resolve_policy_class_by_name(policy_type: str) -> type[Any]:
240240

241241
if not inspect.isabstract(PreTrainedPolicy):
242242
return PreTrainedPolicy
243-
except ImportError:
243+
except (ImportError, TypeError):
244244
pass
245245

246246
raise ImportError(

0 commit comments

Comments
 (0)