skypilot-nightly 1.0.0.dev2024053101__py3-none-any.whl → 1.0.0.dev2025022801__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 (299) hide show
  1. sky/__init__.py +64 -32
  2. sky/adaptors/aws.py +23 -6
  3. sky/adaptors/azure.py +432 -15
  4. sky/adaptors/cloudflare.py +5 -5
  5. sky/adaptors/common.py +19 -9
  6. sky/adaptors/do.py +20 -0
  7. sky/adaptors/gcp.py +3 -2
  8. sky/adaptors/kubernetes.py +122 -88
  9. sky/adaptors/nebius.py +100 -0
  10. sky/adaptors/oci.py +39 -1
  11. sky/adaptors/vast.py +29 -0
  12. sky/admin_policy.py +101 -0
  13. sky/authentication.py +117 -98
  14. sky/backends/backend.py +52 -20
  15. sky/backends/backend_utils.py +669 -557
  16. sky/backends/cloud_vm_ray_backend.py +1099 -808
  17. sky/backends/local_docker_backend.py +14 -8
  18. sky/backends/wheel_utils.py +38 -20
  19. sky/benchmark/benchmark_utils.py +22 -23
  20. sky/check.py +76 -27
  21. sky/cli.py +1586 -1139
  22. sky/client/__init__.py +1 -0
  23. sky/client/cli.py +5683 -0
  24. sky/client/common.py +345 -0
  25. sky/client/sdk.py +1765 -0
  26. sky/cloud_stores.py +283 -19
  27. sky/clouds/__init__.py +7 -2
  28. sky/clouds/aws.py +303 -112
  29. sky/clouds/azure.py +185 -179
  30. sky/clouds/cloud.py +115 -37
  31. sky/clouds/cudo.py +29 -22
  32. sky/clouds/do.py +313 -0
  33. sky/clouds/fluidstack.py +44 -54
  34. sky/clouds/gcp.py +206 -65
  35. sky/clouds/ibm.py +26 -21
  36. sky/clouds/kubernetes.py +345 -91
  37. sky/clouds/lambda_cloud.py +40 -29
  38. sky/clouds/nebius.py +297 -0
  39. sky/clouds/oci.py +129 -90
  40. sky/clouds/paperspace.py +22 -18
  41. sky/clouds/runpod.py +53 -34
  42. sky/clouds/scp.py +28 -24
  43. sky/clouds/service_catalog/__init__.py +19 -13
  44. sky/clouds/service_catalog/aws_catalog.py +29 -12
  45. sky/clouds/service_catalog/azure_catalog.py +33 -6
  46. sky/clouds/service_catalog/common.py +95 -75
  47. sky/clouds/service_catalog/constants.py +3 -3
  48. sky/clouds/service_catalog/cudo_catalog.py +13 -3
  49. sky/clouds/service_catalog/data_fetchers/fetch_aws.py +36 -21
  50. sky/clouds/service_catalog/data_fetchers/fetch_azure.py +31 -4
  51. sky/clouds/service_catalog/data_fetchers/fetch_cudo.py +8 -117
  52. sky/clouds/service_catalog/data_fetchers/fetch_fluidstack.py +197 -44
  53. sky/clouds/service_catalog/data_fetchers/fetch_gcp.py +224 -36
  54. sky/clouds/service_catalog/data_fetchers/fetch_lambda_cloud.py +44 -24
  55. sky/clouds/service_catalog/data_fetchers/fetch_vast.py +147 -0
  56. sky/clouds/service_catalog/data_fetchers/fetch_vsphere.py +1 -1
  57. sky/clouds/service_catalog/do_catalog.py +111 -0
  58. sky/clouds/service_catalog/fluidstack_catalog.py +2 -2
  59. sky/clouds/service_catalog/gcp_catalog.py +16 -2
  60. sky/clouds/service_catalog/ibm_catalog.py +2 -2
  61. sky/clouds/service_catalog/kubernetes_catalog.py +192 -70
  62. sky/clouds/service_catalog/lambda_catalog.py +8 -3
  63. sky/clouds/service_catalog/nebius_catalog.py +116 -0
  64. sky/clouds/service_catalog/oci_catalog.py +31 -4
  65. sky/clouds/service_catalog/paperspace_catalog.py +2 -2
  66. sky/clouds/service_catalog/runpod_catalog.py +2 -2
  67. sky/clouds/service_catalog/scp_catalog.py +2 -2
  68. sky/clouds/service_catalog/vast_catalog.py +104 -0
  69. sky/clouds/service_catalog/vsphere_catalog.py +2 -2
  70. sky/clouds/utils/aws_utils.py +65 -0
  71. sky/clouds/utils/azure_utils.py +91 -0
  72. sky/clouds/utils/gcp_utils.py +5 -9
  73. sky/clouds/utils/oci_utils.py +47 -5
  74. sky/clouds/utils/scp_utils.py +4 -3
  75. sky/clouds/vast.py +280 -0
  76. sky/clouds/vsphere.py +22 -18
  77. sky/core.py +361 -107
  78. sky/dag.py +41 -28
  79. sky/data/data_transfer.py +37 -0
  80. sky/data/data_utils.py +211 -32
  81. sky/data/mounting_utils.py +182 -30
  82. sky/data/storage.py +2118 -270
  83. sky/data/storage_utils.py +126 -5
  84. sky/exceptions.py +179 -8
  85. sky/execution.py +158 -85
  86. sky/global_user_state.py +150 -34
  87. sky/jobs/__init__.py +12 -10
  88. sky/jobs/client/__init__.py +0 -0
  89. sky/jobs/client/sdk.py +302 -0
  90. sky/jobs/constants.py +49 -11
  91. sky/jobs/controller.py +161 -99
  92. sky/jobs/dashboard/dashboard.py +171 -25
  93. sky/jobs/dashboard/templates/index.html +572 -60
  94. sky/jobs/recovery_strategy.py +157 -156
  95. sky/jobs/scheduler.py +307 -0
  96. sky/jobs/server/__init__.py +1 -0
  97. sky/jobs/server/core.py +598 -0
  98. sky/jobs/server/dashboard_utils.py +69 -0
  99. sky/jobs/server/server.py +190 -0
  100. sky/jobs/state.py +627 -122
  101. sky/jobs/utils.py +615 -206
  102. sky/models.py +27 -0
  103. sky/optimizer.py +142 -83
  104. sky/provision/__init__.py +20 -5
  105. sky/provision/aws/config.py +124 -42
  106. sky/provision/aws/instance.py +130 -53
  107. sky/provision/azure/__init__.py +7 -0
  108. sky/{skylet/providers → provision}/azure/azure-config-template.json +19 -7
  109. sky/provision/azure/config.py +220 -0
  110. sky/provision/azure/instance.py +1012 -37
  111. sky/provision/common.py +31 -3
  112. sky/provision/constants.py +25 -0
  113. sky/provision/cudo/__init__.py +2 -1
  114. sky/provision/cudo/cudo_utils.py +112 -0
  115. sky/provision/cudo/cudo_wrapper.py +37 -16
  116. sky/provision/cudo/instance.py +28 -12
  117. sky/provision/do/__init__.py +11 -0
  118. sky/provision/do/config.py +14 -0
  119. sky/provision/do/constants.py +10 -0
  120. sky/provision/do/instance.py +287 -0
  121. sky/provision/do/utils.py +301 -0
  122. sky/provision/docker_utils.py +82 -46
  123. sky/provision/fluidstack/fluidstack_utils.py +57 -125
  124. sky/provision/fluidstack/instance.py +15 -43
  125. sky/provision/gcp/config.py +19 -9
  126. sky/provision/gcp/constants.py +7 -1
  127. sky/provision/gcp/instance.py +55 -34
  128. sky/provision/gcp/instance_utils.py +339 -80
  129. sky/provision/gcp/mig_utils.py +210 -0
  130. sky/provision/instance_setup.py +172 -133
  131. sky/provision/kubernetes/__init__.py +1 -0
  132. sky/provision/kubernetes/config.py +104 -90
  133. sky/provision/kubernetes/constants.py +8 -0
  134. sky/provision/kubernetes/instance.py +680 -325
  135. sky/provision/kubernetes/manifests/smarter-device-manager-daemonset.yaml +3 -0
  136. sky/provision/kubernetes/network.py +54 -20
  137. sky/provision/kubernetes/network_utils.py +70 -21
  138. sky/provision/kubernetes/utils.py +1370 -251
  139. sky/provision/lambda_cloud/__init__.py +11 -0
  140. sky/provision/lambda_cloud/config.py +10 -0
  141. sky/provision/lambda_cloud/instance.py +265 -0
  142. sky/{clouds/utils → provision/lambda_cloud}/lambda_utils.py +24 -23
  143. sky/provision/logging.py +1 -1
  144. sky/provision/nebius/__init__.py +11 -0
  145. sky/provision/nebius/config.py +11 -0
  146. sky/provision/nebius/instance.py +285 -0
  147. sky/provision/nebius/utils.py +318 -0
  148. sky/provision/oci/__init__.py +15 -0
  149. sky/provision/oci/config.py +51 -0
  150. sky/provision/oci/instance.py +436 -0
  151. sky/provision/oci/query_utils.py +681 -0
  152. sky/provision/paperspace/constants.py +6 -0
  153. sky/provision/paperspace/instance.py +4 -3
  154. sky/provision/paperspace/utils.py +2 -0
  155. sky/provision/provisioner.py +207 -130
  156. sky/provision/runpod/__init__.py +1 -0
  157. sky/provision/runpod/api/__init__.py +3 -0
  158. sky/provision/runpod/api/commands.py +119 -0
  159. sky/provision/runpod/api/pods.py +142 -0
  160. sky/provision/runpod/instance.py +64 -8
  161. sky/provision/runpod/utils.py +239 -23
  162. sky/provision/vast/__init__.py +10 -0
  163. sky/provision/vast/config.py +11 -0
  164. sky/provision/vast/instance.py +247 -0
  165. sky/provision/vast/utils.py +162 -0
  166. sky/provision/vsphere/common/vim_utils.py +1 -1
  167. sky/provision/vsphere/instance.py +8 -18
  168. sky/provision/vsphere/vsphere_utils.py +1 -1
  169. sky/resources.py +247 -102
  170. sky/serve/__init__.py +9 -9
  171. sky/serve/autoscalers.py +361 -299
  172. sky/serve/client/__init__.py +0 -0
  173. sky/serve/client/sdk.py +366 -0
  174. sky/serve/constants.py +12 -3
  175. sky/serve/controller.py +106 -36
  176. sky/serve/load_balancer.py +63 -12
  177. sky/serve/load_balancing_policies.py +84 -2
  178. sky/serve/replica_managers.py +42 -34
  179. sky/serve/serve_state.py +62 -32
  180. sky/serve/serve_utils.py +271 -160
  181. sky/serve/server/__init__.py +0 -0
  182. sky/serve/{core.py → server/core.py} +271 -90
  183. sky/serve/server/server.py +112 -0
  184. sky/serve/service.py +52 -16
  185. sky/serve/service_spec.py +95 -32
  186. sky/server/__init__.py +1 -0
  187. sky/server/common.py +430 -0
  188. sky/server/constants.py +21 -0
  189. sky/server/html/log.html +174 -0
  190. sky/server/requests/__init__.py +0 -0
  191. sky/server/requests/executor.py +472 -0
  192. sky/server/requests/payloads.py +487 -0
  193. sky/server/requests/queues/__init__.py +0 -0
  194. sky/server/requests/queues/mp_queue.py +76 -0
  195. sky/server/requests/requests.py +567 -0
  196. sky/server/requests/serializers/__init__.py +0 -0
  197. sky/server/requests/serializers/decoders.py +192 -0
  198. sky/server/requests/serializers/encoders.py +166 -0
  199. sky/server/server.py +1106 -0
  200. sky/server/stream_utils.py +141 -0
  201. sky/setup_files/MANIFEST.in +2 -5
  202. sky/setup_files/dependencies.py +159 -0
  203. sky/setup_files/setup.py +14 -125
  204. sky/sky_logging.py +59 -14
  205. sky/skylet/autostop_lib.py +2 -2
  206. sky/skylet/constants.py +183 -50
  207. sky/skylet/events.py +22 -10
  208. sky/skylet/job_lib.py +403 -258
  209. sky/skylet/log_lib.py +111 -71
  210. sky/skylet/log_lib.pyi +6 -0
  211. sky/skylet/providers/command_runner.py +6 -8
  212. sky/skylet/providers/ibm/node_provider.py +2 -2
  213. sky/skylet/providers/scp/config.py +11 -3
  214. sky/skylet/providers/scp/node_provider.py +8 -8
  215. sky/skylet/skylet.py +3 -1
  216. sky/skylet/subprocess_daemon.py +69 -17
  217. sky/skypilot_config.py +119 -57
  218. sky/task.py +205 -64
  219. sky/templates/aws-ray.yml.j2 +37 -7
  220. sky/templates/azure-ray.yml.j2 +27 -82
  221. sky/templates/cudo-ray.yml.j2 +7 -3
  222. sky/templates/do-ray.yml.j2 +98 -0
  223. sky/templates/fluidstack-ray.yml.j2 +7 -4
  224. sky/templates/gcp-ray.yml.j2 +26 -6
  225. sky/templates/ibm-ray.yml.j2 +3 -2
  226. sky/templates/jobs-controller.yaml.j2 +46 -11
  227. sky/templates/kubernetes-ingress.yml.j2 +7 -0
  228. sky/templates/kubernetes-loadbalancer.yml.j2 +7 -0
  229. sky/templates/{kubernetes-port-forward-proxy-command.sh.j2 → kubernetes-port-forward-proxy-command.sh} +51 -7
  230. sky/templates/kubernetes-ray.yml.j2 +292 -25
  231. sky/templates/lambda-ray.yml.j2 +30 -40
  232. sky/templates/nebius-ray.yml.j2 +79 -0
  233. sky/templates/oci-ray.yml.j2 +18 -57
  234. sky/templates/paperspace-ray.yml.j2 +10 -6
  235. sky/templates/runpod-ray.yml.j2 +26 -4
  236. sky/templates/scp-ray.yml.j2 +3 -2
  237. sky/templates/sky-serve-controller.yaml.j2 +12 -1
  238. sky/templates/skypilot-server-kubernetes-proxy.sh +36 -0
  239. sky/templates/vast-ray.yml.j2 +70 -0
  240. sky/templates/vsphere-ray.yml.j2 +8 -3
  241. sky/templates/websocket_proxy.py +64 -0
  242. sky/usage/constants.py +10 -1
  243. sky/usage/usage_lib.py +130 -37
  244. sky/utils/accelerator_registry.py +35 -51
  245. sky/utils/admin_policy_utils.py +147 -0
  246. sky/utils/annotations.py +51 -0
  247. sky/utils/cli_utils/status_utils.py +81 -23
  248. sky/utils/cluster_utils.py +356 -0
  249. sky/utils/command_runner.py +452 -89
  250. sky/utils/command_runner.pyi +77 -3
  251. sky/utils/common.py +54 -0
  252. sky/utils/common_utils.py +319 -108
  253. sky/utils/config_utils.py +204 -0
  254. sky/utils/control_master_utils.py +48 -0
  255. sky/utils/controller_utils.py +548 -266
  256. sky/utils/dag_utils.py +93 -32
  257. sky/utils/db_utils.py +18 -4
  258. sky/utils/env_options.py +29 -7
  259. sky/utils/kubernetes/create_cluster.sh +8 -60
  260. sky/utils/kubernetes/deploy_remote_cluster.sh +243 -0
  261. sky/utils/kubernetes/exec_kubeconfig_converter.py +73 -0
  262. sky/utils/kubernetes/generate_kubeconfig.sh +336 -0
  263. sky/utils/kubernetes/gpu_labeler.py +4 -4
  264. sky/utils/kubernetes/k8s_gpu_labeler_job.yaml +4 -3
  265. sky/utils/kubernetes/kubernetes_deploy_utils.py +228 -0
  266. sky/utils/kubernetes/rsync_helper.sh +24 -0
  267. sky/utils/kubernetes/ssh_jump_lifecycle_manager.py +1 -1
  268. sky/utils/log_utils.py +240 -33
  269. sky/utils/message_utils.py +81 -0
  270. sky/utils/registry.py +127 -0
  271. sky/utils/resources_utils.py +94 -22
  272. sky/utils/rich_utils.py +247 -18
  273. sky/utils/schemas.py +284 -64
  274. sky/{status_lib.py → utils/status_lib.py} +12 -7
  275. sky/utils/subprocess_utils.py +212 -46
  276. sky/utils/timeline.py +12 -7
  277. sky/utils/ux_utils.py +168 -15
  278. skypilot_nightly-1.0.0.dev2025022801.dist-info/METADATA +363 -0
  279. skypilot_nightly-1.0.0.dev2025022801.dist-info/RECORD +352 -0
  280. {skypilot_nightly-1.0.0.dev2024053101.dist-info → skypilot_nightly-1.0.0.dev2025022801.dist-info}/WHEEL +1 -1
  281. sky/clouds/cloud_registry.py +0 -31
  282. sky/jobs/core.py +0 -330
  283. sky/skylet/providers/azure/__init__.py +0 -2
  284. sky/skylet/providers/azure/azure-vm-template.json +0 -301
  285. sky/skylet/providers/azure/config.py +0 -170
  286. sky/skylet/providers/azure/node_provider.py +0 -466
  287. sky/skylet/providers/lambda_cloud/__init__.py +0 -2
  288. sky/skylet/providers/lambda_cloud/node_provider.py +0 -320
  289. sky/skylet/providers/oci/__init__.py +0 -2
  290. sky/skylet/providers/oci/node_provider.py +0 -488
  291. sky/skylet/providers/oci/query_helper.py +0 -383
  292. sky/skylet/providers/oci/utils.py +0 -21
  293. sky/utils/cluster_yaml_utils.py +0 -24
  294. sky/utils/kubernetes/generate_static_kubeconfig.sh +0 -137
  295. skypilot_nightly-1.0.0.dev2024053101.dist-info/METADATA +0 -315
  296. skypilot_nightly-1.0.0.dev2024053101.dist-info/RECORD +0 -275
  297. {skypilot_nightly-1.0.0.dev2024053101.dist-info → skypilot_nightly-1.0.0.dev2025022801.dist-info}/LICENSE +0 -0
  298. {skypilot_nightly-1.0.0.dev2024053101.dist-info → skypilot_nightly-1.0.0.dev2025022801.dist-info}/entry_points.txt +0 -0
  299. {skypilot_nightly-1.0.0.dev2024053101.dist-info → skypilot_nightly-1.0.0.dev2025022801.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,162 @@
1
+ # pylint: disable=assignment-from-no-return
2
+ #
3
+ # The pylint exception above is an accomodation for
4
+ # false positives generated by pylint for the Vast
5
+ # python sdk.
6
+ #
7
+ """Vast library wrapper for SkyPilot."""
8
+ from typing import Any, Dict, List
9
+
10
+ from sky import sky_logging
11
+ from sky.adaptors import vast
12
+
13
+ logger = sky_logging.init_logger(__name__)
14
+
15
+
16
+ def list_instances() -> Dict[str, Dict[str, Any]]:
17
+ """Lists instances associated with API key."""
18
+ instances = vast.vast().show_instances()
19
+
20
+ instance_dict: Dict[str, Dict[str, Any]] = {}
21
+ for instance in instances:
22
+ instance['id'] = str(instance['id'])
23
+ info = instance
24
+
25
+ if isinstance(instance['actual_status'], str):
26
+ info['status'] = instance['actual_status'].upper()
27
+ else:
28
+ info['status'] = 'UNKNOWN'
29
+ info['name'] = instance['label']
30
+
31
+ instance_dict[instance['id']] = info
32
+
33
+ return instance_dict
34
+
35
+
36
+ def launch(name: str, instance_type: str, region: str, disk_size: int,
37
+ image_name: str, preemptible: bool) -> str:
38
+ """Launches an instance with the given parameters.
39
+
40
+ Converts the instance_type to the Vast GPU name, finds the specs for the
41
+ GPU, and launches the instance.
42
+
43
+ Notes:
44
+
45
+ * `georegion`: This is a feature flag to provide an additional
46
+ scope of geographical specificy while maintaining backward
47
+ compatibility.
48
+
49
+ * `chunked`: This is a feature flag to give breadth to the
50
+ snowflake nature of the vast catalog marketplace. It rounds
51
+ down various specifications of machines to emulate an instance
52
+ type and make them more interchangeable.
53
+
54
+ * `disk_size`: We look for instances that are of the requested
55
+ size or greater than it. For instance, `disk_size=100` might
56
+ return something with `disk_size` at 102 or even 1000.
57
+
58
+ The disk size {xx} GB is not exactly matched the requested
59
+ size {yy} GB. It is possible to charge extra cost on disk.
60
+
61
+ * `geolocation`: Geolocation on Vast can be as specific as the
62
+ host chooses to be. They can say, for instance, "Yutakachō,
63
+ Shinagawa District, Tokyo, JP." Such a specific geolocation
64
+ as ours would fail to return this host in a simple string
65
+ comparison if a user searched for "JP".
66
+
67
+ Since regardless of specificity, all our geolocations end
68
+ in two-letter country codes we just snip that to conform
69
+ to how many providers state their geolocation.
70
+
71
+ * Since the catalog is cached, we can't gaurantee availability
72
+ of any machine at the point of inquiry. As a consequence we
73
+ search for the machine again and potentially return a failure
74
+ if there is no availability.
75
+
76
+ * We pass in the cpu_ram here as a guarantor to make sure the
77
+ instance we match with will be compliant with the requested
78
+ amount of memory.
79
+
80
+ * Vast instance types are an invention for skypilot. Refer to
81
+ service_catalog/vast_catalog.py for the current construction
82
+ of the type.
83
+
84
+ """
85
+ cpu_ram = float(instance_type.split('-')[-1]) / 1024
86
+ gpu_name = instance_type.split('-')[1].replace('_', ' ')
87
+ num_gpus = int(instance_type.split('-')[0].replace('x', ''))
88
+
89
+ query = ' '.join([
90
+ 'chunked=true',
91
+ 'georegion=true',
92
+ f'geolocation="{region[-2:]}"',
93
+ f'disk_space>={disk_size}',
94
+ f'num_gpus={num_gpus}',
95
+ f'gpu_name="{gpu_name}"',
96
+ f'cpu_ram>="{cpu_ram}"',
97
+ ])
98
+
99
+ instance_list = vast.vast().search_offers(query=query)
100
+
101
+ if isinstance(instance_list, int) or len(instance_list) == 0:
102
+ raise RuntimeError('Failed to create instances, could not find an '
103
+ f'offer that satisfies the requirements "{query}".')
104
+
105
+ instance_touse = instance_list[0]
106
+
107
+ launch_params = {
108
+ 'id': instance_touse['id'],
109
+ 'direct': True,
110
+ 'ssh': True,
111
+ 'env': '-e __SOURCE=skypilot',
112
+ 'onstart_cmd': ';'.join([
113
+ 'touch ~/.no_auto_tmux',
114
+ f'echo "{vast.vast().api_key_access}" > ~/.vast_api_key',
115
+ ]),
116
+ 'label': name,
117
+ 'image': image_name,
118
+ 'disk': disk_size
119
+ }
120
+
121
+ if preemptible:
122
+ launch_params['min_bid'] = instance_touse['min_bid']
123
+
124
+ new_instance_contract = vast.vast().create_instance(**launch_params)
125
+
126
+ new_instance = vast.vast().show_instance(
127
+ id=new_instance_contract['new_contract'])
128
+
129
+ return new_instance['id']
130
+
131
+
132
+ def start(instance_id: str) -> None:
133
+ """Starts the given instance."""
134
+ vast.vast().start_instance(id=instance_id)
135
+
136
+
137
+ def stop(instance_id: str) -> None:
138
+ """Stops the given instance."""
139
+ vast.vast().stop_instance(id=instance_id)
140
+
141
+
142
+ def remove(instance_id: str) -> None:
143
+ """Terminates the given instance."""
144
+ vast.vast().destroy_instance(id=instance_id)
145
+
146
+
147
+ def get_ssh_ports(cluster_name: str) -> List[int]:
148
+ """Gets the SSH ports for the given cluster."""
149
+ logger.debug(f'Getting SSH ports for cluster {cluster_name}.')
150
+
151
+ instances = list_instances()
152
+ possible_names = [f'{cluster_name}-head', f'{cluster_name}-worker']
153
+
154
+ ssh_ports = []
155
+
156
+ for instance in instances.values():
157
+ if instance['name'] in possible_names:
158
+ ssh_ports.append(instance['ssh_port'])
159
+ assert ssh_ports, (
160
+ f'Could not find any instances for cluster {cluster_name}.')
161
+
162
+ return ssh_ports
@@ -56,7 +56,7 @@ def get_hosts_by_cluster_names(content, vcenter_name, cluster_name_dicts=None):
56
56
  'name': cluster.name
57
57
  } for cluster in cluster_view.view]
