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

Check tool versions at beginning of run #2000

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 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 Down Expand Up @@ -4224,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)
14 changes: 8 additions & 6 deletions tests/core/test_error_manifest.py
@@ -1,9 +1,12 @@
import siliconcompiler
from siliconcompiler.tools.surelog import parse
from siliconcompiler._common import SiliconCompilerError
import os

import pytest


@pytest.mark.quick
@pytest.mark.eda
def test_error_manifest():
'''
Executing a node with errors should still produce an output manifest
Expand All @@ -18,9 +21,8 @@ def test_error_manifest():
index = '0'
chip.node(flow, step, parse, index=index)

try:
with pytest.raises(siliconcompiler.SiliconCompilerError):
chip.run()
except SiliconCompilerError:
workdir = chip._getworkdir(jobname=chip._get_in_job(step, index), step=step, index=index)
cfg = os.path.join(workdir, 'outputs', f'{chip.top()}.pkg.json')
assert os.path.isfile(cfg)
workdir = chip._getworkdir(jobname=chip._get_in_job(step, index), step=step, index=index)
cfg = os.path.join(workdir, 'outputs', f'{chip.top()}.pkg.json')
assert os.path.isfile(cfg)
15 changes: 9 additions & 6 deletions tests/core/test_fail_early.py
@@ -1,9 +1,12 @@
import siliconcompiler
from siliconcompiler.tools.yosys import syn_asic
from siliconcompiler.tools.surelog import parse
from siliconcompiler._common import SiliconCompilerError

import pytest


@pytest.mark.quick
@pytest.mark.eda
def test_fail_early(capfd):
chip = siliconcompiler.Chip('test')
chip.set('input', 'rtl', 'verilog', 'fake.v')
Expand All @@ -15,9 +18,9 @@ def test_fail_early(capfd):
chip.node(flow, 'syn', syn_asic)
chip.edge(flow, 'import', 'syn')

try:
with pytest.raises(siliconcompiler.SiliconCompilerError):
chip.run()
except SiliconCompilerError:
# Fail if 'syn' step is run
out, _ = capfd.readouterr()
assert "Halting step 'syn'" not in out
# Fail if 'syn' step is run
out, _ = capfd.readouterr()
assert "Halting step 'import'" in out
assert "Halting step 'syn'" not in out
24 changes: 24 additions & 0 deletions tests/core/test_version_early.py
@@ -0,0 +1,24 @@
import siliconcompiler
from siliconcompiler.tools.surelog import parse

import pytest


@pytest.mark.eda
@pytest.mark.quick
def test_version_early(capfd):
chip = siliconcompiler.Chip('test')
chip.set('input', 'rtl', 'verilog', 'fake.v')
chip.load_target('freepdk45_demo')
chip.set('option', 'mode', 'asic')
flow = 'test'
chip.set('option', 'flow', flow)
chip.node(flow, 'import', parse)
chip.set('tool', 'surelog', 'version', '==100.0')

with pytest.raises(SystemExit):
chip.run()
# Fail if any task is run
out, _ = capfd.readouterr()
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