Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
romilbhardwaj committed Apr 30, 2024
1 parent a6b5bfc commit 1346159
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
20 changes: 10 additions & 10 deletions sky/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2919,10 +2919,8 @@ def _kubernetes_realtime_gpu_output(name_filter: Optional[str] = None,
qty_header = 'QTY_FILTER'
else:
qty_header = 'QTY_PER_NODE'
realtime_gpu_table = log_utils.create_table([
'GPU', qty_header, 'TOTAL_GPUS',
'AVAILABLE_GPUS'
])
realtime_gpu_table = log_utils.create_table(
['GPU', qty_header, 'TOTAL_GPUS', 'AVAILABLE_GPUS'])
counts, capacity, available = service_catalog.list_accelerator_realtime(
gpus_only=True,
clouds=cloud,
Expand All @@ -2941,14 +2939,14 @@ def _kubernetes_realtime_gpu_output(name_filter: Optional[str] = None,
'run: sky show-gpus --cloud kubernetes.')
if quantity_filter is not None:
gpu_info_msg += f' with quantity {quantity_filter}'
err_msg = kubernetes_utils.NO_GPU_ERROR_MESSAGE.format(gpu_info_msg=gpu_info_msg, debug_msg=debug_msg)
err_msg = kubernetes_utils.NO_GPU_ERROR_MESSAGE.format(
gpu_info_msg=gpu_info_msg, debug_msg=debug_msg)
yield err_msg
return
for gpu, _ in sorted(counts.items()):
realtime_gpu_table.add_row([
gpu,
_list_to_str(counts.pop(gpu)), capacity[gpu],
available[gpu]
_list_to_str(counts.pop(gpu)), capacity[gpu], available[gpu]
])
yield from realtime_gpu_table.get_string()

Expand Down Expand Up @@ -3082,15 +3080,17 @@ def _output():
cpu_str = str(int(cpu_count))
else:
cpu_str = f'{cpu_count:.1f}'
device_memory_str = (f'{item.device_memory:.0f}GB' if
not pd.isna(item.device_memory) else '-')
device_memory_str = (f'{item.device_memory:.0f}GB'
if not pd.isna(item.device_memory) else
'-')
host_memory_str = f'{item.memory:.0f}GB' if not pd.isna(
item.memory) else '-'
price_str = f'$ {item.price:.3f}' if not pd.isna(
item.price) else '-'
spot_price_str = f'$ {item.spot_price:.3f}' if not pd.isna(
item.spot_price) else '-'
region_str = item.region if not pd.isna(item.region) else '-'
region_str = item.region if not pd.isna(
item.region) else '-'
accelerator_table_vals = [
item.accelerator_name,
item.accelerator_count,
Expand Down
17 changes: 8 additions & 9 deletions sky/clouds/service_catalog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,14 @@ def list_accelerator_realtime(
- Number of accelerators available at the time of call (availability).
"""
qtys_map, total_accelerators_capacity, total_accelerators_available = (
_map_clouds_catalog(
clouds,
'list_accelerators_realtime',
gpus_only,
name_filter,
region_filter,
quantity_filter,
all_regions=False,
require_price=False))
_map_clouds_catalog(clouds,
'list_accelerators_realtime',
gpus_only,
name_filter,
region_filter,
quantity_filter,
all_regions=False,
require_price=False))
accelerator_counts: Dict[str, List[int]] = collections.defaultdict(list)
for gpu, items in qtys_map.items():
for item in items:
Expand Down
4 changes: 2 additions & 2 deletions sky/clouds/service_catalog/kubernetes_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def list_accelerators_realtime(

if accelerator_count >= min_quantity_filter:
quantized_count = (min_quantity_filter *
(accelerator_count//min_quantity_filter))
(accelerator_count // min_quantity_filter))
if accelerator_name not in total_accelerators_capacity:
total_accelerators_capacity[
accelerator_name] = quantized_count
Expand All @@ -133,7 +133,7 @@ def list_accelerators_realtime(

if accelerators_available >= min_quantity_filter:
quantized_availability = min_quantity_filter * (
accelerators_available // min_quantity_filter)
accelerators_available // min_quantity_filter)
if accelerator_name not in total_accelerators_available:
total_accelerators_available[
accelerator_name] = quantized_availability
Expand Down

0 comments on commit 1346159

Please sign in to comment.