58
58
  cluster_view.Destroy()
59
- if len(cluster_name_dicts) == 0:
59
+ if not cluster_name_dicts:
60
60
  logger.warning(f'vCenter \'{vcenter_name}\' has no clusters')
61
61
 
62
62
  # Retrieve all cluster names from the cluster_name_dicts
@@ -1,12 +1,9 @@
1
1
  """Vsphere instance provisioning."""
2
2
  import json
3
- import os
4
3
  import typing
5
4
  from typing import Any, Dict, List, Optional
6
5
 
7
- from sky import exceptions
8
6
  from sky import sky_logging
9
- from sky import status_lib
10
7
  from sky.adaptors import common as adaptors_common
11
8
  from sky.adaptors import vsphere as vsphere_adaptor
12
9
  from sky.clouds.service_catalog.common import get_catalog_path
@@ -18,6 +15,7 @@ from sky.provision.vsphere.common.vim_utils import poweroff_vm
18
15
  from sky.provision.vsphere.common.vim_utils import wait_for_tasks
19
16
  from sky.provision.vsphere.common.vim_utils import wait_internal_ip_ready
20
17
  from sky.provision.vsphere.vsphere_utils import VsphereClient
18
+ from sky.utils import status_lib
21
19
 
22
20
  if typing.TYPE_CHECKING:
