Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scenario build error message improvements #2055

Merged
merged 5 commits into from
Jun 8, 2023

Conversation

saulfield
Copy link
Contributor

When an error is encountered while building a scenario, the error message can be cryptic because it is actually running a temp file, and the stack trace is noisy:

Building: scenarios/sumo/loop/
Traceback (most recent call last):
  File "tmpjv0_4z2_.py", line 14, in <module>
    traffic = t.Traffic(
NameError: name 't' is not defined
Traceback (most recent call last):
  File "/home/saul/code/SMARTS/.venv/bin/scl", line 8, in <module>
    sys.exit(scl())
  File "/home/saul/code/SMARTS/.venv/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/saul/code/SMARTS/.venv/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/saul/code/SMARTS/.venv/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/saul/code/SMARTS/.venv/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/saul/code/SMARTS/.venv/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/saul/code/SMARTS/.venv/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/saul/code/SMARTS/cli/studio.py", line 55, in build
    build_scenario(scenario=scenario, clean=clean, seed=seed, log=click.echo)
  File "/home/saul/code/SMARTS/smarts/sstudio/scenario_construction.py", line 62, in build_scenario
    subprocess.check_call(
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/saul/code/SMARTS/.venv/bin/python3.8', 'tmpjv0_4z2_.py']' returned non-zero exit status 1.

I changed it so that no temp file is created, and I trimmed the error message:

Building: scenarios/sumo/loop/
Traceback (most recent call last):
  File "scenario_builder.py", line 45, in <module>
    _build(args.scenario_py, args.seed)
  File "scenario_builder.py", line 33, in _build
    exec(code, {"__file__": scenario_py})
  File "/home/saul/code/SMARTS/scenarios/sumo/loop/scenario.py", line 9, in <module>
    traffic = t.Traffic(
NameError: name 't' is not defined
Command '['/home/saul/code/SMARTS/.venv/bin/python3.8', 'scenario_builder.py', '/home/saul/code/SMARTS/scenarios/sumo/loop/scenario.py', '42']' returned non-zero exit status 1.

We could remove even more of the error message if we want.

@saulfield saulfield requested review from Gamenot and Adaickalavan June 6, 2023 17:59
@saulfield saulfield merged commit cf87c1e into master Jun 8, 2023
@saulfield saulfield deleted the saul/scenario-build-improvements branch June 8, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants