Skip to content

[Ready for review] Use default CPU resources when GPU type is None #1722

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions truss/cli/train/deploy_checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ def _get_compute(compute: Optional[Compute]) -> Compute:
if not compute:
compute = Compute(cpu_count=0, memory="0Mi")
compute.accelerator = _get_accelerator_if_specified(compute.accelerator)
# User did not specify an accelerator, so we default to CPU.
if not compute.accelerator:
Copy link
Contributor

Choose a reason for hiding this comment

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

is this going to overwrite the compute provided by the customer?

compute.cpu_count = int(truss_config.DEFAULT_CPU)
compute.memory = truss_config.DEFAULT_MEMORY
return compute


Expand Down
29 changes: 29 additions & 0 deletions truss/tests/cli/train/test_deploy_checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ def deploy_checkpoints_mock_select(create_mock_prompt):
yield mock


@pytest.fixture
def deploy_checkpoints_mock_select_cpu(create_mock_prompt):
with patch("truss.cli.train.deploy_checkpoints.inquirer.select") as mock:
mock.side_effect = lambda message, **kwargs: create_mock_prompt(None)
yield mock


@pytest.fixture
def deploy_checkpoints_mock_text(create_mock_prompt):
with patch("truss.cli.train.deploy_checkpoints.inquirer.text") as mock:
Expand Down Expand Up @@ -164,6 +171,28 @@ def test_prepare_checkpoint_deploy_empty_config(
)


def test_prepare_checkpoint_deploy_empty_config_cpu(
mock_remote,
deploy_checkpoints_mock_select_cpu,
deploy_checkpoints_mock_text,
deploy_checkpoints_mock_checkbox,
):
# Create empty config
empty_config = definitions.DeployCheckpointsConfig()
result = prepare_checkpoint_deploy(
remote_provider=mock_remote,
checkpoint_deploy_config=empty_config,
project_id="project123",
job_id="job123",
)
assert isinstance(result, PrepareCheckpointResult)
assert result.checkpoint_deploy_config.compute.cpu_count == int(
truss_config.DEFAULT_CPU
)
assert result.checkpoint_deploy_config.compute.memory == truss_config.DEFAULT_MEMORY
assert result.checkpoint_deploy_config.compute.accelerator is None


def test_prepare_checkpoint_deploy_complete_config(
mock_remote,
deploy_checkpoints_mock_select,
Expand Down
Loading