Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Troiber committed Sep 28, 2023
1 parent 7c2ea7c commit 658dd48
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
25 changes: 13 additions & 12 deletions siliconcompiler/core.py
Expand Up @@ -4196,6 +4196,17 @@ def _check_nodes_status(self, flow, status, steplist, indexlist):
if status[node] != NodeStatus.PENDING:
self.set('flowgraph', flow, step, index, 'status', status[node])

def _pre_run_version_check(self, flow, flowgraph_nodes):
# Don't print information messages produced by _check_tool_version()
prev_log_level = self.logger.level
self.logger.setLevel(logging.WARNING)

for (step, index) in flowgraph_nodes:
run_func = getattr(self._get_task_module(step, index, flow=flow), 'run', None)
self._check_tool_version(step, index, run_func)

self.logger.setLevel(prev_log_level)

def _local_process(self, flow, status, steplist, indexlist):
# Populate status dict with any flowgraph status values that have already
# been set.
Expand All @@ -4211,18 +4222,6 @@ def _local_process(self, flow, status, steplist, indexlist):
for (step, index) in flowgraph_nodes:
# Setting up tool is optional
self._setup_node(step, index)
# Env vars are necessary as test_multiple_tools.py requires it for its version check
self._set_env_vars(step, index)
tool, task = self._get_tool_task(step, index, flow)
# Icarus compiles its executable during the run so we can't check its version
if (tool, task) != ('execute', 'exec_input'):
run_func = getattr(self._get_task_module(step, index, flow=flow), 'run', None)
try:
self._check_tool_version(step, index, run_func)
# Convert sys.exit(1) from haltstep() in version check to SilicoCompilerError
except SystemExit:
self.error('Pre-run version check failed. Please update your tools.',
fatal=True)

# Check validity of setup
self.logger.info("Checking manifest before running.")
Expand All @@ -4236,6 +4235,8 @@ def _local_process(self, flow, status, steplist, indexlist):
if self._error:
self.error('Implementation errors encountered. See previous errors.', fatal=True)

self._pre_run_version_check(flow, flowgraph_nodes)

nodes_to_run = {}
processes = {}
self._prepare_nodes(nodes_to_run, processes, flow, status, steplist, indexlist)
Expand Down
3 changes: 2 additions & 1 deletion siliconcompiler/tools/execute/execute.py
Expand Up @@ -11,5 +11,6 @@ def setup(chip):

tool, task = chip._get_tool_task(step, index)

chip.set('tool', tool, 'exe', ":exe:", clobber=False)
# Use dummy bash executable 'true' to pass pre-run version check
chip.set('tool', tool, 'exe', 'true', clobber=False)
chip.set('tool', tool, 'task', task, 'option', [], step=step, index=index, clobber=False)
7 changes: 4 additions & 3 deletions tests/core/test_version_early.py
Expand Up @@ -4,6 +4,8 @@
import pytest


@pytest.mark.eda
@pytest.mark.quick
def test_version_early(capfd):
chip = siliconcompiler.Chip('test')
chip.set('input', 'rtl', 'verilog', 'fake.v')
Expand All @@ -14,10 +16,9 @@ def test_version_early(capfd):
chip.node(flow, 'import', parse)
chip.set('tool', 'surelog', 'version', '==100.0')

with pytest.raises(siliconcompiler.SiliconCompilerError,
match='Pre-run version check failed. Please update your tools.'):
with pytest.raises(SystemExit):
chip.run()
# Fail if any task is run
out, _ = capfd.readouterr()
assert "Halting step 'import'" in out
assert "Version check failed" in out
assert "Finished task in" not in out
3 changes: 3 additions & 0 deletions tests/flows/test_multiple_tools.py
Expand Up @@ -55,6 +55,9 @@ def test_multiple_tools():
chip.set('tool', 'surelog', 'licenseserver', 'ACME_LICENSE', '1700@server',
step='slog', index=1)

# Set env vars for slog1 for pre-run version check
chip._set_env_vars('slog', '1')

# Don't run tools, just version check
chip.set('option', 'skipall', True)
chip.run()
Expand Down

0 comments on commit 658dd48

Please sign in to comment.