skypilot-nightly 1.0.0.dev20250522__py3-none-any.whl → 1.0.0.dev20250523__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. sky/__init__.py +2 -2
  2. sky/adaptors/kubernetes.py +46 -16
  3. sky/backends/cloud_vm_ray_backend.py +16 -4
  4. sky/check.py +109 -44
  5. sky/cli.py +261 -90
  6. sky/client/cli.py +261 -90
  7. sky/client/sdk.py +50 -2
  8. sky/clouds/__init__.py +3 -0
  9. sky/clouds/aws.py +4 -2
  10. sky/clouds/azure.py +4 -2
  11. sky/clouds/cloud.py +24 -6
  12. sky/clouds/cudo.py +2 -1
  13. sky/clouds/do.py +2 -1
  14. sky/clouds/fluidstack.py +2 -1
  15. sky/clouds/gcp.py +4 -2
  16. sky/clouds/ibm.py +4 -2
  17. sky/clouds/kubernetes.py +66 -22
  18. sky/clouds/lambda_cloud.py +2 -1
  19. sky/clouds/nebius.py +18 -2
  20. sky/clouds/oci.py +4 -2
  21. sky/clouds/paperspace.py +2 -1
  22. sky/clouds/runpod.py +2 -1
  23. sky/clouds/scp.py +2 -1
  24. sky/clouds/service_catalog/constants.py +1 -1
  25. sky/clouds/service_catalog/ssh_catalog.py +167 -0
  26. sky/clouds/ssh.py +203 -0
  27. sky/clouds/vast.py +2 -1
  28. sky/clouds/vsphere.py +2 -1
  29. sky/core.py +53 -9
  30. sky/dashboard/out/404.html +1 -1
  31. sky/dashboard/out/_next/static/{CzOVV6JpRQBRt5GhZuhyK → ECKwDNS9v9y3_IKFZ2lpp}/_buildManifest.js +1 -1
  32. sky/dashboard/out/_next/static/chunks/pages/infra-abf08c4384190a39.js +1 -0
  33. sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
  34. sky/dashboard/out/clusters/[cluster].html +1 -1
  35. sky/dashboard/out/clusters.html +1 -1
  36. sky/dashboard/out/index.html +1 -1
  37. sky/dashboard/out/infra.html +1 -1
  38. sky/dashboard/out/jobs/[job].html +1 -1
  39. sky/dashboard/out/jobs.html +1 -1
  40. sky/optimizer.py +23 -4
  41. sky/provision/__init__.py +1 -0
  42. sky/provision/aws/instance.py +17 -1
  43. sky/provision/kubernetes/instance.py +16 -5
  44. sky/provision/kubernetes/utils.py +37 -19
  45. sky/provision/nebius/instance.py +3 -1
  46. sky/provision/nebius/utils.py +14 -2
  47. sky/provision/ssh/__init__.py +18 -0
  48. sky/resources.py +4 -1
  49. sky/server/requests/payloads.py +7 -0
  50. sky/server/server.py +40 -0
  51. sky/setup_files/dependencies.py +1 -0
  52. sky/templates/nebius-ray.yml.j2 +12 -0
  53. sky/utils/infra_utils.py +21 -1
  54. sky/utils/kubernetes/cleanup-tunnel.sh +62 -0
  55. sky/utils/kubernetes/create_cluster.sh +1 -0
  56. sky/utils/kubernetes/deploy_remote_cluster.py +1437 -0
  57. sky/utils/kubernetes/kubernetes_deploy_utils.py +117 -10
  58. sky/utils/kubernetes/ssh-tunnel.sh +387 -0
  59. sky/utils/log_utils.py +214 -1
  60. sky/utils/schemas.py +21 -0
  61. sky/utils/ux_utils.py +2 -1
  62. {skypilot_nightly-1.0.0.dev20250522.dist-info → skypilot_nightly-1.0.0.dev20250523.dist-info}/METADATA +6 -1
  63. {skypilot_nightly-1.0.0.dev20250522.dist-info → skypilot_nightly-1.0.0.dev20250523.dist-info}/RECORD +68 -63
  64. sky/dashboard/out/_next/static/chunks/pages/infra-9180cd91cee64b96.js +0 -1
  65. sky/utils/kubernetes/deploy_remote_cluster.sh +0 -308
  66. /sky/dashboard/out/_next/static/{CzOVV6JpRQBRt5GhZuhyK → ECKwDNS9v9y3_IKFZ2lpp}/_ssgManifest.js +0 -0
  67. {skypilot_nightly-1.0.0.dev20250522.dist-info → skypilot_nightly-1.0.0.dev20250523.dist-info}/WHEEL +0 -0
  68. {skypilot_nightly-1.0.0.dev20250522.dist-info → skypilot_nightly-1.0.0.dev20250523.dist-info}/entry_points.txt +0 -0
  69. {skypilot_nightly-1.0.0.dev20250522.dist-info → skypilot_nightly-1.0.0.dev20250523.dist-info}/licenses/LICENSE +0 -0
  70. {skypilot_nightly-1.0.0.dev20250522.dist-info → skypilot_nightly-1.0.0.dev20250523.dist-info}/top_level.txt +0 -0
