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

[Core] Relax cluster name restriction and process cloud cluster name #3130

Merged

Conversation

dtran24
Copy link
Contributor

@dtran24 dtran24 commented Feb 9, 2024

Fixes #2709

Tested (run the relevant ones):

  • Code formatting: bash format.sh
  • Any manual or new tests for this PR (please specify below)
    • pytest tests/unit_tests/test_cloud.py::TestCheckClusterNameIsValid
    • pytest tests/unit_tests/test_common_utils.py
    • sky launch -c mycluster@ hello_sky.yaml --cloud aws. Raised exception, as expected
    • sky launch -c mycluster hello_sky.yaml --cloud aws
    • sky launch -c Cuda_11.8 hello_sky.yaml --cloud aws. Processed cluster name, as expected. sky status displays the original cluster name
    • sky launch -c mycluster@ hello_sky.yaml --cloud aws --use-spot. Raised exception, as expected
    • sky launch -c mycluster hello_sky.yaml --cloud aws --use-spot
    • sky launch -c Cuda_11.8 hello_sky.yaml --cloud aws --use-spot. Processed cluster name, as expected. sky status displays the original cluster name
    • backward compatibility test (link to comment for more details)
  • 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

@dtran24 dtran24 changed the title [Core] Relax cluster name restriction and transform cloud cluster name [Core] Relax cluster name restriction and process cloud cluster name Feb 9, 2024
@dtran24 dtran24 marked this pull request as ready for review February 9, 2024 05:08
@dtran24
Copy link
Contributor Author

dtran24 commented Feb 9, 2024

Requesting review @Michaelvll

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 the fix @dtran24! Looks pretty good to me! Left some comments mostly for code style : )

sky/utils/common_utils.py Outdated Show resolved Hide resolved
sky/utils/common_utils.py Show resolved Hide resolved
sky/utils/common_utils.py Outdated Show resolved Hide resolved
sky/utils/common_utils.py Outdated Show resolved Hide resolved
sky/utils/common_utils.py Outdated Show resolved Hide resolved
sky/utils/common_utils.py Outdated Show resolved Hide resolved
@dtran24
Copy link
Contributor Author

dtran24 commented Feb 9, 2024

Appreciate the review @Michaelvll! Is helpful for me as I learn more about the codebase's patterns

Also, whenever this PR does get approved, feel free to merge it since I don't have permissions to merge myself

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 the quick update @dtran24! We should test a bit of the backward compatibility before merging, i.e., we need to make sure the cluster_name_on_cloud does not change for existing clusters after making the change for this function.

sky/exceptions.py Outdated Show resolved Hide resolved
tests/unit_tests/test_cloud.py Outdated Show resolved Hide resolved
sky/utils/common_utils.py Outdated Show resolved Hide resolved
@dtran24
Copy link
Contributor Author

dtran24 commented Feb 9, 2024

Did a quick check on backward compatibility

  1. From master branch, run sky launch -c mycluster hello_sky.yaml --cloud aws
  2. Switched to feature branch (i.e. core/relax-cluster-name-constraint), and ran sky down mycluster

Let me know if something like this is what you had in mind @Michaelvll

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 the quick fix @dtran24! Some final comments:

We should update the docstr in the following function, by saying that dot and underscores are allowed, as we will handle it when mapping to the cluster_name_on_cloud in common_utils.make_cluster_name_on_cloud

def get_cleaned_username(username: str = '') -> str:
"""Cleans the username as some cloud provider have limitation on
characters usage such as dot (.) is not allowed in GCP.
Clean up includes:
1. Making all characters lowercase
2. Removing any non-alphanumeric characters (excluding hyphens)
3. Removing any numbers and/or hyphens at the start of the username.
4. Removing any hyphens at the end of the username
e.g. 1SkY-PiLot2- becomes sky-pilot2
Returns:
A cleaned username.
"""
username = username or getpass.getuser()
username = username.lower()
username = re.sub(r'[^a-z0-9-]', '', username)
username = re.sub(r'^[0-9-]+', '', username)
username = re.sub(r'-$', '', username)
return username

sky/utils/common_utils.py Outdated Show resolved Hide resolved
sky/utils/common_utils.py Outdated Show resolved Hide resolved
sky/utils/common_utils.py Outdated Show resolved Hide resolved
sky/utils/common_utils.py Outdated Show resolved Hide resolved
@dtran24
Copy link
Contributor Author

dtran24 commented Feb 9, 2024

PTAL @Michaelvll, appreciate the time and effort for reviewing this multiple times!

As per the comment for updating docstr for get_cleaned_username, I also updated the regex to also include dots and underscores.

username = re.sub(r'[^a-z0-9-._]', '', username)

Otherwise, the docstr update didn't seem to make sense to me

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.

Thank you for the update @dtran24! LGTM. Merging the PR now.

@Michaelvll Michaelvll merged commit 9a77adf into skypilot-org:master Feb 12, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS cluster name restrictions should've been relaxed
2 participants