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

Check that environment exists when setting in config #2578

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modal/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from rich.console import Console

from modal.config import _profile, _store_user_config, config
from modal.environments import Environment

config_cli = typer.Typer(
name="config",
Expand Down Expand Up @@ -38,6 +39,8 @@ def show(redact: bool = typer.Option(True, help="Redact the `token_secret` value

@config_cli.command(help=SET_DEFAULT_ENV_HELP)
def set_environment(environment_name: str):
# Confirm that the environment exists by looking it up
Environment.lookup(environment_name)
_store_user_config({"environment": environment_name})
typer.echo(f"New default environment for profile {_profile}: {environment_name}")

Expand Down
2 changes: 1 addition & 1 deletion modal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def __repr__(self):
return repr(self.to_dict())

def to_dict(self):
return {key: self.get(key) for key in _SETTINGS.keys()}
return {key: self.get(key) for key in sorted(_SETTINGS)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not directly related but when confirming that we can still set a valid environment I noticed that the modal config show output was hard to read because it was unordered.



config = Config()
Expand Down
Loading