sky/clouds/cloud.py CHANGED
@@ -457,12 +457,14 @@ class Cloud:
457
457
 
458
458
  @classmethod
459
459
  def check_credentials(
460
- cls,
461
- cloud_capability: CloudCapability) -> Tuple[bool, Optional[str]]:
460
+ cls, cloud_capability: CloudCapability
461
+ ) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
462
462
  """Checks if the user has access credentials to this cloud.
463
463
 
464
- Returns a boolean of whether the user can access this cloud, and a
465
- string describing the reason if the user cannot access.
464
+ Returns a boolean of whether the user can access this cloud, and:
465
+ - For SSH and Kubernetes, a dictionary that maps context names to
466
+ the status of the context.
467
+ - For others, a string describing the reason if cannot access.
466
468
 
467
469
  Raises NotSupportedError if the capability is
468
470
  not supported by this cloud.
@@ -474,19 +476,30 @@ class Cloud:
474
476
  assert_never(cloud_capability)
475
477
 
476
478
  @classmethod
477
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
479
+ def _check_compute_credentials(
480
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
478
481
  """Checks if the user has access credentials to
479
482
  this cloud's compute service."""
480
483
  raise exceptions.NotSupportedError(
481
484
  f'{cls._REPR} does not support {CloudCapability.COMPUTE.value}.')
482
485
 
483
486
  @classmethod
484
- def _check_storage_credentials(cls) -> Tuple[bool, Optional[str]]:
487
+ def _check_storage_credentials(
488
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
485
489
  """Checks if the user has access credentials to
486
490
  this cloud's storage service."""
487
491
  raise exceptions.NotSupportedError(
488
492
  f'{cls._REPR} does not support {CloudCapability.STORAGE.value}.')
489
493
 
494
+ @classmethod
495
+ def get_infras(cls) -> List[str]:
496
+ """Returns a list of enabled infrastructures for this cloud.
497
+
498
+ For Kubernetes and SSH, return a list of resource pools.
499
+ For all other clouds, return self.
500
+ """
501
+ return [cls._REPR.lower()]
502
+
490
503
  # TODO(zhwu): Make the return type immutable.
491
504
  @classmethod
492
505
  def get_user_identities(cls) -> Optional[List[List[str]]]:
@@ -878,6 +891,11 @@ class Cloud:
878
891
  def canonical_name(cls) -> str:
879
892
  return cls.__name__.lower()
880
893
 
894
+ @classmethod
895
+ def display_name(cls) -> str:
896
+ """Name of the cloud used in messages displayed to the user."""
897
+ return cls.canonical_name()
898
+
881
899
  def __repr__(self):
882
900
  return self._REPR
883
901
 
sky/clouds/cudo.py CHANGED
@@ -270,7 +270,8 @@ class Cudo(clouds.Cloud):
270
270
  fuzzy_candidate_list, None)
271
271
 
272
272
  @classmethod
273
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
273
+ def _check_compute_credentials(
274
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
274
275
  """Checks if the user has access credentials to
275
276
  Cudo's compute service."""
276
277
  try:
sky/clouds/do.py CHANGED
@@ -264,7 +264,8 @@ class DO(clouds.Cloud):
264
264
  fuzzy_candidate_list, None)
