Skip to content

Commit 0b8f58a

Browse files
committed
impr(replayer): allow imports from other modules
1 parent 1d2b8f6 commit 0b8f58a

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

python/rcs/__main__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
app = typer.Typer()
2626

2727

28+
def _exec_import_statements(imports: list[str] | None) -> None:
29+
if imports is None:
30+
return
31+
32+
for import_statement in imports:
33+
exec(import_statement, {})
34+
35+
2836
@app.command()
2937
def consolidate(
3038
path: Annotated[
@@ -76,7 +84,15 @@ def replay(
7684
str,
7785
typer.Option(help="Environment id used in gym.make()."),
7886
] = "rcs/duo",
87+
imports: Annotated[
88+
list[str] | None,
89+
typer.Option(
90+
"--import",
91+
help="Python import statement to execute before resolving the environment. Repeat for multiple imports. Example: --import 'from rcs_duobench.tasks import bin_sort'",
92+
),
93+
] = None,
7994
):
95+
_exec_import_statements(imports)
8096
replay_dataset(
8197
dataset=dataset,
8298
output=output,

0 commit comments

Comments
 (0)