-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UX: Allow inferring cloud from region or zone. (#2632)
* UX: Allow infering cloud from region or zone. * format * minor fix * Remove Local cloud from registry. * UX for 1-cloud cases * Format * Fix test fixtures. * isort
- Loading branch information
1 parent
734cf68
commit 4f5b107
Showing
9 changed files
with
227 additions
and
116 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import tempfile | ||
from typing import List, Optional | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from sky import clouds | ||
from sky.utils import kubernetes_utils | ||
|
||
|
||
def enable_all_clouds_in_monkeypatch( | ||
monkeypatch: pytest.MonkeyPatch, | ||
enabled_clouds: Optional[List[str]] = None, | ||
) -> None: | ||
# Monkey-patching is required because in the test environment, no cloud is | ||
# enabled. The optimizer checks the environment to find enabled clouds, and | ||
# only generates plans within these clouds. The tests assume that all three | ||
# clouds are enabled, so we monkeypatch the `sky.global_user_state` module | ||
# to return all three clouds. We also monkeypatch `sky.check.check` so that | ||
# when the optimizer tries calling it to update enabled_clouds, it does not | ||
# raise exceptions. | ||
if enabled_clouds is None: | ||
enabled_clouds = list(clouds.CLOUD_REGISTRY.values()) | ||
monkeypatch.setattr( | ||
'sky.global_user_state.get_enabled_clouds', | ||
lambda: enabled_clouds, | ||
) | ||
monkeypatch.setattr('sky.check.check', lambda *_args, **_kwargs: None) | ||
config_file_backup = tempfile.NamedTemporaryFile( | ||
prefix='tmp_backup_config_default', delete=False) | ||
monkeypatch.setattr('sky.clouds.gcp.GCP_CONFIG_SKY_BACKUP_PATH', | ||
config_file_backup.name) | ||
monkeypatch.setattr( | ||
'sky.clouds.gcp.DEFAULT_GCP_APPLICATION_CREDENTIAL_PATH', | ||
config_file_backup.name) | ||
monkeypatch.setenv('OCI_CONFIG', config_file_backup.name) | ||
|
||
az_mappings = pd.read_csv('tests/default_aws_az_mappings.csv') | ||
|
||
def _get_az_mappings(_): | ||
return az_mappings | ||
|
||
monkeypatch.setattr( | ||
'sky.clouds.service_catalog.aws_catalog._get_az_mappings', | ||
_get_az_mappings) | ||
|
||
monkeypatch.setattr('sky.backends.backend_utils.check_owner_identity', | ||
lambda _: None) | ||
|
||
monkeypatch.setattr( | ||
'sky.clouds.gcp.GCP._list_reservations_for_instance_type', | ||
lambda *_args, **_kwargs: []) | ||
|
||
# Monkey patch Kubernetes resource detection since it queries | ||
# the cluster to detect available cluster resources. | ||
monkeypatch.setattr( | ||
'sky.utils.kubernetes_utils.detect_gpu_label_formatter', | ||
lambda *_args, **_kwargs: [kubernetes_utils.SkyPilotLabelFormatter, []]) | ||
monkeypatch.setattr('sky.utils.kubernetes_utils.detect_gpu_resource', | ||
lambda *_args, **_kwargs: [True, []]) | ||
monkeypatch.setattr('sky.utils.kubernetes_utils.check_instance_fits', | ||
lambda *_args, **_kwargs: [True, '']) |
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
Oops, something went wrong.