Skip to content

Commit d3862ed

Browse files
authored
Pass executor options to default threads executor (#839)
1 parent fa009ae commit d3862ed

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

cubed/core/array.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from cubed import config
77
from cubed.backend_array_api import namespace as nxp
88
from cubed.backend_array_api import numpy_array_to_backend_array
9+
from cubed.runtime.create import create_executor
910
from cubed.runtime.types import Callback, Executor
1011
from cubed.spec import Spec, spec_from_config
1112
from cubed.storage.zarr import open_if_lazy_zarr_array
@@ -296,11 +297,9 @@ def compute(
296297
compile_function=compile_function,
297298
)
298299
if executor is None:
299-
executor = arrays[0].spec.executor
300+
executor = spec.executor
300301
if executor is None:
301-
from cubed.runtime.executors.local import ThreadsExecutor
302-
303-
executor = ThreadsExecutor()
302+
executor = create_executor("threads", spec.executor_options)
304303

305304
# combine any callbacks specified as args with any active callbacks from the context manager
306305
if callbacks is None and len(Callback.active) == 0:

cubed/tests/test_core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import platform
23
import random
34
from functools import partial
@@ -504,7 +505,11 @@ def test_default_spec_config_override():
504505
from cubed import config
505506

506507
with config.set(
507-
{"spec.allowed_mem": "4GB", "spec.executor_name": "single-threaded"}
508+
{
509+
"spec.allowed_mem": "4GB",
510+
# need to decrease max workers proportionately
511+
"spec.executor_options.max_workers": os.cpu_count() // 2,
512+
}
508513
):
509514
a = xp.ones((20000, 10000), chunks=(10000, 10000))
510515
b = xp.negative(a)

0 commit comments

Comments
 (0)