Skip to content

Commit

Permalink
[UX/Doc] Add disk size in resource display and a minor fix for the doc (
Browse files Browse the repository at this point in the history
#1371)

Minor fix for docs and ux
  • Loading branch information
Michaelvll authored Nov 4, 2022
1 parent b00a359 commit 75ab3de
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
1 change: 1 addition & 0 deletions docs/source/reference/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ By default, SkyPilot only supports the US regions on different clouds for conven

.. code-block:: bash
mkdir -p ~/.sky/catalogs/v4
cd ~/.sky/catalogs/v4
# Fetch all regions for AWS
python -m sky.clouds.service_catalog.data_fetchers.fetch_aws --all-regions
Expand Down
6 changes: 5 additions & 1 deletion sky/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ def __repr__(self) -> str:
if self.image_id is not None:
image_id = f', image_id={self.image_id!r}'

disk_size = ''
if self.disk_size != _DEFAULT_DISK_SIZE_GB:
disk_size = f', disk_size={self.disk_size}'

return (f'{self.cloud}({self._instance_type}{use_spot}'
f'{accelerators}{accelerator_args}{image_id})')
f'{accelerators}{accelerator_args}{image_id}{disk_size})')

@property
def cloud(self):
Expand Down
20 changes: 0 additions & 20 deletions sky/utils/cli_utils/cli_utils.py

This file was deleted.

24 changes: 21 additions & 3 deletions sky/utils/cli_utils/status_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,30 @@
from sky import spot
from sky.backends import backend_utils
from sky.utils import common_utils
from sky.utils.cli_utils import cli_utils
from sky.utils import log_utils

_COMMAND_TRUNC_LENGTH = 25


def _truncate_long_string(s: str, max_length: int = 35) -> str:
if len(s) <= max_length:
return s
splits = s.split(' ')
if len(splits[0]) > max_length:
return splits[0][:max_length] + '...' # Use '…'?
# Truncate on word boundary.
i = 0
total = 0
for i, part in enumerate(splits):
total += len(part)
if total >= max_length:
break
prefix = ' '.join(splits[:i])
if len(prefix) < max_length:
prefix += s[len(prefix):max_length]
return prefix + '...'


class StatusColumn:
"""One column of the displayed cluster table"""

Expand All @@ -29,7 +47,7 @@ def __init__(self,
def calc(self, record):
val = self.calc_func(record)
if self.trunc_length != 0:
val = cli_utils.truncate_long_string(str(val), self.trunc_length)
val = _truncate_long_string(str(val), self.trunc_length)
return val


Expand Down Expand Up @@ -160,7 +178,7 @@ def show_local_status_table(local_clusters: List[str]):
# RESOURCES
resources_str,
# COMMAND
cli_utils.truncate_long_string(command_str, _COMMAND_TRUNC_LENGTH),
_truncate_long_string(command_str, _COMMAND_TRUNC_LENGTH),
]
names.append(cluster_name)
cluster_table.add_row(row)
Expand Down

0 comments on commit 75ab3de

Please sign in to comment.