23
21
  import pandas as pd
@@ -30,7 +28,6 @@ TAG_SKYPILOT_CLUSTER_NAME = 'skypilot-cluster-name'
30
28
  TAG_SKYPILOT_HEAD_NODE = 'skypilot-head-node'
31
29
  HEAD_NODE_VALUE = '1'
32
30
  WORKER_NODE_VALUE = '0'
33
- PUBLIC_SSH_KEY_PATH = '~/.ssh/sky-key.pub'
34
31
 
35
32
 
36
33
  def run_instances(region: str, cluster_name: str,
@@ -162,7 +159,7 @@ def _create_instances(
162
159
  if not gpu_instance:
163
160
  # Find an image for CPU
164
161
  images_df = images_df[images_df['GpuTags'] == '\'[]\'']
165
- if len(images_df) == 0:
162
+ if not images_df:
166
163
  logger.error(
167
164
  f'Can not find an image for instance type: {instance_type}.')
168
165
  raise Exception(
@@ -185,7 +182,7 @@ def _create_instances(
185
182
  image_instance_mapping_df = image_instance_mapping_df[
186
183
  image_instance_mapping_df['InstanceType'] == instance_type]
187
184
 
188
- if len(image_instance_mapping_df) == 0:
185
+ if not image_instance_mapping_df:
189
186
  raise Exception(f"""There is no image can match instance type named
190
187
  {instance_type}
191
188
  If you are using CPU-only instance, assign an image with tag
@@ -218,10 +215,9 @@ def _create_instances(
218
215
  hosts_df = hosts_df[(hosts_df['AvailableCPUs'] /
219
216
  hosts_df['cpuMhz']) >= cpus_needed]
220
217
  hosts_df = hosts_df[hosts_df['AvailableMemory(MB)'] >= memory_needed]
221
- assert len(hosts_df) > 0, (
222
- f'There is no host available to create the instance '
223
- f'{vms_item["InstanceType"]}, at least {cpus_needed} '
224
- f'cpus and {memory_needed}MB memory are required.')
218
+ assert hosts_df, (f'There is no host available to create the instance '
219
+ f'{vms_item["InstanceType"]}, at least {cpus_needed} '
220
+ f'cpus and {memory_needed}MB memory are required.')
225
221
 
226
222
  # Sort the hosts df by AvailableCPUs to get the compatible host with the
227
223
  # least resource
@@ -303,13 +299,7 @@ def _create_instances(
303
299
 
304
300
  # Create the customization spec
305
301
  # Set up the VM's authorized_keys with customization spec
306
- ssh_key_path = os.path.expanduser(PUBLIC_SSH_KEY_PATH)
307
- if not os.path.exists(ssh_key_path):
308
- logger.error('SSH pubic key does not exist.')
309
- raise exceptions.ResourcesUnavailableError(
310
- 'SSH pubic key does not exist.')
311
- with open(ssh_key_path, 'r', encoding='utf-8') as f:
312
- ssh_public_key = f.read()
302
+ ssh_public_key = config.authentication_config['ssh_public_key']
313
303
 
314
304
  # Create a custom script to inject the ssh public key into the instance
315
305
  vm_user = config.authentication_config['ssh_user']
@@ -365,7 +355,7 @@ def _choose_vsphere_cluster_name(config: common.ProvisionConfig, region: str,
365
355
  skypilot framework-optimized availability_zones"""
366
356
  vsphere_cluster_name = None
367
357
  vsphere_cluster_name_str = config.provider_config['availability_zone']
368
- if len(vc_object.clusters) > 0:
358
+ if vc_object.clusters:
369
359
  for optimized_cluster_name in vsphere_cluster_name_str.split(','):
370
360
  if optimized_cluster_name in [
371
361
  item['name'] for item in vc_object.clusters
@@ -257,7 +257,7 @@ class VsphereClient:
257
257
  # hard code here. should support configure later.
258
258
  profile_name = 'skypilot_policy'
259
259
  storage_profile_id = None
260
- if len(profile_ids) > 0:
260
+ if profile_ids:
261
261
  profiles = pm.PbmRetrieveContent(profileIds=profile_ids)
262
262
  for profile in profiles:
263
263
  if profile_name in profile.name: