From b0362710f440915a8df56c3c28331c195f598632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Thu, 17 Jul 2025 06:27:27 +0200 Subject: [PATCH 1/3] Add test for execute_with_pysqa() --- tests/test_fluxclusterexecutor.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/test_fluxclusterexecutor.py b/tests/test_fluxclusterexecutor.py index 46637606..a48a8107 100644 --- a/tests/test_fluxclusterexecutor.py +++ b/tests/test_fluxclusterexecutor.py @@ -2,6 +2,7 @@ import importlib import unittest import shutil +from time import sleep from executorlib import FluxClusterExecutor from executorlib.standalone.serialize import cloudpickle_register @@ -9,7 +10,7 @@ try: import flux.job from executorlib.task_scheduler.file.hdf import dump - from executorlib.task_scheduler.file.queue_spawner import terminate_with_pysqa, terminate_tasks_in_cache + from executorlib.task_scheduler.file.queue_spawner import terminate_with_pysqa, terminate_tasks_in_cache, execute_with_pysqa skip_flux_test = "FLUX_URI" not in os.environ pmi = os.environ.get("EXECUTORLIB_PMIX", None) @@ -59,8 +60,15 @@ def test_executor_no_cwd(self): self.assertEqual(len(os.listdir("executorlib_cache")), 2) self.assertTrue(fs1.done()) - def test_terminate_with_pysqa(self): - self.assertIsNone(terminate_with_pysqa(queue_id=1, backend="flux")) + def test_pysqa_interface(self): + queue_id = execute_with_pysqa( + command=["sleep", "10"], + file_name="test.h5", + data_dict={"fn": sleep}, + cache_directory="executorlib_cache", + backend="flux" + ) + self.assertIsNone(terminate_with_pysqa(queue_id=queue_id, backend="flux")) def test_executor_existing_files(self): with FluxClusterExecutor( From 33063f4d811250625e2e384a3f4fe57988049122 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Thu, 17 Jul 2025 06:40:38 +0200 Subject: [PATCH 2/3] Update test_fluxclusterexecutor.py --- tests/test_fluxclusterexecutor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fluxclusterexecutor.py b/tests/test_fluxclusterexecutor.py index a48a8107..3d44bf8e 100644 --- a/tests/test_fluxclusterexecutor.py +++ b/tests/test_fluxclusterexecutor.py @@ -62,7 +62,7 @@ def test_executor_no_cwd(self): def test_pysqa_interface(self): queue_id = execute_with_pysqa( - command=["sleep", "10"], + command=["flux", "run", "sleep", "10"], file_name="test.h5", data_dict={"fn": sleep}, cache_directory="executorlib_cache", From 468b0eade0ea48821210c22ea1e5379b596cc921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Thu, 17 Jul 2025 06:57:42 +0200 Subject: [PATCH 3/3] extend test --- tests/test_fluxclusterexecutor.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_fluxclusterexecutor.py b/tests/test_fluxclusterexecutor.py index 3d44bf8e..f2f90ce0 100644 --- a/tests/test_fluxclusterexecutor.py +++ b/tests/test_fluxclusterexecutor.py @@ -11,6 +11,7 @@ import flux.job from executorlib.task_scheduler.file.hdf import dump from executorlib.task_scheduler.file.queue_spawner import terminate_with_pysqa, terminate_tasks_in_cache, execute_with_pysqa + from executorlib.task_scheduler.file.shared import _get_execute_command skip_flux_test = "FLUX_URI" not in os.environ pmi = os.environ.get("EXECUTORLIB_PMIX", None) @@ -62,9 +63,13 @@ def test_executor_no_cwd(self): def test_pysqa_interface(self): queue_id = execute_with_pysqa( - command=["flux", "run", "sleep", "10"], - file_name="test.h5", - data_dict={"fn": sleep}, + command=_get_execute_command( + file_name="test_i.h5", + cores=1, + ), + file_name="test_i.h5", + data_dict={"fn": sleep, "args": (10,)}, + resource_dict={"cores": 1}, cache_directory="executorlib_cache", backend="flux" )