sycl setup: write_run_script takes setup.py's open_browser argument; Arc Pro B60 also as PCI id e211 (#870)

Fixes 1 and 4 of #870, plus a test that every function setup_intel.py swaps into setup.py accepts all of the original's parameters. Fixes 2 and 3 are PR #784's session/native_dense ports.

Co-authored-by: Magh97 <Magh97@users.noreply.github.com>
This commit is contained in:
Niko1221andMagh97 committed 2026-10-05 18:33:39 +02:00
1 parent fa228b094d
commit b72ea678be
2 files changed
+37 -2

No files matched your search

+2 -2
View File
@@ -209,11 +209,11 @@ def install(argv) -> None:
write = S.write_run_script
def write_run_script(model, cfg_path, port):
def write_run_script(model, cfg_path, port, open_browser=True): # setup.write_run_script's signature (#870)
cfg = json.loads(Path(cfg_path).read_text(encoding="utf-8"))
cfg = to_sycl(cfg, exe, real_ram, keep.get(Path(cfg_path).name, {}))
Path(cfg_path).write_text(json.dumps(cfg, indent=1), encoding="utf-8")
script = write(model, cfg_path, port)
script = write(model, cfg_path, port, open_browser)
script.write_text(script.read_text().replace(str(ROOT / "serve" / "server.py"), str(SERVER)))
return script
S.write_run_script = write_run_script
+35
View File
@@ -62,6 +62,41 @@ class SyclBackend(unittest.TestCase):
for name in re.findall(r'"(\w+)"', names):
self.assertTrue(callable(getattr(setup, name, None)), name)
def test_setup_intel_replacements_take_every_argument_of_the_function_they_replace(self):
"""#870: setup.py grew write_run_script's fourth argument and the port's replacement still took three, so
setup died with a TypeError after the download. Every `S.<name> = <replacement>` in setup_intel.py must accept
all the parameters of setup.<name> (or take *args / **kwargs)."""
import ast
import inspect
tree = ast.parse((ROOT / "sycl" / "setup_intel.py").read_text(encoding="utf-8"))
defs = {n.name: n for n in ast.walk(tree) if isinstance(n, ast.FunctionDef)}
checked = 0
for n in ast.walk(tree):
if not (isinstance(n, ast.Assign) and len(n.targets) == 1 and isinstance(n.targets[0], ast.Attribute)
and isinstance(n.targets[0].value, ast.Name) and n.targets[0].value.id == "S"):
continue
name = n.targets[0].attr
fn = n.value if isinstance(n.value, ast.Lambda) else defs.get(getattr(n.value, "id", ""))
orig = getattr(setup, name, None)
if fn is None or not callable(orig):
continue
a = fn.args
if a.vararg is not None and a.kwarg is not None:
checked += 1
continue
have = {x.arg for x in a.posonlyargs + a.args + a.kwonlyargs}
for param in inspect.signature(orig).parameters.values():
if param.kind in (param.VAR_POSITIONAL, param.VAR_KEYWORD):
continue
self.assertIn(param.name, have, f"setup_intel's {name} lacks setup.{name}'s `{param.name}`")
checked += 1
self.assertGreaterEqual(checked, 8)
def test_arc_pro_b60_is_known_under_both_pci_ids(self):
src = (ROOT / "sycl" / "setup_intel.py").read_text(encoding="utf-8")
self.assertIn('"e211": ("Arc Pro B60", 24.0)', src)
self.assertIn('"e221": ("Arc Pro B60", 24.0)', src)
class CMakeOption(unittest.TestCase):
def test_sycl_is_off_by_default_and_exclusive(self):