Skip to content

Commit

Permalink
fix(joblib): optimize test_batcher.py
Browse files Browse the repository at this point in the history
  • Loading branch information
entelecheia committed Jul 4, 2023
1 parent 484c06b commit d15c426
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/hyfi/joblib/test_batcher.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
from hyfi.joblib.batch.apply import Apply
from hyfi.joblib.batch.apply_batch import ApplyBatch
from hyfi.joblib import JobLibConfig


def batcher_test(backend):
print(f"Testing backend: {backend}")
joblib = JobLibConfig(
**{"distributed_framework": {"backend": backend}, "num_workers": 2}
)
joblib = JobLibConfig(backend=backend, num_workers=2, minibatch_size=2)
# b = Batcher(minibatch_size=2, backend=backend, procs=2)
joblib.initialize()
b = joblib._batcher_instance_
import numpy as np

a = Apply(np.power, b, [2], {})
print(a.transform([1, 2, 3, 4]))
a = ApplyBatch(np.power, b, [2], {})
print(a.transform([1, 2, 3, 4]))


def test_bacher_backends():
backends = ["serial", "threading", "multiprocessing", "ray", "loky", "joblilb"]
backends = ["serial", "threading", "multiprocessing"]
# sourcery skip: no-loop-in-tests
for backend in backends:
batcher_test(backend)
Expand Down

0 comments on commit d15c426

Please sign in to comment.