Skip to content

Commit

Permalink
feat(core): runner gets extra args for running engine (#47)
Browse files Browse the repository at this point in the history
* feat(core): runner gets extra args for running engine

* feat(engines): saver extra args

* perf: remove temporal print for debugging
  • Loading branch information
henrylee97 authored Nov 29, 2023
1 parent 538b4b5 commit 9438fcb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion kaprese/bin/kaprese_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ def main(
help='benchmark to run (see "kaprese benchmark list")',
)

parser.add_argument(
"extra_args",
nargs="*",
help="extra arguments for engine (e.g. -- -j4)",
)

# Branching to pass type checking
args = parser.parse_args(argv, namespace=args) if args else parser.parse_args(argv)

Expand Down Expand Up @@ -369,7 +375,7 @@ def main(

# Start preparing
row.prepare_start()
runner = Runner(bench, engine, args.output)
runner = Runner(bench, engine, args.output, args.extra_args)
prepared = runner.prepare(force=args.rebuild_runner)
row.prepare_done(prepared)
if not prepared:
Expand Down
9 changes: 8 additions & 1 deletion kaprese/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@

class Runner:
def __init__(
self, benchmark: Benchmark, engine: Engine, output_dir: str | None = None
self,
benchmark: Benchmark,
engine: Engine,
output_dir: str | None = None,
extra_args: str | list[str] = "",
):
self.benchmark = benchmark
self.engine = engine
self.extra_args = (
extra_args if isinstance(extra_args, str) else " ".join(extra_args)
)

self.output_dir = Path(
f"{output_dir or 'kaprese-out'}/{engine.name}/{benchmark.name}"
Expand Down
2 changes: 1 addition & 1 deletion kaprese/engines/saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def register_saver(overwrite: bool = False) -> None:
exec_commands=[
"make clean -j$(nproc) >/dev/null",
"infer capture -- make -j$(nproc) >/dev/null",
'infer saver --error-report report.json $([ -e api.json ] && echo \\"--resource-api-spec api.json\\")',
'infer saver --error-report report.json $([ -e api.json ] && echo \\"--resource-api-spec api.json\\") {runner.extra_args}',
"export RETURN_CODE=$?",
"cp -r infer-out/* {runner.mount_dir}/",
"chown -R {runner.uid}:{runner.gid} {runner.mount_dir}",
Expand Down

0 comments on commit 9438fcb

Please sign in to comment.