Skip to content

refactor: Move tool name to FlowCfg#149

Merged
rswarbrick merged 1 commit intolowRISC:masterfrom
rswarbrick:tool-field-at-run-time
Apr 6, 2026
Merged

refactor: Move tool name to FlowCfg#149
rswarbrick merged 1 commit intolowRISC:masterfrom
rswarbrick:tool-field-at-run-time

Conversation

@rswarbrick
Copy link
Copy Markdown
Contributor

@rswarbrick rswarbrick commented Apr 2, 2026

This value was always actually supplied (either directly in SimCfg or
through OneShotCfg). Move it to the base class and consume it in just
one place.

A specific type looks like there might be problems where we try to run
a job without having decided on the tool. The second instance of
this (in CovReport.post_finish) can definitely never happen, but the
example in Deploy.get_job_spec is less obvious to me, so I've put in a
runtime check.

Copy link
Copy Markdown
Contributor

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is definitely an easy stop-gap for now, but I checked your strong suspcicion and can confirm that in all the different flows this attribute is defined. SimCfg and OneShotCfg set it directly from args.tool, FormalCfg, LintCfg and SyncCfg inherit it from OneShotCfg, and CdcCfg & RdcCfg inherit it from LintCfg.

So this could be added to FlowCfg.__init__ as self.tool: str | None = args.tool (since the --tool argument can be unspecified), and then this runtime check should instead be that the value is not None. If you don't mind the little extra effort, could you make this change?

@rswarbrick rswarbrick force-pushed the tool-field-at-run-time branch from c86c43f to 29986b0 Compare April 3, 2026 21:55
@rswarbrick rswarbrick changed the title Move get_job_spec's check that the FlowCfg has "tool" to run-time refactor: Move tool name to FlowCfg Apr 3, 2026
@rswarbrick rswarbrick marked this pull request as ready for review April 3, 2026 21:56
@rswarbrick rswarbrick requested a review from AlexJones0 April 3, 2026 21:56
@rswarbrick
Copy link
Copy Markdown
Contributor Author

@AlexJones0: You're completely right! Thanks! I think I've tweaked everything to match now?

Comment thread src/dvsim/job/deploy.py Outdated
if self.sim_cfg.tool is None:
msg = (
"No tool selected in job configuration. It must either be "
"specified in the hjson or passed with the --tool argument."
Copy link
Copy Markdown
Contributor

@AlexJones0 AlexJones0 Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: extra space

Suggested change
"specified in the hjson or passed with the --tool argument."
"specified in the hjson or passed with the --tool argument."

Comment thread src/dvsim/job/deploy.py Outdated
# At this point, we have finished running a tool, so we know that
# self.sim_cfg.tool must have been set.
if self.sim_cfg.tool is None:
raise AssertionError("sim_cfg.tool cannot be None now.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: AssertionError is typically intended for use in the built-in assert statement, I would suggest using a RuntimeError here instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that makes sense. I'll switch over to that. I think I was intending it to mean "Oh no! Bug in tool" (as opposed to "Naughty user: that's a silly thing to do."), but agree that AssertionError isn't the right way to do that.

Is there a standard way to make this distinction in Python code?

This value was always actually supplied (either directly in SimCfg or
through OneShotCfg). Move it to the base class and consume it in just
one place.

A specific type looks like there might be problems where we try to run
a job without having decided on the tool. The second instance of
this (in CovReport.post_finish) can definitely never happen, but the
example in Deploy.get_job_spec is less obvious to me, so I've put in a
runtime check.

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
@rswarbrick rswarbrick force-pushed the tool-field-at-run-time branch from 29986b0 to 52081e8 Compare April 6, 2026 20:34
@rswarbrick rswarbrick added this pull request to the merge queue Apr 6, 2026
Merged via the queue into lowRISC:master with commit 51e3655 Apr 6, 2026
6 checks passed
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.

2 participants