Skip to content

Commit

Permalink
switch to pydo
Browse files Browse the repository at this point in the history
  • Loading branch information
asaiacai committed Aug 20, 2024
1 parent fa8a6bb commit cc8384e
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 272 deletions.
14 changes: 14 additions & 0 deletions sky/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from sky.adaptors import kubernetes
from sky.adaptors import runpod
from sky.clouds.utils import lambda_utils
from sky.provision.do import utils as do_utils
from sky.provision.fluidstack import fluidstack_utils
from sky.provision.kubernetes import utils as kubernetes_utils
from sky.utils import common_utils
Expand Down Expand Up @@ -471,3 +472,16 @@ def setup_fluidstack_authentication(config: Dict[str, Any]) -> Dict[str, Any]:
client.get_or_add_ssh_key(public_key)
config['auth']['ssh_public_key'] = PUBLIC_SSH_KEY_PATH
return configure_ssh_info(config)


def setup_do_authentication(config: Dict[str, Any]) -> Dict[str, Any]:

get_or_generate_keys()

public_key_path = os.path.expanduser(PUBLIC_SSH_KEY_PATH)
public_key = None
with open(public_key_path, 'r', encoding='utf-8') as f:
public_key = f.read()
do_utils.get_or_create_ssh_keys(public_key)
config['auth']['ssh_public_key'] = PUBLIC_SSH_KEY_PATH
return configure_ssh_info(config)
3 changes: 2 additions & 1 deletion sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,6 @@ def _add_auth_to_cluster_config(cloud: clouds.Cloud, cluster_config_file: str):
clouds.SCP,
clouds.Vsphere,
clouds.Cudo,
clouds.DigitalOcean,
clouds.Paperspace,
clouds.Azure,
)):
Expand All @@ -1043,6 +1042,8 @@ def _add_auth_to_cluster_config(cloud: clouds.Cloud, cluster_config_file: str):
config = auth.setup_runpod_authentication(config)
elif isinstance(cloud, clouds.Fluidstack):
config = auth.setup_fluidstack_authentication(config)
elif isinstance(cloud, clouds.DO):
config = auth.setup_do_authentication(config)
else:
assert False, cloud
common_utils.dump_yaml(cluster_config_file, config)
Expand Down
3 changes: 2 additions & 1 deletion sky/clouds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sky.clouds.aws import AWS
from sky.clouds.azure import Azure
from sky.clouds.cudo import Cudo
from sky.clouds.do import DO
from sky.clouds.fluidstack import Fluidstack
from sky.clouds.gcp import GCP
from sky.clouds.ibm import IBM
Expand All @@ -32,7 +33,7 @@
'Azure',
'Cloud',
'Cudo',
'DigitalOcean'
'DO',
'GCP',
'Lambda',
'Paperspace',
Expand Down
1 change: 1 addition & 0 deletions sky/clouds/cloud_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def from_str(self, name: Optional[str]) -> Optional['cloud.Cloud']:

def register(self, cloud_cls: Type['cloud.Cloud']) -> Type['cloud.Cloud']:
name = cloud_cls.__name__.lower()
# import pdb; pdb.set_trace()
assert name not in self, f'{name} already registered'
self[name] = cloud_cls()
return cloud_cls
Expand Down
40 changes: 0 additions & 40 deletions sky/provision/do/config.py

This file was deleted.

6 changes: 3 additions & 3 deletions sky/provision/do/instance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""DigitalOcean instance provisioning."""

import pydo
import time
from typing import Any, Dict, List, Optional

Expand All @@ -21,14 +22,13 @@

def _filter_instances(cluster_name_on_cloud: str,
status_filters: Optional[List[str]]) -> Dict[str, Any]:
client = utils.DigitalOceanCloudClient()
instances = client.list_instances()
response = utils.client.droplets.list()
possible_names = [
f'{cluster_name_on_cloud}-head',
f'{cluster_name_on_cloud}-worker',
]

filtered_instances = {}
filtered_instances: Dict[str, Any] = {}
for instance in instances:
instance_id = instance['id']
if status_filters is not None and instance[
Expand Down
Loading

0 comments on commit cc8384e

Please sign in to comment.