Skip to content
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
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Code owners for this repository.
# These owners are the default for everything in the repo and are
# automatically requested for review on every pull request.
# See https://docs.github.com/articles/about-code-owners

* @CentML/platform-team
1 change: 1 addition & 0 deletions centml/cli/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def login(token_file):
click.echo("✅ Login successful")
else:
click.echo("Logging into CCluster...")
click.echo(f"By continuing, you agree to the Terms of Service: {settings.CENTML_TERMS_OF_SERVICE_URL}\n")

choice = click.confirm("Do you want to log in with your browser now?", default=True)
if choice:
Expand Down
3 changes: 2 additions & 1 deletion centml/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from centml.cli.login import login, logout
from centml.cli.cluster import ls, get, delete, pause, resume, capacity
from centml.cli.shell import shell, exec_cmd
from centml.sdk.config import settings

# NVIDIA green (#76B900)
_NVIDIA_GREEN = (118, 185, 0)
Expand All @@ -21,7 +22,7 @@
✨ AI Deployment Made Simple ✨
📚 Documentation: https://docs.nvidia.com/ccluster
💬 Need help? Reach out on GitHub: https://github.com/NVIDIA/ccluster
"""
📄 Terms of Service: """ + settings.CENTML_TERMS_OF_SERVICE_URL + "\n"


@click.group()
Expand Down
3 changes: 3 additions & 0 deletions centml/sdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class Config(BaseSettings):
model_config = SettingsConfigDict(env_file=Path(".env"), extra="ignore")

CENTML_WEB_URL: str = os.getenv("CENTML_WEB_URL", default="https://app.centml.com/")
CENTML_TERMS_OF_SERVICE_URL: str = os.getenv(
"CENTML_TERMS_OF_SERVICE_URL", default="https://app.centml.com/terms-of-service/"
)
CENTML_CONFIG_PATH: str = os.getenv("CENTML_CONFIG_PATH", default=os.path.expanduser("~/.centml"))
CENTML_CRED_FILE: str = os.getenv("CENTML_CRED_FILE", default="credentials.json")
CENTML_CRED_FILE_PATH: str = os.path.join(CENTML_CONFIG_PATH, CENTML_CRED_FILE)
Expand Down
30 changes: 30 additions & 0 deletions tests/test_cli_terms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from unittest.mock import patch

from click.testing import CliRunner

from centml.cli.main import cli
from centml.sdk.config import settings

TOS_URL = settings.CENTML_TERMS_OF_SERVICE_URL


def test_version_shows_terms_url():
result = CliRunner().invoke(cli, ["--version"])
assert result.exit_code == 0
assert TOS_URL in result.output


def test_login_shows_terms_url_when_not_authenticated():
with patch("centml.cli.login.auth.load_centml_cred", return_value=None):
result = CliRunner().invoke(cli, ["login"], input="n\n")
assert TOS_URL in result.output
assert "Terms of Service" in result.output


def test_login_with_stored_credentials_skips_terms_notice():
with patch("centml.cli.login.auth.load_centml_cred", return_value={"refresh_token": "x"}), patch(
"centml.cli.login.auth.refresh_centml_token", return_value=True
):
result = CliRunner().invoke(cli, ["login"])
assert "Login successful" in result.output
assert TOS_URL not in result.output
Loading