Skip to content

Commit

Permalink
rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
landscapepainter committed Apr 15, 2023
1 parent d19e3fd commit 6ee3952
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
20 changes: 0 additions & 20 deletions sky/global_user_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,26 +664,6 @@ def get_enabled_clouds() -> List[clouds.Cloud]:
return enabled_clouds


def get_enabled_clouds_str() -> List[str]:
# Currently, 'clouds' only support cloud types with
# computing instances. The following is to temporarily
# support R2 for get_enabled_clouds
rows = _DB.cursor.execute('SELECT value FROM config WHERE key = ?',
(_ENABLED_CLOUDS_KEY,))
ret = []
for (value,) in rows:
ret = json.loads(value)
break
enabled_clouds: List[str] = []
for c in ret:
cloud = clouds.CLOUD_REGISTRY.from_str(c)
if cloud is not None:
enabled_clouds.append(str(cloud))
if os.path.exists(os.path.expanduser(cloudflare.ACCOUNT_ID_PATH)):
enabled_clouds.append('Cloudflare')
return enabled_clouds


def set_enabled_clouds(enabled_clouds: List[str]) -> None:
_DB.cursor.execute('INSERT OR REPLACE INTO config VALUES (?, ?)',
(_ENABLED_CLOUDS_KEY, json.dumps(enabled_clouds)))
Expand Down
8 changes: 6 additions & 2 deletions sky/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from sky.skylet import constants
from sky.utils import schemas
from sky.utils import ux_utils
from sky.adaptors import cloudflare

if typing.TYPE_CHECKING:
from sky import resources as resources_lib
Expand Down Expand Up @@ -295,15 +296,18 @@ def from_yaml(yaml_path: str) -> 'Task':

task_storage_mounts: Dict[str, storage_lib.Storage] = {}
all_storages = fm_storages
enabled_clouds = global_user_state.get_enabled_clouds()
enabled_clouds = [str(cloud) for cloud in enabled_clouds]
if cloudflare.r2_is_enabled:
enabled_clouds.append('r2')
for storage in all_storages:
mount_path = storage[0]
assert mount_path, \
'Storage mount path cannot be empty.'
store_type = storage[1]['store']
if store_type:
cloud_type = storage_lib.STORE_TYPE_TO_CLOUD_TYPE[store_type]
enabled_clouds = global_user_state.get_enabled_clouds_str()
if not cloud_type in enabled_clouds:
if cloud_type not in enabled_clouds:
with ux_utils.print_exception_no_traceback():
raise exceptions.CloudDisabledError(
f'Storage \'store:{store_type}\' specified, but '
Expand Down

0 comments on commit 6ee3952

Please sign in to comment.