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

[Storage] Truncate long command str in sky storage ls #2177

Merged
merged 4 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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: 3 additions & 1 deletion sky/data/storage_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from sky import sky_logging
from sky.utils import log_utils
from sky.utils.cli_utils import status_utils

logger = sky_logging.init_logger(__name__)

Expand Down Expand Up @@ -34,7 +35,8 @@ def format_storage_table(storages: List[Dict[str, Any]]) -> str:
# CLOUDS
', '.join([s.value for s in row['store']]),
# COMMAND
row['last_use'],
status_utils.truncate_long_string(
row['last_use'], status_utils.COMMAND_TRUNC_LENGTH),
# STATUS
row['status'].value,
])
Expand Down
10 changes: 5 additions & 5 deletions sky/utils/cli_utils/status_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sky.utils import common_utils
from sky.utils import log_utils

_COMMAND_TRUNC_LENGTH = 25
COMMAND_TRUNC_LENGTH = 25
NUM_COST_REPORT_LINES = 5

# A record in global_user_state's 'clusters' table.
Expand All @@ -21,7 +21,7 @@
_ClusterCostReportRecord = Dict[str, Any]


def _truncate_long_string(s: str, max_length: int = 35) -> str:
def truncate_long_string(s: str, max_length: int = 35) -> str:
if len(s) <= max_length:
return s
splits = s.split(' ')
Expand Down Expand Up @@ -56,7 +56,7 @@ def __init__(self,
def calc(self, record):
val = self.calc_func(record)
if self.trunc_length != 0:
val = _truncate_long_string(str(val), self.trunc_length)
val = truncate_long_string(str(val), self.trunc_length)
return val


Expand All @@ -82,7 +82,7 @@ def show_status_table(cluster_records: List[_ClusterRecord],
StatusColumn('AUTOSTOP', _get_autostop),
StatusColumn('COMMAND',
_get_command,
trunc_length=_COMMAND_TRUNC_LENGTH if not show_all else 0),
trunc_length=COMMAND_TRUNC_LENGTH if not show_all else 0),
]

columns = []
Expand Down Expand Up @@ -268,7 +268,7 @@ def show_local_status_table(local_clusters: List[str]):
# RESOURCES
resources_str,
# COMMAND
_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