Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UX: Allow inferring cloud from region or zone. #2632

Merged
merged 9 commits into from
Oct 4, 2023
Merged

Conversation

concretevitamin
Copy link
Member

@concretevitamin concretevitamin commented Oct 1, 2023

Fixes #1882. Also, unregisters Local cloud, which is done to provide good 1-cloud hints.

Tested (added to unit tests too) with all clouds enabled incl. k8s:

OK cases:

# Maps to GCP.
» sky launch --region us-east1
» sky launch --zone us-west2-a

# Maps to AWS.
» sky launch --region us-east-2
» sky launch --zone us-west-2a

# OK: Optimizer prints.
» sky launch
» sky launch --region us-east-1 --cloud aws
» sky launch --region us-east-1 --cloud lambda

Not OK cases:

» sky launch --region us-east-1
ValueError: Cannot infer cloud from (region 'us-east-1', zone None). Multiple enabled clouds have region/zone of the same names: [AWS, Lambda]. To fix: explicitly specify `cloud`.

» sky launch --zone us-west-2-a --cloud aws
ValueError: Invalid zone 'us-west-2-a'
Did you mean one of these: 'us-west-2a'?

» sky launch --zone us-west-2-a                                            
ValueError: Invalid (region None, zone 'us-west-2-a') for any cloud among [AWS, Azure, GCP, IBM, Kubernetes, Lambda, OCI, SCP]. Details:
Cloud       Hint
-----       ----
AWS         Invalid zone 'us-west-2-a' Did you mean one of these: 'us-west-2a'?
Azure       Azure does not support zones.
GCP         Invalid zone 'us-west-2-a' Did you mean one of these: 'us-west2-a'?
IBM         Invalid zone 'us-west-2-a'
Kubernetes  Kubernetes support does not support setting region. Cluster used is determined
            by the kubeconfig.
Lambda      Lambda Cloud does not support zones.
OCI         Invalid zone 'us-west-2-a'
SCP         SCP Cloud does not support zones.

» sky launch --zone us-west-2z
ValueError: Invalid (region None, zone 'us-west-2z') for any cloud among [AWS, Azure, GCP, IBM, Kubernetes, Lambda, OCI, SCP]. Details:
Cloud       Hint
-----       ----
AWS         Invalid zone 'us-west-2z' Did you mean one of these: 'us-west-2a, us-west-2b,
            us-west-2c, us-west-2d'?
Azure       Azure does not support zones.
GCP         Invalid zone 'us-west-2z'
IBM         Invalid zone 'us-west-2z'
Kubernetes  Kubernetes support does not support setting region. Cluster used is determined
            by the kubeconfig.
Lambda      Lambda Cloud does not support zones.
Local       Local cloud does not support zones.
OCI         Invalid zone 'us-west-2z'
SCP         SCP Cloud does not support zones.


» sky launch --region us-east1 --zone us-west2-a                         
ValueError: Invalid (region 'us-east1', zone 'us-west2-a') for any cloud among [AWS, Azure, GCP, IBM, Kubernetes, Lambda, OCI, SCP]. Details:
Cloud       Hint
-----       ----
AWS         Invalid region 'us-east1' Did you mean one of these: 'us-east-1'?
Azure       Azure does not support zones.
GCP         Invalid zone 'us-west2-a' for region 'us-east1'
IBM         Invalid region 'us-east1' Did you mean one of these: 'us-east'?
Kubernetes  Kubernetes support does not support setting region. Cluster used is determined
            by the kubeconfig.
Lambda      Lambda Cloud does not support zones.
OCI         Invalid region 'us-east1' List of supported oci regions: 'us-sanjose-1'
SCP         SCP Cloud does not support zones.

In docker, with AWS enabled only:

  • TODO: improve on this output, 1-cloud only situations should not need the verbose table
# OK
» sky launch --region us-east-1

» sky launch --zone us-west-2-a
ValueError: Invalid (region None, zone 'us-west-2-a') for cloud AWS. Details:
Invalid zone 'us-west-2-a'
Did you mean one of these: 'us-west-2a'?

» sky launch --region us-east1 --zone us-west2-a
ValueError: Invalid (region 'us-east1', zone 'us-west2-a') for cloud AWS. Details:
Invalid region 'us-east1'
Did you mean one of these: 'us-east-1'?

Tested (run the relevant ones):

  • Code formatting: bash format.sh
  • Any manual or new tests for this PR (please specify below)
  • All smoke tests: pytest tests/test_smoke.py
  • Relevant individual smoke tests: pytest tests/test_smoke.py::test_fill_in_the_name
  • Backward compatibility tests: bash tests/backward_comaptibility_tests.sh

@concretevitamin concretevitamin changed the title UX: Allow infering cloud from region or zone. UX: Allow inferring cloud from region or zone. Oct 1, 2023
Copy link
Collaborator

@Michaelvll Michaelvll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this functionality @concretevitamin! LGTM.

@@ -691,3 +691,64 @@ def test_optimize_speed(enable_all_clouds, monkeypatch):
sky.Resources(cpus='4+', memory='4+', accelerators='A100-80GB:8'))
_test_optimize_speed(
sky.Resources(cpus='4+', memory='4+', accelerators='tpu-v3-32'))


def test_infer_cloud_from_region_or_zone(monkeypatch):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@concretevitamin
Copy link
Member Author

PTAL @Michaelvll, main changes since last review are: better 1-cloud hints, and test fixtures refactoring.

Copy link
Collaborator

@Michaelvll Michaelvll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for the refactoring of the tests @concretevitamin! LGTM.

@concretevitamin concretevitamin merged commit 4f5b107 into master Oct 4, 2023
18 checks passed
@concretevitamin concretevitamin deleted the infer-cloud branch October 4, 2023 22:34
jc9123 pushed a commit to jc9123/skypilot that referenced this pull request Oct 11, 2023
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants