From 094bf9a9351fd56927ac157198cbff0acfb81297 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 5 Jul 2024 16:38:41 +0700 Subject: [PATCH] Create DistributedComputing.py --- .ai/models/DistributedComputing.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .ai/models/DistributedComputing.py diff --git a/.ai/models/DistributedComputing.py b/.ai/models/DistributedComputing.py new file mode 100644 index 0000000..b04910e --- /dev/null +++ b/.ai/models/DistributedComputing.py @@ -0,0 +1,13 @@ +from dask.distributed import Client + +class DistributedComputing: + def __init__(self, client): + self.client = client + + def compute(self, func, data): + future = self.client.submit(func, data) + result = future.result() + return result + + def close(self): + self.client.close()