From 54df7572bd75ca7d90e282825fb422c67feeedd8 Mon Sep 17 00:00:00 2001 From: Troels Henriksen Date: Tue, 28 Apr 2026 11:49:24 +0200 Subject: [PATCH 1/2] Test pair projection. This will not work until https://github.com/diku-dk/futhark/pull/2410 is merged. --- futhark_server/__init__.py | 5 +++-- shell.nix | 7 +++++-- test.fut | 6 ++++-- test.py | 7 +++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/futhark_server/__init__.py b/futhark_server/__init__.py index 958ba50..89a5a47 100644 --- a/futhark_server/__init__.py +++ b/futhark_server/__init__.py @@ -136,8 +136,9 @@ def cmd_project(self, newname, name, field): def get_value(self, v): """Retrieve Futhark value in given variable. - This only produces a meaningful value if the type of the value - is non-opaque (i.e., a primitive or array of primitives). + This only produces a meaningful value if the type of the value is + non-opaque (i.e., a primitive, array of primitives, or tuple of + primitives). """ def unpack(val): diff --git a/shell.nix b/shell.nix index ba32bad..0889cba 100644 --- a/shell.nix +++ b/shell.nix @@ -3,11 +3,14 @@ let my-python-packages = ps: with ps; [ (buildPythonPackage rec { pname = "futhark-data"; - version = "1.0.2"; + version = "1.0.3"; src = fetchPypi { inherit pname version; - sha256 = "sha256-FJOhVr65U3kP408BbA42jbGGD6x+tVh+TNhsYv8bUT0="; + sha256 = "sha256-HoxeSLXt2B1X3PZmfZmnIOipLec4ba3VkUBLtZhVPPU="; }; + pyproject = true; + dependencies = [ numpy ] ; + build-system = [ setuptools ]; doCheck = false; }) numpy diff --git a/test.fut b/test.fut index 9d495f5..7ad381c 100644 --- a/test.fut +++ b/test.fut @@ -2,9 +2,11 @@ entry f0 : i64 = 1337 entry f1 (x: i64) : i64 = x + 1 -type r = {a:i64, b:bool} -entry const_record : r = {a=42,b=true} +type r = {a: i64, b: bool} +entry const_record : r = {a = 42, b = true} entry failing (x: i64) : i64 = assert false (x + 1) entry ensure_i32_arr (x: []i32) = x + +entry get_pair (x: i32) = (x + 1, x + 2) diff --git a/test.py b/test.py index 08e6c85..760973d 100644 --- a/test.py +++ b/test.py @@ -58,5 +58,12 @@ def test_put_arr_i32(self): self.server.put_value('v', arr) self.assertEqual(self.server.get_value('v').tolist(), arr.tolist()) + def test_get_pair(self): + self.server.put_value('v', np.int32(42)) + self.server.cmd_call('get_pair', 'out', 'v') + x, y = self.server.get_value('out') + self.assertEqual(x, np.int32(43)) + self.assertEqual(y, np.int32(44)) + if __name__ == '__main__': unittest.main() From c3f3953e15e7501daa976f29bfadc042e3d4f2cc Mon Sep 17 00:00:00 2001 From: Troels Henriksen Date: Wed, 29 Apr 2026 10:51:59 +0200 Subject: [PATCH 2/2] Also prepare for change to server protocol. --- futhark_server/__init__.py | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/futhark_server/__init__.py b/futhark_server/__init__.py index 89a5a47..ee2d77d 100644 --- a/futhark_server/__init__.py +++ b/futhark_server/__init__.py @@ -100,8 +100,8 @@ def cmd_rename(self, oldname, newname): def cmd_inputs(self, entry): return self.cmd('inputs', entry) - def cmd_outputs(self, entry): - return self.cmd('outputs', entry) + def cmd_output(self, entry): + return self.cmd('output', entry) def cmd_clear(self): self.cmd('clear') diff --git a/setup.py b/setup.py index 6de3672..e12d898 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import find_packages, setup setup(name='futhark-server', - version='1.0.0', + version='1.0.1', url='https://github.com/diku-dk/futhark-server-python', license='ISC', author='Troels Henriksen',