Skip to content

Commit

Permalink
Merge pull request #977 from allenai/sceneNameFailure
Browse files Browse the repository at this point in the history
Better error message when passing in unknown scene
  • Loading branch information
mattdeitke committed Feb 6, 2022
2 parents e684b6f + af4f585 commit 1d35fba
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions ai2thor/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,19 +629,11 @@ def reset(self, scene=None, **init_params):
# scenes in build can be an empty set when GetScenesInBuild doesn't exist as an action
# for old builds
if self.scenes_in_build and scene not in self.scenes_in_build:

def key_sort_func(scene_name):
m = re.search(
r"FloorPlan[_]?([a-zA-Z\-]*)([0-9]+)_?([0-9]+)?.*$", scene_name
)
last_val = m.group(3) if m.group(3) is not None else -1
return m.group(1), int(m.group(2)), int(last_val)

raise ValueError(
"\nScene '{}' not contained in build (scene names are case sensitive)."
"\nPlease choose one of the following scene names:\n\n{}".format(
scene,
", ".join(sorted(list(self.scenes_in_build), key=key_sort_func)),
", ".join(sorted(list(self.scenes_in_build))),
)
)

Expand Down

0 comments on commit 1d35fba

Please sign in to comment.