265
265
 
266
266
  @classmethod
267
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
267
+ def _check_compute_credentials(
268
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
268
269
  """Verify that the user has valid credentials for
269
270
  DO's compute service."""
270
271
 
sky/clouds/fluidstack.py CHANGED
@@ -261,7 +261,8 @@ class Fluidstack(clouds.Cloud):
261
261
  fuzzy_candidate_list, None)
262
262
 
263
263
  @classmethod
264
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
264
+ def _check_compute_credentials(
265
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
265
266
  """Checks if the user has access credentials to
266
267
  FluidStack's compute service."""
267
268
  try:
sky/clouds/gcp.py CHANGED
@@ -791,7 +791,8 @@ class GCP(clouds.Cloud):
791
791
  return DEFAULT_GCP_APPLICATION_CREDENTIAL_PATH
792
792
 
793
793
  @classmethod
794
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
794
+ def _check_compute_credentials(
795
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
795
796
  """Checks if the user has access credentials to this cloud's compute service."""
796
797
  return cls._check_credentials(
797
798
  [
@@ -803,7 +804,8 @@ class GCP(clouds.Cloud):
803
804
  gcp_utils.get_minimal_compute_permissions())
804
805
 
805
806
  @classmethod
806
- def _check_storage_credentials(cls) -> Tuple[bool, Optional[str]]:
807
+ def _check_storage_credentials(
808
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
807
809
  """Checks if the user has access credentials to this cloud's storage service."""
808
810
  return cls._check_credentials(
809
811
  [('storage', 'Cloud Storage')],
sky/clouds/ibm.py CHANGED
@@ -399,13 +399,15 @@ class IBM(clouds.Cloud):
399
399
  return image_size
400
400
 
401
401
  @classmethod
402
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
402
+ def _check_compute_credentials(
403
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
403
404
  """Checks if the user has access credentials to
404
405
  IBM's compute service."""
405
406
  return cls._check_credentials()
406
407
 
407
408
  @classmethod
408
- def _check_storage_credentials(cls) -> Tuple[bool, Optional[str]]:
409
+ def _check_storage_credentials(
410
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
409
411
  """Checks if the user has access credentials to
410
412
  IBM's storage service."""
411
413
  # TODO(seungjin): Implement separate check for
sky/clouds/kubernetes.py CHANGED
@@ -4,6 +4,8 @@ import re
4
4
  import typing
5
5
  from typing import Dict, Iterator, List, Optional, Set, Tuple, Union
6
6
 
7
+ import colorama
8
+
7
9
  from sky import clouds
8
10
  from sky import exceptions
9
11
  from sky import sky_logging
@@ -149,7 +151,7 @@ class Kubernetes(clouds.Cloud):
149
151
  'Ignoring these contexts.')
150
152
 
151
153
  @classmethod
152
- def existing_allowed_contexts(cls) -> List[str]:
154
+ def existing_allowed_contexts(cls, silent: bool = False) -> List[str]:
153
155
  """Get existing allowed contexts.
154
156
 
155
157
  If None is returned in the list, it means that we are running in a pod
@@ -162,6 +164,12 @@ class Kubernetes(clouds.Cloud):
162
164
 
163
165
  all_contexts = set(all_contexts)
164
166
 
167
+ # Exclude contexts starting with `ssh-`
168
+ # TODO(romilb): Remove when SSH Node Pools use a separate kubeconfig.
169
+ all_contexts = [
170
+ ctx for ctx in all_contexts if not ctx.startswith('ssh-')
171
+ ]
172
+
165
173
  allowed_contexts = skypilot_config.get_nested(
166
174
  ('kubernetes', 'allowed_contexts'), None)
167
175
 
@@ -183,8 +191,12 @@ class Kubernetes(clouds.Cloud):
183
191
  if context in all_contexts:
184
192
  existing_contexts.append(context)
185
193
  else:
194
+ # Skip SSH Node Pool contexts
195
+ if context.startswith('ssh-'):
196
+ continue
186
197
  skipped_contexts.append(context)
187
- cls._log_skipped_contexts_once(tuple(skipped_contexts))
198
+ if not silent:
199
+ cls._log_skipped_contexts_once(tuple(skipped_contexts))
188
200
  return existing_contexts
189
201
 
190
202
  @classmethod
@@ -640,7 +652,7 @@ class Kubernetes(clouds.Cloud):
640
652
  resource_list = []
641
653
  for instance_type in instance_list:
642
654
  r = resources.copy(
643
- cloud=Kubernetes(),
655
+ cloud=self.__class__(),
644
656
  instance_type=instance_type,
645
657
  accelerators=None,
646
658
  )
@@ -692,7 +704,43 @@ class Kubernetes(clouds.Cloud):
692
704
  [], None)
693
705
 
694
706
  @classmethod
695
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
707
+ def _check_single_context(cls, context: str) -> Tuple[bool, str]:
708
+ """Check if the user has access credentials to a single SSH context."""
709
+
710
+ def _red_color(str_to_format: str) -> str:
711
+ return (f'{colorama.Fore.LIGHTRED_EX}'
712
+ f'{str_to_format}'
713
+ f'{colorama.Style.RESET_ALL}')
714
+
715
+ def _dim_color(str_to_format: str) -> str:
716
+ return (f'{colorama.Style.DIM}'
717
+ f'{str_to_format}'
718
+ f'{colorama.Style.RESET_ALL}')
719
+
720
+ def _bright_green_color(str_to_format: str) -> str:
721
+ return (f'{colorama.Fore.GREEN}'
722
+ f'{str_to_format}'
723
+ f'{colorama.Style.RESET_ALL}')
724
+
725
+ try:
726
+ check_result = kubernetes_utils.check_credentials(
727
+ context, run_optional_checks=True)
728
+ if check_result[0]:
729
+ if check_result[1] is not None:
730
+ return True, (_bright_green_color('enabled.') +
731
+ _dim_color(f' Note: {check_result[1]}'))
732
+ else:
733
+ return True, _bright_green_color('enabled.')
734
+ else:
735
+ assert check_result[1] is not None
736
+ return False, (_red_color('disabled.') +
737
+ _dim_color(f' Reason: {check_result[1]}'))
738
+ except Exception as e: # pylint: disable=broad-except
739
+ return False, _red_color(str(e))
740
+
741
+ @classmethod
742
+ def _check_compute_credentials(
743
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
696
744
  """Checks if the user has access credentials to
697
745
  Kubernetes."""
698
746
  # Check for port forward dependencies
@@ -719,26 +767,15 @@ class Kubernetes(clouds.Cloud):
719
767
  return (False, 'No available context found in kubeconfig. '
720
768
  'Check if you have a valid kubeconfig file' +
721
769
  check_skypilot_config_msg)
722
- reasons = []
723
- hints = []
770
+
771
+ ctx2text = {}
724
772
  success = False
725
773
  for context in existing_allowed_contexts:
726
- try:
727
- check_result = kubernetes_utils.check_credentials(
728
- context, run_optional_checks=True)
729
- if check_result[0]:
730
- success = True
731
- if check_result[1] is not None:
732
- hints.append(f'Context {context}: {check_result[1]}')
733
- else:
734
- reasons.append(f'Context {context}: {check_result[1]}')
735
- except Exception as e: # pylint: disable=broad-except
736
- return (False, f'Credential check failed for {context}: '
737
- f'{common_utils.format_exception(e)}')
738
- if success:
739
- return (True, cls._format_credential_check_results(hints, reasons))
740
- return (False, 'Failed to find available context with working '
741
- 'credentials. Details:\n' + '\n'.join(reasons))
774
+ suc, text = cls._check_single_context(context)
775
+ success = success or suc
776
+ ctx2text[context] = text
777
+
778
+ return success, ctx2text
742
779
 
743
780
  @classmethod
744
781
  def _format_credential_check_results(cls, hints: List[str],
@@ -855,3 +892,10 @@ class Kubernetes(clouds.Cloud):
855
892
  if not key_valid or not value_valid:
856
893
  return False, error_msg
857
894
  return True, None
895
+
896
+ @classmethod
897
+ def get_infras(cls) -> List[str]:
898
+ return [
899
+ f'{cls._REPR.lower()}/{c}'
900
+ for c in cls.existing_allowed_contexts(silent=True)
901
+ ]
@@ -244,7 +244,8 @@ class Lambda(clouds.Cloud):
244
244
  fuzzy_candidate_list, None)
245
245
 
246
246
  @classmethod
247
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
247
+ def _check_compute_credentials(
248
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
248
249
  """Checks if the user has access credentials to
249
250
  Lambda's compute service."""
250
251
  try:
sky/clouds/nebius.py CHANGED
@@ -4,6 +4,7 @@ import typing
4
4
  from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
5
5
 
6
6
  from sky import clouds
7
+ from sky import skypilot_config
7
8
  from sky.adaptors import nebius
8
9
  from sky.clouds import service_catalog
9
10
  from sky.utils import annotations
@@ -210,6 +211,18 @@ class Nebius(clouds.Cloud):
210
211
  raise RuntimeError('Unsupported instance type for Nebius cloud:'
211
212
  f' {resources.instance_type}')
212
213
 
214
+ config_fs = skypilot_config.get_nested(
215
+ ('nebius', region.name, 'filesystems'), [])
216
+ resources_vars_fs = []
217
+ for i, fs in enumerate(config_fs):
218
+ resources_vars_fs.append({
219
+ 'filesystem_id': fs['filesystem_id'],
220
+ 'filesystem_attach_mode': fs.get('attach_mode', 'READ_WRITE'),
221
+ 'filesystem_mount_path': fs.get(
222
+ 'mount_path', f'/mnt/filesystem-skypilot-{i+1}'),
223
+ 'filesystem_mount_tag': f'filesystem-skypilot-{i+1}'
224
+ })
225
+
213
226
  resources_vars: Dict[str, Any] = {
214
227
  'instance_type': resources.instance_type,
215
228
  'custom_resources': custom_resources,
@@ -217,6 +230,7 @@ class Nebius(clouds.Cloud):
217
230
  'image_id': image_family,
218
231
  # Nebius does not support specific zones.
219
232
  'zones': None,
233
+ 'filesystems': resources_vars_fs
220
234
  }
221
235
 
222
236
  if acc_dict is not None:
@@ -283,7 +297,8 @@ class Nebius(clouds.Cloud):
283
297
 
284
298
  @classmethod
285
299
  @annotations.lru_cache(scope='request')
286
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
300
+ def _check_compute_credentials(
301
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
287
302
  """Checks if the user has access credentials to
288
303
  Nebius's compute service."""
289
304
  token_cred_msg = (
@@ -314,7 +329,8 @@ class Nebius(clouds.Cloud):
314
329
 
315
330
  @classmethod
316
331
  @annotations.lru_cache(scope='request')
317
- def _check_storage_credentials(cls) -> Tuple[bool, Optional[str]]:
332
+ def _check_storage_credentials(
333
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
318
334
  """Checks if the user has access credentials to Nebius Object Storage.
319
335
 
320
336
  Returns:
sky/clouds/oci.py CHANGED
@@ -401,13 +401,15 @@ class OCI(clouds.Cloud):
401
401
  fuzzy_candidate_list, None)
402
402
 
403
403
  @classmethod
404
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
404
+ def _check_compute_credentials(
405
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
405
406
  """Checks if the user has access credentials to
406
407
  OCI's compute service."""
407
408
  return cls._check_credentials()
408
409
 
409
410
  @classmethod
410
- def _check_storage_credentials(cls) -> Tuple[bool, Optional[str]]:
411
+ def _check_storage_credentials(
412
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
411
413
  """Checks if the user has access credentials to
412
414
  OCI's storage service."""
413
415
  # TODO(seungjin): Implement separate check for
sky/clouds/paperspace.py CHANGED
@@ -255,7 +255,8 @@ class Paperspace(clouds.Cloud):
255
255
  fuzzy_candidate_list, None)
256
256
 
257
257
  @classmethod
258
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
258
+ def _check_compute_credentials(
259
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
259
260
  """Checks if the user has access credentials to
260
261
  Paperspace's compute service."""
261
262
  try:
sky/clouds/runpod.py CHANGED
@@ -259,7 +259,8 @@ class RunPod(clouds.Cloud):
259
259
  fuzzy_candidate_list, None)
260
260
 
261
261
  @classmethod
262
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
262
+ def _check_compute_credentials(
263
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
263
264
  """Checks if the user has access credentials to
264
265
  RunPod's compute service."""
265
266
  return cls._check_credentials()
sky/clouds/scp.py CHANGED
@@ -316,7 +316,8 @@ class SCP(clouds.Cloud):
316
316
  fuzzy_candidate_list, None)
317
317
 
318
318
  @classmethod
319
- def _check_compute_credentials(cls) -> Tuple[bool, Optional[str]]:
319
+ def _check_compute_credentials(
320
+ cls) -> Tuple[bool, Optional[Union[str, Dict[str, str]]]]:
320
321
  """Checks if the user has access credentials to
321
322
  SCP's compute service."""
322
323
  try:
@@ -5,4 +5,4 @@ CATALOG_SCHEMA_VERSION = 'v7'
5
5
  CATALOG_DIR = '~/.sky/catalogs'
6
6
  ALL_CLOUDS = ('aws', 'azure', 'gcp', 'ibm', 'lambda', 'scp', 'oci',
7
7
  'kubernetes', 'runpod', 'vast', 'vsphere', 'cudo', 'fluidstack',
8
- 'paperspace', 'do', 'nebius')
8
+ 'paperspace', 'do', 'nebius', 'ssh')
@@ -0,0 +1,167 @@
1
+ """SSH Catalog.
2
+
3
+ This catalog inherits from the Kubernetes catalog as SSH cloud is a wrapper
4
+ around Kubernetes that uses SSH-specific contexts.
5
+ """
6
+ import typing
7
+ from typing import Dict, List, Optional, Tuple
8
+
9
+ from sky import sky_logging
10
+ from sky.clouds import ssh
11
+ from sky.clouds.service_catalog import CloudFilter
12
+ from sky.clouds.service_catalog import common
13
+ from sky.clouds.service_catalog import kubernetes_catalog
14
+
15
+ logger = sky_logging.init_logger(__name__)
16
+
17
+ if typing.TYPE_CHECKING:
18
+ import pandas as pd
19
+ else:
20
+ from sky.adaptors import common as adaptors_common
21
+ pd = adaptors_common.LazyImport('pandas')
22
+
23
+ _PULL_FREQUENCY_HOURS = 7
24
+
25
+ # Reuse the Kubernetes images catalog for SSH cloud.
26
+ # We keep pull_frequency_hours so we can remotely update the default image paths
27
+ _image_df = common.read_catalog('kubernetes/images.csv',
28
+ pull_frequency_hours=_PULL_FREQUENCY_HOURS)
29
+
30
+
31
+ def get_image_id_from_tag(tag: str, region: Optional[str]) -> Optional[str]:
32
+ """Returns the image id from the tag.
33
+
34
+ Delegates to Kubernetes catalog implementation.
35
+ """
36
+ return kubernetes_catalog.get_image_id_from_tag(tag, region)
37
+
38
+
39
+ def is_image_tag_valid(tag: str, region: Optional[str]) -> bool:
40
+ """Returns whether the image tag is valid.
41
+
42
+ Delegates to Kubernetes catalog implementation.
43
+ """
44
+ return kubernetes_catalog.is_image_tag_valid(tag, region)
45
+
46
+
47
+ def list_accelerators(
48
+ gpus_only: bool,
49
+ name_filter: Optional[str],
50
+ region_filter: Optional[str],
51
+ quantity_filter: Optional[int],
52
+ case_sensitive: bool = True,
53
+ all_regions: bool = False,
54
+ require_price: bool = True) -> Dict[str, List[common.InstanceTypeInfo]]:
55
+ """List accelerators in SSH-based Kubernetes clusters.
56
+
57
+ Delegates to the Kubernetes _list_accelerators function but restricts to
58
+ SSH contexts.
59
+ """
60
+ return _list_accelerators(gpus_only,
61
+ name_filter,
62
+ region_filter,
63
+ quantity_filter,
64
+ case_sensitive,
65
+ all_regions,
66
+ require_price,
67
+ realtime=False)[0]
68
+
69
+
70
+ def list_accelerators_realtime(
71
+ gpus_only: bool,
72
+ name_filter: Optional[str],
73
+ region_filter: Optional[str],
74
+ quantity_filter: Optional[int],
75
+ case_sensitive: bool = True,
76
+ all_regions: bool = False,
77
+ require_price: bool = True
78
+ ) -> Tuple[Dict[str, List[common.InstanceTypeInfo]], Dict[str, int], Dict[str,
79
+ int]]:
80
+ """List accelerators in SSH Node Pools with real-time information.
81
+
82
+ Delegates to the Kubernetes _list_accelerators function but restricts to
83
+ SSH contexts.
84
+ """
85
+ return _list_accelerators(gpus_only,
86
+ name_filter,
87
+ region_filter,
88
+ quantity_filter,
89
+ case_sensitive,
90
+ all_regions,
91
+ require_price,
92
+ realtime=True)
93
+
94
+
95
+ def _list_accelerators(
96
+ gpus_only: bool,
97
+ name_filter: Optional[str],
98
+ region_filter: Optional[str],
99
+ quantity_filter: Optional[int],
100
+ case_sensitive: bool = True,
101
+ all_regions: bool = False,
102
+ require_price: bool = True,
103
+ realtime: bool = False
104
+ ) -> Tuple[Dict[str, List[common.InstanceTypeInfo]], Dict[str, int], Dict[str,
105
+ int]]:
106
+ """List accelerators in SSH-based Kubernetes clusters.
107
+
108
+ This is a wrapper around the Kubernetes _list_accelerators function that
109
+ restricts the contexts to SSH-specific contexts only.
110
+
111
+ If region_filter is specified and it's not an SSH context, no results will
112
+ be returned.
113
+ """
114
+ # If a specific region is requested, ensure it's an SSH context
115
+ if region_filter is not None and not region_filter.startswith('ssh-'):
116
+ return {}, {}, {}
117
+
118
+ # Get SSH contexts
119
+ ssh_contexts = ssh.SSH.existing_allowed_contexts()
120
+
121
+ # If no contexts found, return empty results
122
+ if not ssh_contexts:
123
+ return {}, {}, {}
124
+
125
+ # If a region filter is specified and it's not a SSH context return empty
126
+ # results
127
+ if region_filter is not None and region_filter not in ssh_contexts:
128
+ return {}, {}, {}
129
+
130
+ # If region_filter is None, use the first context if all_regions is False
131
+ if region_filter is None and not all_regions and ssh_contexts:
132
+ # Use the first SSH context if no specific region requested
133
+ region_filter = ssh_contexts[0]
134
+
135
+ # Call the Kubernetes _list_accelerators with the appropriate region filter
136
+ if realtime:
137
+ return kubernetes_catalog.list_accelerators_realtime(
138
+ gpus_only, name_filter, region_filter, quantity_filter,
139
+ case_sensitive, all_regions, require_price)
140
+ else:
141
+ result = kubernetes_catalog.list_accelerators(
142
+ gpus_only, name_filter, region_filter, quantity_filter,
143
+ case_sensitive, all_regions, require_price)
144
+ return result, {}, {}
145
+
146
+
147
+ def validate_region_zone(
148
+ region_name: Optional[str],
149
+ zone_name: Optional[str],
150
+ clouds: CloudFilter = None) -> Tuple[Optional[str], Optional[str]]:
151
+ """Validates the region and zone for SSH cloud.
152
+
153
+ Delegates to the Kubernetes catalog implementation but ensures
154
+ the region is a valid SSH context.
155
+ """
156
+ # Delegate to Kubernetes implementation
157
+ region, zone = kubernetes_catalog.validate_region_zone(
158
+ region_name, zone_name, clouds)
159
+
160
+ # Get SSH contexts
161
+ ssh_contexts = ssh.SSH.existing_allowed_contexts()
162
+
163
+ # If a region is specified, ensure it's in the list of SSH contexts
164
+ if region is not None and region not in ssh_contexts:
165
+ return None, None
166
+
167
+ return region, zone