-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Midterm milestone from CMU team on Develop dask"
- Loading branch information
Showing
30 changed files
with
1,168,519 additions
and
4,644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,45 @@ | ||
# TODO: Change all documentation to sphinx | ||
try: | ||
# Import checks | ||
import os | ||
from sdt_dask.clients.clients import Clients | ||
from dask_cloudprovider.aws import FargateCluster | ||
from dask.distributed import Client | ||
|
||
# Raises exception if modules aren't installed in the environment | ||
except ModuleNotFoundError as error: | ||
packages = "\tos\n\tdask.distributed\n\tdask_cloudprovider" | ||
msg = f"{error}\n[!] Check or reinstall the following packages\n{packages}" | ||
raise ModuleNotFoundError(msg) | ||
|
||
finally: | ||
class Fargate(Clients): | ||
|
||
def __init__(self, | ||
image: str = "", | ||
tags: dict = {}, # optional | ||
vpc: str = "", | ||
region_name: str = "", | ||
environment: dict = {}, | ||
n_workers: int = 10, | ||
threads_per_worker: int = 2 | ||
): | ||
self.image = image | ||
self.tags = tags | ||
self.vpc = vpc | ||
self.region_name = region_name | ||
self.environment = environment | ||
self.n_workers = n_workers | ||
self.threads_per_worker = threads_per_worker | ||
def _check_versions(self): | ||
data = self.client.get_versions(check=True) | ||
scheduler_pkgs = data['scheduler']['packages'] | ||
client_pkgs = data['client']['packages'] | ||
|
||
for (c_pkg, c_ver), (s_pkg, s_ver) in zip(scheduler_pkgs.items(), client_pkgs.items()): | ||
if c_ver != s_ver: | ||
msg = 'Please Update the client version to match the Scheduler version' | ||
raise EnvironmentError(f"{c_pkg} version Mismatch:\n\tScheduler: {s_ver} vs Client: {c_ver}\n{msg}") | ||
|
||
def init_client(self) -> tuple: | ||
try: | ||
print("[i] Initilializing Fargate Cluster ...") | ||
|
||
cluster = FargateCluster( | ||
tags = self.tags, | ||
image = self.image, | ||
vpc = self.vpc, | ||
region_name = self.region_name, | ||
environment = self.environment, | ||
n_workers = self.n_workers, | ||
worker_nthreads = self.threads_per_worker | ||
) | ||
|
||
print("[i] Initialized Fargate Cluster") | ||
print("[i] Initilializing Dask Client ...") | ||
|
||
self.client = Client(cluster) | ||
|
||
self._check_versions() | ||
|
||
print(f"[>] Dask Dashboard: {self.client.dashboard_link}") | ||
|
||
return self.client, cluster | ||
except Exception as e: | ||
raise Exception(e) | ||
"""Note: this module is not yet implemented. | ||
This can be written as an example of how to create a Dask client (given some resources) | ||
that will integrate seamlessly with our SDT Dask tool. | ||
We should determine if this module/class would be helpful/is needed. | ||
""" | ||
|
||
from dask.distributed import Client | ||
from dask_cloudprovider.aws import FargateCluster | ||
""" | ||
Optional: | ||
tags: only use this if your organization enforces tag policies | ||
Required: | ||
image: should be a dockerhub public image. Please customize your image if needed | ||
""" | ||
|
||
|
||
def _init_fargate_cluster(**kwargs) -> FargateCluster: | ||
cluster = FargateCluster(kwargs) | ||
return cluster | ||
|
||
|
||
def _init_dask_client(cluster: FargateCluster) -> Client: | ||
client = Client(cluster) | ||
return client | ||
|
||
|
||
def get_fargate_cluster( | ||
tags={}, | ||
image="", | ||
vpc="", | ||
region_name="", | ||
environment={}, | ||
n_workers=10 | ||
) -> Client: | ||
|
||
cluster = _init_fargate_cluster( | ||
tags={}, | ||
image="", | ||
vpc="", | ||
region_name="", | ||
environment={}, | ||
n_workers=10 | ||
) | ||
|
||
return _init_dask_client(cluster) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.