skypilot-nightly 1.0.0.dev20250806__py3-none-any.whl → 1.0.0.dev20250807__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.

Potentially problematic release.


This version of skypilot-nightly might be problematic. Click here for more details.

Files changed (123) hide show
  1. sky/__init__.py +2 -2
  2. sky/backends/cloud_vm_ray_backend.py +33 -4
  3. sky/check.py +11 -1
  4. sky/client/cli/command.py +208 -93
  5. sky/client/sdk.py +14 -1
  6. sky/client/sdk_async.py +4 -0
  7. sky/dashboard/out/404.html +1 -1
  8. sky/dashboard/out/_next/static/YAirOGsV1z6B2RJ0VIUmD/_buildManifest.js +1 -0
  9. sky/dashboard/out/_next/static/chunks/1141-a8a8f1adba34c892.js +11 -0
  10. sky/dashboard/out/_next/static/chunks/1871-980a395e92633a5c.js +6 -0
  11. sky/dashboard/out/_next/static/chunks/3785.6003d293cb83eab4.js +1 -0
  12. sky/dashboard/out/_next/static/chunks/3850-ff4a9a69d978632b.js +1 -0
  13. sky/dashboard/out/_next/static/chunks/4725.29550342bd53afd8.js +1 -0
  14. sky/dashboard/out/_next/static/chunks/{4937.d6bf67771e353356.js → 4937.a2baa2df5572a276.js} +1 -1
  15. sky/dashboard/out/_next/static/chunks/6130-2be46d70a38f1e82.js +1 -0
  16. sky/dashboard/out/_next/static/chunks/6601-3e21152fe16da09c.js +1 -0
  17. sky/dashboard/out/_next/static/chunks/{691.6d99cbfba347cebf.js → 691.5eeedf82cc243343.js} +1 -1
  18. sky/dashboard/out/_next/static/chunks/6989-6129c1cfbcf51063.js +1 -0
  19. sky/dashboard/out/_next/static/chunks/6990-0f886f16e0d55ff8.js +1 -0
  20. sky/dashboard/out/_next/static/chunks/8056-019615038d6ce427.js +1 -0
  21. sky/dashboard/out/_next/static/chunks/8252.62b0d23aed618bb2.js +16 -0
  22. sky/dashboard/out/_next/static/chunks/8969-318c3dca725e8e5d.js +1 -0
  23. sky/dashboard/out/_next/static/chunks/9025.a1bef12d672bb66d.js +6 -0
  24. sky/dashboard/out/_next/static/chunks/9159-11421c0f2909236f.js +1 -0
  25. sky/dashboard/out/_next/static/chunks/9360.85b0b1b4054574dd.js +31 -0
  26. sky/dashboard/out/_next/static/chunks/9666.cd4273f2a5c5802c.js +1 -0
  27. sky/dashboard/out/_next/static/chunks/{9847.4c46c5e229c78704.js → 9847.757720f3b40c0aa5.js} +1 -1
  28. sky/dashboard/out/_next/static/chunks/pages/{_app-2a43ea3241bbdacd.js → _app-1e6de35d15a8d432.js} +1 -1
  29. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-6fd1d2d8441aa54b.js +11 -0
  30. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-155d477a6c3e04e2.js +1 -0
  31. sky/dashboard/out/_next/static/chunks/pages/{clusters-47f1ddae13a2f8e4.js → clusters-b30460f683e6ba96.js} +1 -1
  32. sky/dashboard/out/_next/static/chunks/pages/config-dfb9bf07b13045f4.js +1 -0
  33. sky/dashboard/out/_next/static/chunks/pages/infra/{[context]-2a44e70b500b6b70.js → [context]-13d53fffc03ccb52.js} +1 -1
  34. sky/dashboard/out/_next/static/chunks/pages/{infra-22faac9325016d83.js → infra-fc9222e26c8e2f0d.js} +1 -1
  35. sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-154f55cf8af55be5.js +11 -0
  36. sky/dashboard/out/_next/static/chunks/pages/jobs/pools/[pool]-f5ccf5d39d87aebe.js +21 -0
  37. sky/dashboard/out/_next/static/chunks/pages/jobs-cdc60fb5d371e16a.js +1 -0
  38. sky/dashboard/out/_next/static/chunks/pages/{users-b90c865a690bfe84.js → users-7ed36e44e779d5c7.js} +1 -1
  39. sky/dashboard/out/_next/static/chunks/pages/{volumes-7af733f5d7b6ed1c.js → volumes-c9695d657f78b5dc.js} +1 -1
  40. sky/dashboard/out/_next/static/chunks/pages/workspace/new-3f88a1c7e86a3f86.js +1 -0
  41. sky/dashboard/out/_next/static/chunks/pages/workspaces/[name]-f72f73bcef9541dc.js +1 -0
  42. sky/dashboard/out/_next/static/chunks/pages/workspaces-8f67be60165724cc.js +1 -0
  43. sky/dashboard/out/_next/static/chunks/webpack-76efbdad99742559.js +1 -0
  44. sky/dashboard/out/_next/static/css/4614e06482d7309e.css +3 -0
  45. sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
  46. sky/dashboard/out/clusters/[cluster].html +1 -1
  47. sky/dashboard/out/clusters.html +1 -1
  48. sky/dashboard/out/config.html +1 -1
  49. sky/dashboard/out/index.html +1 -1
  50. sky/dashboard/out/infra/[context].html +1 -1
  51. sky/dashboard/out/infra.html +1 -1
  52. sky/dashboard/out/jobs/[job].html +1 -1
  53. sky/dashboard/out/jobs/pools/[pool].html +1 -0
  54. sky/dashboard/out/jobs.html +1 -1
  55. sky/dashboard/out/users.html +1 -1
  56. sky/dashboard/out/volumes.html +1 -1
  57. sky/dashboard/out/workspace/new.html +1 -1
  58. sky/dashboard/out/workspaces/[name].html +1 -1
  59. sky/dashboard/out/workspaces.html +1 -1
  60. sky/global_user_state.py +14 -2
  61. sky/jobs/__init__.py +2 -0
  62. sky/jobs/client/sdk.py +43 -2
  63. sky/jobs/server/core.py +48 -1
  64. sky/jobs/server/server.py +52 -3
  65. sky/jobs/state.py +5 -1
  66. sky/schemas/db/global_user_state/002_add_workspace_to_cluster_history.py +35 -0
  67. sky/schemas/db/spot_jobs/003_pool_hash.py +34 -0
  68. sky/serve/client/impl.py +85 -1
  69. sky/serve/client/sdk.py +16 -47
  70. sky/serve/constants.py +2 -1
  71. sky/serve/controller.py +4 -2
  72. sky/serve/serve_state.py +28 -5
  73. sky/serve/serve_utils.py +77 -46
  74. sky/serve/server/core.py +13 -197
  75. sky/serve/server/impl.py +239 -2
  76. sky/serve/service.py +8 -3
  77. sky/server/common.py +11 -4
  78. sky/server/constants.py +1 -1
  79. sky/server/requests/executor.py +5 -3
  80. sky/server/requests/payloads.py +19 -0
  81. sky/task.py +18 -11
  82. sky/templates/kubernetes-ray.yml.j2 +5 -0
  83. sky/templates/sky-serve-controller.yaml.j2 +1 -0
  84. sky/usage/usage_lib.py +8 -6
  85. sky/utils/annotations.py +8 -3
  86. sky/utils/common_utils.py +11 -1
  87. sky/utils/db/migration_utils.py +2 -2
  88. {skypilot_nightly-1.0.0.dev20250806.dist-info → skypilot_nightly-1.0.0.dev20250807.dist-info}/METADATA +18 -13
  89. {skypilot_nightly-1.0.0.dev20250806.dist-info → skypilot_nightly-1.0.0.dev20250807.dist-info}/RECORD +95 -92
  90. sky/client/sdk.pyi +0 -301
  91. sky/dashboard/out/_next/static/Gelsd19kVxXcX7aQQGsGu/_buildManifest.js +0 -1
  92. sky/dashboard/out/_next/static/chunks/1043-75af48ca5d5aaf57.js +0 -1
  93. sky/dashboard/out/_next/static/chunks/1141-8678a9102cc5f67e.js +0 -11
  94. sky/dashboard/out/_next/static/chunks/1664-22b00e32c9ff96a4.js +0 -1
  95. sky/dashboard/out/_next/static/chunks/1871-ced1c14230cad6e1.js +0 -6
  96. sky/dashboard/out/_next/static/chunks/2003.f90b06bb1f914295.js +0 -1
  97. sky/dashboard/out/_next/static/chunks/2350.fab69e61bac57b23.js +0 -1
  98. sky/dashboard/out/_next/static/chunks/2622-951867535095b0eb.js +0 -1
  99. sky/dashboard/out/_next/static/chunks/3785.0a173cd4393f0fef.js +0 -1
  100. sky/dashboard/out/_next/static/chunks/4725.42f21f250f91f65b.js +0 -1
  101. sky/dashboard/out/_next/static/chunks/4869.18e6a4361a380763.js +0 -16
  102. sky/dashboard/out/_next/static/chunks/5230-f3bb2663e442e86c.js +0 -1
  103. sky/dashboard/out/_next/static/chunks/6601-2109d22e7861861c.js +0 -1
  104. sky/dashboard/out/_next/static/chunks/6990-08b2a1cae076a943.js +0 -1
  105. sky/dashboard/out/_next/static/chunks/8969-9a8cca241b30db83.js +0 -1
  106. sky/dashboard/out/_next/static/chunks/9025.99f29acb7617963e.js +0 -6
  107. sky/dashboard/out/_next/static/chunks/938-bda2685db5eae6cf.js +0 -1
  108. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-7cb24da04ca00956.js +0 -11
  109. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-1e95993124dbfc57.js +0 -1
  110. sky/dashboard/out/_next/static/chunks/pages/config-d56e64f30db7b42e.js +0 -1
  111. sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-90693cb88b5599a7.js +0 -11
  112. sky/dashboard/out/_next/static/chunks/pages/jobs-ab318e52eb4424a7.js +0 -1
  113. sky/dashboard/out/_next/static/chunks/pages/workspace/new-92f741084a89e27b.js +0 -1
  114. sky/dashboard/out/_next/static/chunks/pages/workspaces/[name]-35e0de5bca55e594.js +0 -1
  115. sky/dashboard/out/_next/static/chunks/pages/workspaces-062525fb5462acb6.js +0 -1
  116. sky/dashboard/out/_next/static/chunks/webpack-387626669badf82e.js +0 -1
  117. sky/dashboard/out/_next/static/css/b3227360726f12eb.css +0 -3
  118. /sky/dashboard/out/_next/static/{Gelsd19kVxXcX7aQQGsGu → YAirOGsV1z6B2RJ0VIUmD}/_ssgManifest.js +0 -0
  119. /sky/dashboard/out/_next/static/chunks/{6135-2d7ed3350659d073.js → 6135-85426374db04811e.js} +0 -0
  120. {skypilot_nightly-1.0.0.dev20250806.dist-info → skypilot_nightly-1.0.0.dev20250807.dist-info}/WHEEL +0 -0
  121. {skypilot_nightly-1.0.0.dev20250806.dist-info → skypilot_nightly-1.0.0.dev20250807.dist-info}/entry_points.txt +0 -0
  122. {skypilot_nightly-1.0.0.dev20250806.dist-info → skypilot_nightly-1.0.0.dev20250807.dist-info}/licenses/LICENSE +0 -0
  123. {skypilot_nightly-1.0.0.dev20250806.dist-info → skypilot_nightly-1.0.0.dev20250807.dist-info}/top_level.txt +0 -0
sky/__init__.py CHANGED
@@ -5,7 +5,7 @@ from typing import Optional
5
5
  import urllib.request
6
6
 
7
7
  # Replaced with the current commit when building the wheels.
8
- _SKYPILOT_COMMIT_SHA = '57784d97d8d63f3c87f4d5d22f3e820b10154241'
8
+ _SKYPILOT_COMMIT_SHA = 'a167cba8230b0ffda6baa0c825fa0eb5d5ab4aa4'
9
9
 
10
10
 
11
11
  def _get_git_commit():
@@ -35,7 +35,7 @@ def _get_git_commit():
35
35
 
36
36
 
37
37
  __commit__ = _get_git_commit()
38
- __version__ = '1.0.0.dev20250806'
38
+ __version__ = '1.0.0.dev20250807'
39
39
  __root_dir__ = os.path.dirname(os.path.abspath(__file__))
40
40
 
41
41
 
@@ -168,6 +168,9 @@ _MAX_INLINE_SCRIPT_LENGTH = 100 * 1024
168
168
  _RESOURCES_UNAVAILABLE_LOG = (
169
169
  'Reasons for provision failures (for details, please check the log above):')
170
170
 
171
+ # Number of seconds to wait locking the cluster before communicating with user.
172
+ _CLUSTER_LOCK_TIMEOUT = 5.0
173
+
171
174
 
172
175
  def _is_command_length_over_limit(command: str) -> bool:
173
176
  """Check if the length of the command exceeds the limit.
@@ -2917,10 +2920,36 @@ class CloudVmRayBackend(backends.Backend['CloudVmRayResourceHandle']):
2917
2920
  # exceptions.ClusterOwnerIdentityMismatchError
2918
2921
  backend_utils.check_owner_identity(cluster_name)
2919
2922
  lock_id = backend_utils.cluster_status_lock_id(cluster_name)
2920
- with timeline.DistributedLockEvent(lock_id):
2921
- # Try to launch the exiting cluster first. If no existing cluster,
2922
- # this function will create a to_provision_config with required
2923
- # resources.
2923
+ communicated_with_user = False
2924
+
2925
+ while True:
2926
+ try:
2927
+ return self._locked_provision(lock_id, task, to_provision,
2928
+ dryrun, stream_logs, cluster_name,
2929
+ retry_until_up,
2930
+ skip_unnecessary_provisioning)
2931
+ except locks.LockTimeout:
2932
+ if not communicated_with_user:
2933
+ logger.info(f'{colorama.Fore.YELLOW}'
2934
+ f'Launching delayed, check concurrent tasks: '
2935
+ f'sky api status')
2936
+ communicated_with_user = True
2937
+
2938
+ def _locked_provision(
2939
+ self,
2940
+ lock_id: str,
2941
+ task: task_lib.Task,
2942
+ to_provision: Optional[resources_lib.Resources],
2943
+ dryrun: bool,
2944
+ stream_logs: bool,
2945
+ cluster_name: str,
2946
+ retry_until_up: bool = False,
2947
+ skip_unnecessary_provisioning: bool = False,
2948
+ ) -> Tuple[Optional[CloudVmRayResourceHandle], bool]:
2949
+ with timeline.DistributedLockEvent(lock_id, _CLUSTER_LOCK_TIMEOUT):
2950
+ # Try to launch the exiting cluster first. If no existing
2951
+ # cluster, this function will create a to_provision_config
2952
+ # with required resources.
2924
2953
  to_provision_config = self._check_existing_cluster(
2925
2954
  task, to_provision, cluster_name, dryrun)
2926
2955
  assert to_provision_config.resources is not None, (
sky/check.py CHANGED
@@ -467,8 +467,18 @@ def _print_checked_cloud(
467
467
  if ok:
468
468
  enabled_capabilities.append(capability)
469
469
  # `dict` reasons for K8s and SSH will be printed in detail in
470
- # _format_enabled_cloud. Skip here.
470
+ # _format_enabled_cloud. Skip here unless the cloud is disabled.
471
471
  if not isinstance(reason, str):
472
+ if not ok and isinstance(cloud_tuple[1],
473
+ (sky_clouds.SSH, sky_clouds.Kubernetes)):
474
+ if reason is not None:
475
+ reason_str = _format_context_details(cloud_tuple[1],
476
+ show_details=True,
477
+ ctx2text=reason)
478
+ reason_str = '\n'.join(
479
+ ' ' + line for line in reason_str.splitlines())
480
+ reasons_to_capabilities.setdefault(reason_str,
481
+ []).append(capability)
472
482
  continue
473
483
  if ok:
474
484
  if reason is not None:
sky/client/cli/command.py CHANGED
@@ -4972,6 +4972,205 @@ def jobs_pool_down(
4972
4972
  _async_call_or_wait(request_id, async_call, 'sky.jobs.pool_down')
4973
4973
 
4974
4974
 
4975
+ def _handle_serve_logs(
4976
+ service_name: str,
4977
+ follow: bool,
4978
+ controller: bool,
4979
+ load_balancer: bool,
4980
+ replica_ids: Tuple[int, ...],
4981
+ sync_down: bool,
4982
+ tail: Optional[int],
4983
+ pool: bool, # pylint: disable=redefined-outer-name
4984
+ ):
4985
+ noun = 'pool' if pool else 'service'
4986
+ capnoun = noun.capitalize()
4987
+ repnoun = 'worker' if pool else 'replica'
4988
+ if tail is not None:
4989
+ if tail < 0:
4990
+ raise click.UsageError('--tail must be a non-negative integer.')
4991
+ # TODO(arda): We could add ability to tail and follow logs together.
4992
+ if follow:
4993
+ follow = False
4994
+ logger.warning(
4995
+ f'{colorama.Fore.YELLOW}'
4996
+ '--tail and --follow cannot be used together. '
4997
+ f'Changed the mode to --no-follow.{colorama.Style.RESET_ALL}')
4998
+
4999
+ chosen_components: Set[serve_lib.ServiceComponent] = set()
5000
+ if controller:
5001
+ chosen_components.add(serve_lib.ServiceComponent.CONTROLLER)
5002
+ if load_balancer:
5003
+ assert not pool, 'Load balancer is not supported for pools.'
5004
+ chosen_components.add(serve_lib.ServiceComponent.LOAD_BALANCER)
5005
+ # replica_ids contains the specific replica IDs provided by the user.
5006
+ # If it's not empty, it implies the user wants replica logs.
5007
+ if replica_ids:
5008
+ chosen_components.add(serve_lib.ServiceComponent.REPLICA)
5009
+
5010
+ if sync_down:
5011
+ # For sync-down, multiple targets are allowed.
5012
+ # If no specific components/replicas are mentioned, sync all.
5013
+ # Note: Multiple replicas or targets can only be specified when
5014
+ # using --sync-down.
5015
+ targets_to_sync = list(chosen_components)
5016
+ if not targets_to_sync and not replica_ids:
5017
+ # Default to all components if nothing specific is requested
5018
+ targets_to_sync = [
5019
+ serve_lib.ServiceComponent.CONTROLLER,
5020
+ serve_lib.ServiceComponent.REPLICA,
5021
+ ]
5022
+ if not pool:
5023
+ targets_to_sync.append(serve_lib.ServiceComponent.LOAD_BALANCER)
5024
+
5025
+ timestamp = sky_logging.get_run_timestamp()
5026
+ log_dir = (pathlib.Path(constants.SKY_LOGS_DIRECTORY) / noun /
5027
+ f'{service_name}_{timestamp}').expanduser()
5028
+ log_dir.mkdir(parents=True, exist_ok=True)
5029
+
5030
+ with rich_utils.client_status(
5031
+ ux_utils.spinner_message(f'Downloading {noun} logs...')):
5032
+ if pool:
5033
+ managed_jobs.pool_sync_down_logs(service_name,
5034
+ str(log_dir),
5035
+ targets=targets_to_sync,
5036
+ worker_ids=list(replica_ids),
5037
+ tail=tail)
5038
+ else:
5039
+ serve_lib.sync_down_logs(service_name,
5040
+ str(log_dir),
5041
+ targets=targets_to_sync,
5042
+ replica_ids=list(replica_ids),
5043
+ tail=tail)
5044
+ style = colorama.Style
5045
+ fore = colorama.Fore
5046
+ logger.info(f'{fore.CYAN}{capnoun} {service_name} logs: '
5047
+ f'{log_dir}{style.RESET_ALL}')
5048
+ return
5049
+
5050
+ # Tailing requires exactly one target.
5051
+ num_targets = len(chosen_components)
5052
+ # If REPLICA component is chosen, len(replica_ids) must be 1 for tailing.
5053
+ if serve_lib.ServiceComponent.REPLICA in chosen_components:
5054
+ if len(replica_ids) != 1:
5055
+ raise click.UsageError(
5056
+ f'Can only tail logs from a single {repnoun} at a time. '
5057
+ f'Provide exactly one {repnoun.upper()}_ID or use --sync-down '
5058
+ f'to download logs from multiple {repnoun}s.')
5059
+ # If replica is chosen and len is 1, num_targets effectively counts it.
5060
+ # We need to ensure no other component (controller/LB) is selected.
5061
+ if num_targets > 1:
5062
+ raise click.UsageError(
5063
+ 'Can only tail logs from one target at a time (controller, '
5064
+ f'load balancer, or a single {repnoun}). Use --sync-down '
5065
+ 'to download logs from multiple sources.')
5066
+ elif num_targets == 0:
5067
+ raise click.UsageError(
5068
+ 'Specify a target to tail: --controller, --load-balancer, or '
5069
+ f'a {repnoun.upper()}_ID.')
5070
+ elif num_targets > 1:
5071
+ raise click.UsageError(
5072
+ 'Can only tail logs from one target at a time. Use --sync-down '
5073
+ 'to download logs from multiple sources.')
5074
+
5075
+ # At this point, we have exactly one target for tailing.
5076
+ assert len(chosen_components) == 1
5077
+ assert len(replica_ids) in [0, 1]
5078
+ target_component = chosen_components.pop()
5079
+ target_replica_id: Optional[int] = replica_ids[0] if replica_ids else None
5080
+
5081
+ try:
5082
+ if pool:
5083
+ managed_jobs.pool_tail_logs(service_name,
5084
+ target=target_component,
5085
+ worker_id=target_replica_id,
5086
+ follow=follow,
5087
+ tail=tail)
5088
+ else:
5089
+ serve_lib.tail_logs(service_name,
5090
+ target=target_component,
5091
+ replica_id=target_replica_id,
5092
+ follow=follow,
5093
+ tail=tail)
5094
+ except exceptions.ClusterNotUpError:
5095
+ with ux_utils.print_exception_no_traceback():
5096
+ raise
5097
+
5098
+
5099
+ @pool.command('logs', cls=_DocumentedCodeCommand)
5100
+ @flags.config_option(expose_value=False)
5101
+ @click.option(
5102
+ '--follow/--no-follow',
5103
+ is_flag=True,
5104
+ default=True,
5105
+ help=('Follow the logs of the job. [default: --follow] '
5106
+ 'If --no-follow is specified, print the log so far and exit.'))
5107
+ @click.option('--controller',
5108
+ is_flag=True,
5109
+ default=False,
5110
+ required=False,
5111
+ help='Show the controller logs of this pool.')
5112
+ @click.option('--sync-down',
5113
+ '-s',
5114
+ is_flag=True,
5115
+ default=False,
5116
+ help='Sync down logs to the local machine. Can be combined with '
5117
+ '--controller or worker ID to narrow scope.')
5118
+ @click.option(
5119
+ '--tail',
5120
+ default=None,
5121
+ type=int,
5122
+ help='The number of lines to display from the end of the log file. '
5123
+ 'Default is None, which means print all lines.')
5124
+ @click.argument('pool_name', required=True, type=str)
5125
+ @click.argument('worker_ids', required=False, type=int, nargs=-1)
5126
+ @usage_lib.entrypoint
5127
+ # TODO(tian): Add default argument for this CLI if none of the flags are
5128
+ # specified.
5129
+ def pool_logs(
5130
+ pool_name: str,
5131
+ follow: bool,
5132
+ controller: bool,
5133
+ worker_ids: Tuple[int, ...],
5134
+ sync_down: bool,
5135
+ tail: Optional[int],
5136
+ ):
5137
+ """Tail or sync down logs of a pool.
5138
+
5139
+ Logs can be tailed from one target (controller, or a single worker) or
5140
+ synced down from multiple targets simultaneously.
5141
+
5142
+ Example:
5143
+
5144
+ .. code-block:: bash
5145
+
5146
+ # Tail the controller logs of a pool
5147
+ sky pool logs --controller [POOL_NAME]
5148
+ \b
5149
+ # Print the worker logs so far and exit
5150
+ sky pool logs --no-follow [POOL_NAME]
5151
+ \b
5152
+ # Tail the logs of worker 1
5153
+ sky pool logs [POOL_NAME] 1
5154
+ \b
5155
+ # Show the last 100 lines of the controller logs
5156
+ sky pool logs --controller --tail 100 [POOL_NAME]
5157
+ \b
5158
+ # Sync down all logs of the pool (controller, all workers)
5159
+ sky pool logs [POOL_NAME] --sync-down
5160
+ \b
5161
+ # Sync down controller logs and logs for workers 1 and 3
5162
+ sky pool logs [POOL_NAME] 1 3 --controller --sync-down
5163
+ """
5164
+ _handle_serve_logs(pool_name,
5165
+ follow=follow,
5166
+ controller=controller,
5167
+ load_balancer=False,
5168
+ replica_ids=worker_ids,
5169
+ sync_down=sync_down,
5170
+ tail=tail,
5171
+ pool=True)
5172
+
5173
+
4975
5174
  @cli.command(cls=_DocumentedCodeCommand)
4976
5175
  @flags.config_option(expose_value=False)
4977
5176
  @usage_lib.entrypoint
@@ -5555,6 +5754,7 @@ def serve_down(
5555
5754
  show_default=True)
5556
5755
 
5557
5756
  if replica_id_is_defined:
5757
+ assert replica_id is not None
5558
5758
  request_id = serve_lib.terminate_replica(service_names[0], replica_id,
5559
5759
  purge)
5560
5760
  else:
@@ -5635,99 +5835,14 @@ def serve_logs(
5635
5835
  # Sync down controller logs and logs for replicas 1 and 3
5636
5836
  sky serve logs [SERVICE_NAME] 1 3 --controller --sync-down
5637
5837
  """
5638
- if tail is not None:
5639
- if tail < 0:
5640
- raise click.UsageError('--tail must be a non-negative integer.')
5641
- # TODO(arda): We could add ability to tail and follow logs together.
5642
- if follow:
5643
- follow = False
5644
- logger.warning(
5645
- f'{colorama.Fore.YELLOW}'
5646
- '--tail and --follow cannot be used together. '
5647
- f'Changed the mode to --no-follow.{colorama.Style.RESET_ALL}')
5648
-
5649
- chosen_components: Set[serve_lib.ServiceComponent] = set()
5650
- if controller:
5651
- chosen_components.add(serve_lib.ServiceComponent.CONTROLLER)
5652
- if load_balancer:
5653
- chosen_components.add(serve_lib.ServiceComponent.LOAD_BALANCER)
5654
- # replica_ids contains the specific replica IDs provided by the user.
5655
- # If it's not empty, it implies the user wants replica logs.
5656
- if replica_ids:
5657
- chosen_components.add(serve_lib.ServiceComponent.REPLICA)
5658
-
5659
- if sync_down:
5660
- # For sync-down, multiple targets are allowed.
5661
- # If no specific components/replicas are mentioned, sync all.
5662
- # Note: Multiple replicas or targets can only be specified when
5663
- # using --sync-down.
5664
- targets_to_sync = list(chosen_components)
5665
- if not targets_to_sync and not replica_ids:
5666
- # Default to all components if nothing specific is requested
5667
- targets_to_sync = [
5668
- serve_lib.ServiceComponent.CONTROLLER,
5669
- serve_lib.ServiceComponent.LOAD_BALANCER,
5670
- serve_lib.ServiceComponent.REPLICA,
5671
- ]
5672
-
5673
- timestamp = sky_logging.get_run_timestamp()
5674
- log_dir = (pathlib.Path(constants.SKY_LOGS_DIRECTORY) / 'service' /
5675
- f'{service_name}_{timestamp}').expanduser()
5676
- log_dir.mkdir(parents=True, exist_ok=True)
5677
-
5678
- with rich_utils.client_status(
5679
- ux_utils.spinner_message('Downloading service logs...')):
5680
- serve_lib.sync_down_logs(service_name,
5681
- local_dir=str(log_dir),
5682
- targets=targets_to_sync,
5683
- replica_ids=list(replica_ids),
5684
- tail=tail)
5685
- style = colorama.Style
5686
- fore = colorama.Fore
5687
- logger.info(f'{fore.CYAN}Service {service_name} logs: '
5688
- f'{log_dir}{style.RESET_ALL}')
5689
- return
5690
-
5691
- # Tailing requires exactly one target.
5692
- num_targets = len(chosen_components)
5693
- # If REPLICA component is chosen, len(replica_ids) must be 1 for tailing.
5694
- if serve_lib.ServiceComponent.REPLICA in chosen_components:
5695
- if len(replica_ids) != 1:
5696
- raise click.UsageError(
5697
- 'Can only tail logs from a single replica at a time. '
5698
- 'Provide exactly one REPLICA_ID or use --sync-down '
5699
- 'to download logs from multiple replicas.')
5700
- # If replica is chosen and len is 1, num_targets effectively counts it.
5701
- # We need to ensure no other component (controller/LB) is selected.
5702
- if num_targets > 1:
5703
- raise click.UsageError(
5704
- 'Can only tail logs from one target at a time (controller, '
5705
- 'load balancer, or a single replica). Use --sync-down '
5706
- 'to download logs from multiple sources.')
5707
- elif num_targets == 0:
5708
- raise click.UsageError(
5709
- 'Specify a target to tail: --controller, --load-balancer, or '
5710
- 'a REPLICA_ID.')
5711
- elif num_targets > 1:
5712
- raise click.UsageError(
5713
- 'Can only tail logs from one target at a time. Use --sync-down '
5714
- 'to download logs from multiple sources.')
5715
-
5716
- # At this point, we have exactly one target for tailing.
5717
- assert len(chosen_components) == 1
5718
- assert len(replica_ids) in [0, 1]
5719
- target_component = chosen_components.pop()
5720
- target_replica_id: Optional[int] = replica_ids[0] if replica_ids else None
5721
-
5722
- try:
5723
- serve_lib.tail_logs(service_name,
5724
- target=target_component,
5725
- replica_id=target_replica_id,
5726
- follow=follow,
5727
- tail=tail)
5728
- except exceptions.ClusterNotUpError:
5729
- with ux_utils.print_exception_no_traceback():
5730
- raise
5838
+ _handle_serve_logs(service_name,
5839
+ follow=follow,
5840
+ controller=controller,
5841
+ load_balancer=load_balancer,
5842
+ replica_ids=replica_ids,
5843
+ sync_down=sync_down,
5844
+ tail=tail,
5845
+ pool=False)
5731
5846
 
5732
5847
 
5733
5848
  @cli.group(cls=_NaturalOrderGroup, hidden=True)
sky/client/sdk.py CHANGED
@@ -352,7 +352,14 @@ def validate(
352
352
  validation. This is only required when a admin policy is in use,
353
353
  see: https://docs.skypilot.co/en/latest/cloud-setup/policy.html
354
354
  """
355
+ remote_api_version = versions.get_remote_api_version()
356
+ # TODO(kevin): remove this in v0.13.0
357
+ omit_user_specified_yaml = (remote_api_version is None or
358
+ remote_api_version < 15)
355
359
  for task in dag.tasks:
360
+ if omit_user_specified_yaml:
361
+ # pylint: disable=protected-access
362
+ task._user_specified_yaml = None
356
363
  task.expand_and_validate_workdir()
357
364
  if not workdir_only:
358
365
  task.expand_and_validate_file_mounts()
@@ -1874,6 +1881,10 @@ def stream_and_get(
1874
1881
  with ux_utils.print_exception_no_traceback():
1875
1882
  raise RuntimeError(f'Failed to stream logs: {detail}')
1876
1883
  elif response.status_code != 200:
1884
+ # TODO(syang): handle the case where the requestID is not provided
1885
+ # see https://github.com/skypilot-org/skypilot/issues/6549
1886
+ if request_id is None:
1887
+ return None
1877
1888
  return get(request_id)
1878
1889
  return stream_response(request_id, response, output_stream)
1879
1890
 
@@ -2420,7 +2431,9 @@ def api_login(endpoint: Optional[str] = None,
2420
2431
  _save_config_updates(endpoint=endpoint)
2421
2432
  dashboard_url = server_common.get_dashboard_url(endpoint)
2422
2433
 
2423
- server_common.get_api_server_status.cache_clear()
2434
+ # see https://github.com/python/mypy/issues/5107 on why
2435
+ # typing is disabled on this line
2436
+ server_common.get_api_server_status.cache_clear() # type: ignore
2424
2437
  # After successful authentication, check server health again to get user
2425
2438
  # identity
2426
2439
  server_status, final_api_server_info = server_common.check_server_healthy(
sky/client/sdk_async.py CHANGED
@@ -244,6 +244,10 @@ async def stream_and_get(
244
244
  with ux_utils.print_exception_no_traceback():
245
245
  raise RuntimeError(f'Failed to stream logs: {detail}')
246
246
  elif response.status != 200:
247
+ # TODO(syang): handle the case where the requestID is not
248
+ # provided. https://github.com/skypilot-org/skypilot/issues/6549
249
+ if request_id is None:
250
+ return None
247
251
  return await get(request_id)
248
252
 
249
253
  return await stream_response_async(request_id, response,
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/dashboard/_next/static/css/b3227360726f12eb.css" as="style"/><link rel="stylesheet" href="/dashboard/_next/static/css/b3227360726f12eb.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/dashboard/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js"></script><script src="/dashboard/_next/static/chunks/webpack-387626669badf82e.js" defer=""></script><script src="/dashboard/_next/static/chunks/framework-cf60a09ccd051a10.js" defer=""></script><script src="/dashboard/_next/static/chunks/main-f15ccb73239a3bf1.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_app-2a43ea3241bbdacd.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_error-c66a4e8afc46f17b.js" defer=""></script><script src="/dashboard/_next/static/Gelsd19kVxXcX7aQQGsGu/_buildManifest.js" defer=""></script><script src="/dashboard/_next/static/Gelsd19kVxXcX7aQQGsGu/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"Gelsd19kVxXcX7aQQGsGu","assetPrefix":"/dashboard","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/dashboard/_next/static/css/4614e06482d7309e.css" as="style"/><link rel="stylesheet" href="/dashboard/_next/static/css/4614e06482d7309e.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/dashboard/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js"></script><script src="/dashboard/_next/static/chunks/webpack-76efbdad99742559.js" defer=""></script><script src="/dashboard/_next/static/chunks/framework-cf60a09ccd051a10.js" defer=""></script><script src="/dashboard/_next/static/chunks/main-f15ccb73239a3bf1.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_app-1e6de35d15a8d432.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_error-c66a4e8afc46f17b.js" defer=""></script><script src="/dashboard/_next/static/YAirOGsV1z6B2RJ0VIUmD/_buildManifest.js" defer=""></script><script src="/dashboard/_next/static/YAirOGsV1z6B2RJ0VIUmD/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"YAirOGsV1z6B2RJ0VIUmD","assetPrefix":"/dashboard","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -0,0 +1 @@
1
+ self.__BUILD_MANIFEST=function(s,c,e,a,t,f,u,n,o,r,j,i,b,k,h){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":["static/chunks/pages/index-444f1804401f04ea.js"],"/_error":["static/chunks/pages/_error-c66a4e8afc46f17b.js"],"/clusters":["static/chunks/pages/clusters-b30460f683e6ba96.js"],"/clusters/[cluster]":[s,c,e,f,u,j,r,a,t,n,i,b,o,k,h,"static/chunks/1871-980a395e92633a5c.js","static/chunks/pages/clusters/[cluster]-155d477a6c3e04e2.js"],"/clusters/[cluster]/[job]":[s,c,e,f,a,t,o,"static/chunks/pages/clusters/[cluster]/[job]-6fd1d2d8441aa54b.js"],"/config":["static/chunks/pages/config-dfb9bf07b13045f4.js"],"/infra":["static/chunks/pages/infra-fc9222e26c8e2f0d.js"],"/infra/[context]":["static/chunks/pages/infra/[context]-13d53fffc03ccb52.js"],"/jobs":["static/chunks/pages/jobs-cdc60fb5d371e16a.js"],"/jobs/pools/[pool]":[s,c,e,u,r,a,t,n,"static/chunks/pages/jobs/pools/[pool]-f5ccf5d39d87aebe.js"],"/jobs/[job]":[s,c,e,f,u,r,a,t,n,o,"static/chunks/pages/jobs/[job]-154f55cf8af55be5.js"],"/users":["static/chunks/pages/users-7ed36e44e779d5c7.js"],"/volumes":["static/chunks/pages/volumes-c9695d657f78b5dc.js"],"/workspace/new":["static/chunks/pages/workspace/new-3f88a1c7e86a3f86.js"],"/workspaces":["static/chunks/pages/workspaces-8f67be60165724cc.js"],"/workspaces/[name]":[s,c,e,f,u,j,a,t,n,i,b,o,k,h,"static/chunks/1141-a8a8f1adba34c892.js","static/chunks/pages/workspaces/[name]-f72f73bcef9541dc.js"],sortedPages:["/","/_app","/_error","/clusters","/clusters/[cluster]","/clusters/[cluster]/[job]","/config","/infra","/infra/[context]","/jobs","/jobs/pools/[pool]","/jobs/[job]","/users","/volumes","/workspace/new","/workspaces","/workspaces/[name]"]}}("static/chunks/616-3d59f75e2ccf9321.js","static/chunks/6130-2be46d70a38f1e82.js","static/chunks/5739-d67458fcb1386c92.js","static/chunks/6989-6129c1cfbcf51063.js","static/chunks/3850-ff4a9a69d978632b.js","static/chunks/7411-b15471acd2cba716.js","static/chunks/1272-1ef0bf0237faccdb.js","static/chunks/8969-318c3dca725e8e5d.js","static/chunks/6135-85426374db04811e.js","static/chunks/6212-7bd06f60ba693125.js","static/chunks/1559-6c00e20454194859.js","static/chunks/6990-0f886f16e0d55ff8.js","static/chunks/8056-019615038d6ce427.js","static/chunks/6601-3e21152fe16da09c.js","static/chunks/9159-11421c0f2909236f.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -0,0 +1,11 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1141],{99333:function(e,s,r){r.d(s,{Z:function(){return t}});/**
2
+ * @license lucide-react v0.407.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */let t=(0,r(60998).Z)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},98418:function(e,s,r){r.d(s,{Z:function(){return t}});/**
7
+ * @license lucide-react v0.407.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */let t=(0,r(60998).Z)("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]])},1812:function(e,s,r){r.d(s,{X:function(){return n}});var t=r(85893),a=r(67294);let l=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let s=e.message;return s.includes("failed:")&&(s=s.split("failed:")[1].trim()),s},n=e=>{let{error:s,title:r="Error",onDismiss:n}=e,[c,i]=(0,a.useState)(!1);if((0,a.useEffect)(()=>{s&&i(!1)},[s]),!s||c)return null;let o="string"==typeof s?s:l(s);return(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,t.jsx)("div",{className:"ml-3",children:(0,t.jsxs)("div",{className:"text-sm text-red-800",children:[(0,t.jsxs)("strong",{children:[r,":"]})," ",o]})})]}),(0,t.jsx)("button",{onClick:()=>{i(!0),n&&n()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,t.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},69123:function(e,s,r){r.d(s,{g:function(){return n}});var t=r(85893),a=r(67294),l=r(32350);let n=a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),ref:s,...a})});n.displayName="Textarea"},11141:function(e,s,r){r.r(s),r.d(s,{WorkspaceEditor:function(){return R}});var t=r(85893),a=r(67294),l=r(11163),n=r(17324),c=r(23266),i=r(68969);r(6135);var o=r(41664),d=r.n(o),u=r(9008),x=r.n(u),m=r(37673),h=r(30803),f=r(69123),g=r(55739),p=r(70282),b=r(6021),j=r(13626),y=r(98418),N=r(99333),v=r(50326);let w=e=>{let{className:s="",variant:r="default",children:a,...l}=e;return(0,t.jsx)("div",{role:"alert",className:"".concat("relative w-full rounded-lg border p-4 flex items-start space-x-2"," ").concat({default:"bg-blue-50 border-blue-200 text-blue-800",destructive:"bg-red-50 border-red-200 text-red-800"}[r]," ").concat(s),...l,children:a})},k=e=>{let{className:s="",children:r,...a}=e;return(0,t.jsx)("div",{className:"text-sm leading-relaxed ".concat(s),...a,children:r})};var C=r(53850),L=r(1812),S=r(9159),E=r(1272),A=r(93225),W=r(53081);let Z=e=>{let{message:s}=e;return s?(0,t.jsxs)(w,{className:"border-green-200 bg-green-50",children:[(0,t.jsx)(p.Z,{className:"h-4 w-4 text-green-600"}),(0,t.jsx)(k,{className:"text-green-800",children:s})]}):null},D=e=>{let{workspaceName:s,config:r,enabledClouds:a=[]}=e;if(!r)return null;let l="default"===s,n=0===Object.keys(r).length;if(l&&n)return(0,t.jsx)("div",{className:"text-sm text-gray-500 mb-3 italic p-3 bg-sky-50 rounded border border-sky-200",children:"Workspace 'default' can use all accessible infrastructure."});let c=[],i=[],o=[],d=new Set(a.map(e=>e.toLowerCase()));Object.entries(r).forEach(e=>{let[s,r]=e;if("private"===s||"allowed_users"===s)return;let a=A.Z2[s.toLowerCase()]||s.toUpperCase(),l=null==a?void 0:a.toLowerCase(),n=d.has(l)||Array.from(d).some(e=>e.startsWith(l+"/")),u=()=>"kubernetes"===s.toLowerCase()?Array.from(d).filter(e=>e.startsWith(l+"/")).map(e=>e.split("/")[1]):[];if((null==r?void 0:r.disabled)===!0)i.push(a);else if(r&&Object.keys(r).length>0){let e="";if("gcp"===s.toLowerCase()&&r.project_id)e=" (Project ID: ".concat(r.project_id,")");else if("aws"===s.toLowerCase()&&r.region)e=" (Region: ".concat(r.region,")");else if("kubernetes"===s.toLowerCase()){let s=u();s.length>0&&(e=" (Contexts: ".concat(s.join(", "),")"))}n?c.push((0,t.jsxs)("span",{className:"block",children:[a,e," is enabled."]},"".concat(s,"-enabled"))):o.push((0,t.jsxs)("span",{className:"block text-amber-700",children:[a,e," is configured but not currently available."]},"".concat(s,"-configured-not-enabled")))}else if(n){let e="";if("kubernetes"===s.toLowerCase()){let s=u();s.length>0&&(e=" (Contexts: ".concat(s.join(", "),")"))}c.push((0,t.jsxs)("span",{className:"block",children:[a,e," is enabled (using default settings)."]},"".concat(s,"-default-enabled")))}else o.push((0,t.jsxs)("span",{className:"block text-amber-700",children:[a," is configured but not currently available."]},"".concat(s,"-default-not-enabled")))});let u=[];if(i.length>0){let e=i.join(" and ");u.push((0,t.jsxs)("span",{className:"block",children:[e," ",1===i.length?"is":"are"," explicitly disabled."]},"disabled-clouds"))}return(u.push(...c),u.push(...o),u.length>0)?(0,t.jsx)("div",{className:"text-sm text-gray-700 mb-3 p-3 bg-sky-50 rounded border border-sky-200",children:u}):!l&&n?(0,t.jsx)("div",{className:"text-sm text-gray-500 mb-3 italic p-3 bg-sky-50 rounded border border-sky-200",children:"This workspace has no specific cloud resource configurations and can use all accessible infrastructure."}):null},M=e=>{let{isPrivate:s}=e;return s?(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700 border border-gray-300",children:"Private"}):(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700 border border-green-300",children:"Public"})},P=e=>{let{workspaceConfig:s,allUsers:r}=e;if(!s.private)return null;let a=s.allowed_users||[],l=(r||[]).filter(e=>"admin"===e.role).map(e=>e.username),n=[...new Set([...a,...l])];return 0===n.length?(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Allowed Users (0)"}),(0,t.jsx)("div",{className:"text-amber-600 text-xs italic p-2 bg-amber-50 rounded border border-amber-200",children:"No users configured (workspace may be inaccessible)"})]}):(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsxs)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:["Allowed Users (",n.length,")"]}),(0,t.jsx)("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-gray-200 rounded",children:n.map(e=>{let s=l.includes(e);return(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs p-2 bg-gray-50 hover:bg-gray-100 border-b border-gray-100 last:border-b-0",children:[(0,t.jsx)("span",{className:"font-medium text-gray-700",children:e}),s?(0,t.jsxs)("span",{className:"inline-flex items-center text-blue-600",children:[(0,t.jsx)(C.r7,{className:"w-3 h-3 mr-1"}),"Admin"]}):(0,t.jsxs)("span",{className:"inline-flex items-center text-gray-600",children:[(0,t.jsx)(b.Z,{className:"w-3 h-3 mr-1"}),"User"]})]},e)})})]})};function R(e){let{workspaceName:s,isNewWorkspace:r=!1}=e,o=(0,l.useRouter)(),[u,p]=(0,a.useState)({}),[b,w]=(0,a.useState)({}),[k,A]=(0,a.useState)(""),[R,_]=(0,a.useState)(!0),[z,O]=(0,a.useState)(!1),[T,U]=(0,a.useState)(!1),[Y,J]=(0,a.useState)(null),[I,V]=(0,a.useState)(null),[F,H]=(0,a.useState)(null),[X,B]=(0,a.useState)([]),[G,q]=(0,a.useState)({showDialog:!1,deleting:!1,error:null}),[K,Q]=(0,a.useState)({totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:[]}),[$,ee]=(0,a.useState)(!1),es=(0,a.useCallback)(async()=>{_(!0),J(null);try{let e;let[r,t]=await Promise.all([(0,n.fX)(),(0,W.R)()]),a=r[s]||{};p(a),w(a),B(t||[]),e=0===Object.keys(a).length?"".concat(s,":\n # Empty workspace configuration - uses all accessible infrastructure\n"):E.ZP.dump({[s]:a},{indent:2,lineWidth:-1,noRefs:!0,skipInvalid:!0,flowLevel:-1}),A(e)}catch(e){console.error("Error fetching workspace config:",e),J(e)}finally{_(!1)}},[s]),er=(0,a.useCallback)(async()=>{if(!r){ee(!0);try{let[e,r,t]=await Promise.all([(0,c.getClusters)(),(0,i.getManagedJobs)(),(0,n.yz)(s,!0)]),a=e.filter(e=>(e.workspace||"default")===s),l=a.filter(e=>"RUNNING"===e.status||"LAUNCHING"===e.status),o={};e.forEach(e=>{o[e.cluster]=e.workspace||"default"});let d=r.jobs||[],u=new Set(S.statusGroups.active),x=0;d.forEach(e=>{let r=e.cluster_name||e.resources&&e.resources.cluster_name;r&&o[r]===s&&u.has(e.status)&&x++}),Q({totalClusterCount:a.length,runningClusterCount:l.length,managedJobsCount:x,clouds:Array.isArray(t)?t:[]})}catch(e){console.error("Failed to fetch workspace stats:",e)}finally{ee(!1)}}},[s,r]);(0,a.useEffect)(()=>{r?(_(!1),A("".concat(s,":\n # New workspace configuration\n # Leave empty to use all accessible infrastructure\n"))):(es(),er())},[s,r,es,er]),(0,a.useEffect)(()=>{U(JSON.stringify(u)!==JSON.stringify(b))},[u,b]);let et=e=>{A(e),H(null);try{let r=E.ZP.load(e)||{},t=Object.keys(r);if(0===t.length)p({});else if(1===t.length){let e=t[0];if(e!==s){H('Workspace name cannot be changed. Expected "'.concat(s,'" but found "').concat(e,'".'));return}let a=r[s]||{};p(a)}else H("Configuration must contain only one workspace. Found: ".concat(t.join(", ")))}catch(e){H("Invalid YAML: ".concat(e.message))}},ea=async()=>{O(!0),J(null),V(null);try{if(F)throw Error("Please fix YAML errors before saving");let e=E.ZP.load(k)||{},t=Object.keys(e);if(t.length>0&&t[0]!==s)throw Error('Workspace name cannot be changed. Expected "'.concat(s,'".'));r?(await (0,n.MB)(s,u),V("Workspace created successfully!"),setTimeout(()=>{o.push("/workspaces/".concat(s))},1500)):(await (0,n.eA)(s,u),V("Workspace updated successfully!"),w(u),er())}catch(e){console.error("Error saving workspace:",e),J(e)}finally{O(!1)}},el=async()=>{q(e=>({...e,deleting:!0,error:null}));try{await (0,n.zl)(s),V("Workspace deleted successfully!"),setTimeout(()=>{o.push("/workspaces")},1500)}catch(e){console.error("Error deleting workspace:",e),q(s=>({...s,deleting:!1,error:e}))}},en=()=>{q({showDialog:!1,deleting:!1,error:null})},ec=async()=>{await Promise.all([es(),er()])};if(!o.isReady)return(0,t.jsx)("div",{children:"Loading..."});let ei=r?"Create New Workspace | SkyPilot Dashboard":"Workspace: ".concat(s," | SkyPilot Dashboard");return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x(),{children:(0,t.jsx)("title",{children:ei})}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,t.jsxs)("div",{className:"text-base flex items-center",children:[(0,t.jsx)(d(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,t.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,t.jsx)(d(),{href:r?"/workspace/new":"/workspaces/".concat(s),className:"text-sky-blue hover:underline",children:r?"New Workspace":s}),T&&(0,t.jsx)("span",{className:"ml-3 px-2 py-1 bg-yellow-100 text-yellow-800 text-xs rounded",children:"Unsaved changes"})]}),(0,t.jsxs)("div",{className:"text-sm flex items-center",children:[(R||z||$)&&(0,t.jsxs)("div",{className:"flex items-center mr-4",children:[(0,t.jsx)(g.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:z?"Saving...":"Loading..."})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-4",children:[!r&&(0,t.jsxs)("button",{onClick:ec,disabled:R||z||$,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[(0,t.jsx)(j.Z,{className:"w-4 h-4 mr-1.5"}),"Refresh"]}),!r&&"default"!==s&&(0,t.jsxs)("button",{onClick:()=>q({...G,showDialog:!0}),disabled:G.deleting||z,className:"text-red-600 hover:text-red-700 font-medium inline-flex items-center",children:[(0,t.jsx)(y.Z,{className:"w-4 h-4 mr-1.5"}),"Delete"]})]})]})]}),R?(0,t.jsxs)("div",{className:"flex justify-center items-center py-12",children:[(0,t.jsx)(g.Z,{size:24,className:"mr-2"}),(0,t.jsx)("span",{className:"text-gray-500",children:"Loading workspace configuration..."})]}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(L.X,{error:Y,title:"Error",onDismiss:()=>J(null)}),(0,t.jsx)(Z,{message:I}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[!r&&(0,t.jsx)("div",{className:"lg:col-span-1",children:(0,t.jsxs)(m.Zb,{className:"h-full",children:[(0,t.jsx)(m.Ol,{children:(0,t.jsx)(m.ll,{className:"text-base font-normal",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-semibold",children:"Workspace:"})," ",s]}),(0,t.jsx)(M,{isPrivate:!0===b.private})]})})}),(0,t.jsxs)(m.aY,{className:"text-sm pb-2 flex-1",children:[(0,t.jsxs)("div",{className:"py-2 flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,t.jsx)(C.QT,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,t.jsx)("span",{children:"Clusters (Running / Total)"})]}),(0,t.jsx)("span",{className:"font-normal text-gray-800",children:$?"...":"".concat(K.runningClusterCount," / ").concat(K.totalClusterCount)})]}),(0,t.jsxs)("div",{className:"py-2 flex items-center justify-between border-t border-gray-100",children:[(0,t.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,t.jsx)(C.Vp,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,t.jsx)("span",{children:"Managed Jobs"})]}),(0,t.jsx)("span",{className:"font-normal text-gray-800",children:$?"...":K.managedJobsCount})]})]}),(0,t.jsxs)("div",{className:"px-6 pb-6 text-sm pt-3",children:[(0,t.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Enabled Infra"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:$?(0,t.jsx)("span",{className:"text-gray-500",children:"Loading..."}):K.clouds.length>0?K.clouds.map(e=>(0,t.jsxs)("div",{className:"flex items-center text-gray-700",children:[(0,t.jsx)(C.Ye,{className:"w-3.5 h-3.5 mr-1.5 text-green-500"}),(0,t.jsx)("span",{children:e})]},e)):(0,t.jsx)("span",{className:"text-gray-500 italic",children:"No enabled infrastructure"})}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(D,{workspaceName:s,config:b,enabledClouds:K.clouds})}),(0,t.jsx)(P,{workspaceConfig:b,allUsers:X})]})]})}),(0,t.jsx)("div",{className:r?"lg:col-span-3":"lg:col-span-2",children:(0,t.jsxs)(m.Zb,{className:"h-full flex flex-col",children:[(0,t.jsx)(m.Ol,{children:(0,t.jsx)(m.ll,{className:"text-base font-normal",children:r?"New Workspace YAML":"Edit Workspace YAML"})}),(0,t.jsx)(m.aY,{className:"flex-1 flex flex-col",children:(0,t.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col",children:[F&&(0,t.jsx)(L.X,{error:F,onDismiss:()=>H(null)}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,t.jsxs)("p",{className:"text-sm text-gray-600 mb-3",children:["Configure infra-specific settings for this workspace. Leave empty to use all accessible infrastructure. Refer to"," ",(0,t.jsx)("a",{href:"https://docs.skypilot.co/en/latest/admin/workspaces.html#configuration",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600",children:"SkyPilot Docs"})," ","for more details."]}),(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Example configuration:"}),(0,t.jsx)("div",{className:"p-3 bg-gray-50 border rounded-lg",children:(0,t.jsx)("pre",{className:"text-xs font-mono text-gray-600 whitespace-pre-wrap",children:"".concat(s||"my-workspace",":\n private: true\n allowed_users:\n - user1@mydomain.com\n - user2@mydomain.com\n gcp:\n project_id: xxx\n disabled: false\n kubernetes:\n allowed_contexts:\n - context-1")})})]}),(0,t.jsx)(f.g,{value:k,onChange:e=>et(e.target.value),className:"font-mono text-sm flex-1 resize-none",style:{minHeight:"350px"},spellCheck:!1,placeholder:"# Enter workspace configuration in YAML format"}),(0,t.jsx)("div",{className:"flex justify-end space-x-3 pt-3 border-gray-200",children:(0,t.jsxs)(h.z,{onClick:ea,disabled:z||F||R,className:"inline-flex items-center bg-sky-600 hover:bg-sky-700 text-white",children:[(0,t.jsx)(N.Z,{className:"w-4 h-4 mr-1.5"}),z?"Applying...":"Apply"]})})]})]})})]})})]})]}),(0,t.jsx)(v.Vq,{open:G.showDialog,onOpenChange:en,children:(0,t.jsxs)(v.cZ,{className:"sm:max-w-md",children:[(0,t.jsxs)(v.fK,{className:"",children:[(0,t.jsx)(v.$N,{children:"Delete Workspace"}),(0,t.jsxs)(v.Be,{children:['Are you sure you want to delete workspace "',s,'"? This action cannot be undone.']})]}),G.error&&(0,t.jsx)(L.X,{error:G.error,title:"Deletion Failed",onDismiss:()=>q(e=>({...e,error:null}))}),(0,t.jsxs)(v.cN,{className:"",children:[(0,t.jsx)(h.z,{variant:"outline",onClick:en,disabled:G.deleting,children:"Cancel"}),(0,t.jsx)(h.z,{variant:"destructive",onClick:el,disabled:G.deleting,children:G.deleting?"Deleting...":"Delete"})]})]})})]})]})}}}]);
@@ -0,0 +1,6 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1871],{39037:function(e,s,t){t.r(s),t.d(s,{ClusterTable:function(){return O},Clusters:function(){return _},Status2Actions:function(){return q},enabledActions:function(){return V},handleVSCodeConnection:function(){return H}});var r=t(85893),a=t(67294),l=t(11163),n=t(55739),c=t(36989),i=t(41664),o=t.n(i),u=t(30803),d=t(37673),h=t(68764),x=t(23266),p=t(17324),m=t(53081),f=t(94545),j=t(13626),v=t(60998);/**
2
+ * @license lucide-react v0.407.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */let g=(0,v.Z)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),w=(0,v.Z)("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);t(6135);var y=t(92128),b=t(99307),k=t(23001),N=t(88950),C=t(6378),S=t(36856);t(1272);var L=t(20546);let M=[{label:"Status",value:"status"},{label:"Cluster",value:"cluster"},{label:"User",value:"user"},{label:"Workspace",value:"workspace"},{label:"Infra",value:"infra"}],R=(e,s)=>{let t="",r="";return e>=0&&(t=e+"m",r=" "),s&&(t+="".concat(r,"(down)")),""===t&&(t="-"),t},I=(e,s)=>{if(e&&e.includes("@")){let t=e.split("@")[0];return s&&s!==t?"".concat(t," (").concat(s,")"):t}let t=e||s||"N/A";return s&&s!==t?"".concat(t," (").concat(s,")"):t},E=e=>{if(!e||0===e)return"-";let s=e=Math.floor(e),t="",r=0;for(let e of[{value:31536e3,label:"y"},{value:2592e3,label:"mo"},{value:86400,label:"d"},{value:3600,label:"h"},{value:60,label:"m"},{value:1,label:"s"}])if(s>=e.value&&r<2){let a=Math.floor(s/e.value);t+="".concat(a).concat(e.label," "),s%=e.value,r++}return t.trim()||"0s"};function _(){let e=(0,l.useRouter)(),[s,t]=(0,a.useState)(!1),i=a.useRef(null),[u,d]=(0,a.useState)(!1),[h,f]=(0,a.useState)(!1),[v,g]=(0,a.useState)(null),[w,b]=(0,a.useState)(()=>!!e.isReady&&"true"===e.query.history),[N,L]=(0,a.useState)(!0),R=(0,k.X)(),[E,_]=(0,a.useState)([]),[H,F]=(0,a.useState)({status:[],cluster:[],user:[],workspace:[],infra:[]});(0,a.useEffect)(()=>{if(e.isReady){q();let s="true"===e.query.history;w!==s&&(L(!1),b(s),setTimeout(()=>L(!0),50))}},[e.isReady,e.query.history]),(0,a.useEffect)(()=>{(async()=>{try{await S.ZP.preloadForPage("clusters");let e=await C.default.get(p.fX),s=Object.keys(e),t=await C.default.get(x.getClusters),r=[...new Set(t.map(e=>e.workspace||"default").filter(e=>e))],a=new Set(s);r.includes("default")&&a.has("default"),r.forEach(e=>a.add(e));let l=await C.default.get(m.R),n=[...new Set(t.map(e=>({userId:e.user_hash||e.user,username:e.user})).filter(e=>e.userId)).values()],c=new Map;l.forEach(e=>{c.set(e.userId,{userId:e.userId,username:e.username,display:I(e.username,e.userId)})}),n.forEach(e=>{c.has(e.userId)||c.set(e.userId,{userId:e.userId,username:e.username,display:I(e.username,e.userId)})})}catch(e){console.error("Error fetching data for filters:",e)}})()},[]);let V=s=>{let t={...e.query},r=[],a=[],l=[];s.map((e,s)=>{var t;r.push(null!==(t=e.property.toLowerCase())&&void 0!==t?t:""),a.push(e.operator),l.push(e.value)}),t.property=r,t.operator=a,t.value=l,e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},W=s=>{let t={...e.query};t.history=s.toString(),e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},q=()=>{let s={...e.query},t=s.property,r=s.operator,a=s.value;if(void 0===t)return;let l=[],n=Array.isArray(t)?t.length:1,c=new Map;if(c.set("",""),c.set("status","Status"),c.set("cluster","Cluster"),c.set("user","User"),c.set("workspace","Workspace"),c.set("infra","Infra"),1===n)l.push({property:c.get(t),operator:r,value:a});else for(let e=0;e<n;e++)l.push({property:c.get(t[e]),operator:r[e],value:a[e]});_(l)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-1 min-h-[20px]",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(o(),{href:"/clusters",className:"text-sky-blue hover:underline leading-none text-base",children:"Sky Clusters"})}),(0,r.jsx)("div",{className:"w-full sm:w-auto",children:(0,r.jsx)(z,{propertyList:M,valueList:H,setFilters:_,updateURLParams:V,placeholder:"Filter clusters"})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 ml-auto",children:[(0,r.jsxs)("label",{className:"flex items-center cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:w,onChange:e=>{let s=e.target.checked;b(s),W(s)},className:"sr-only"}),(0,r.jsx)("div",{className:"relative inline-flex h-5 w-9 items-center rounded-full ".concat(N?"transition-colors":""," ").concat(w?"bg-sky-600":"bg-gray-300"),children:(0,r.jsx)("span",{className:"inline-block h-3 w-3 transform rounded-full bg-white ".concat(N?"transition-transform":""," ").concat(w?"translate-x-5":"translate-x-1")})}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Show history (Last 30 days)"})]}),s&&(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(n.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500 text-sm",children:"Loading..."})]}),(0,r.jsxs)("button",{onClick:()=>{C.default.invalidate(x.getClusters),C.default.invalidate(x.uR),C.default.invalidate(p.fX),C.default.invalidate(m.R),i.current&&i.current()},disabled:s,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(j.Z,{className:"h-4 w-4 mr-1.5"}),!R&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsx)(A,{filters:E,setFilters:_,updateURLParams:V}),(0,r.jsx)(O,{refreshInterval:c.yc,setLoading:t,refreshDataRef:i,filters:E,showHistory:w,onOpenSSHModal:e=>{g(e),d(!0)},onOpenVSCodeModal:e=>{g(e),f(!0)},setOptionValues:F}),(0,r.jsx)(y.Oh,{isOpen:u,onClose:()=>d(!1),cluster:v}),(0,r.jsx)(y._R,{isOpen:h,onClose:()=>f(!1),cluster:v})]})}function O(e){let{refreshInterval:s,setLoading:t,refreshDataRef:l,filters:i,showHistory:p,onOpenSSHModal:m,onOpenVSCodeModal:j,setOptionValues:v}=e,[g,w]=(0,a.useState)([]),[y,k]=(0,a.useState)({key:null,direction:"ascending"}),[N,S]=(0,a.useState)(!1),[M,I]=(0,a.useState)(!0),[_,O]=(0,a.useState)(1),[H,F]=(0,a.useState)(10),V=e=>{let s={status:[],cluster:[],user:[],workspace:[],infra:[]},t=(e,s)=>{e.includes(s)||e.push(s)};return e.map(e=>{t(s.status,e.status),t(s.cluster,e.cluster),t(s.user,e.user),t(s.workspace,e.workspace),t(s.infra,e.infra)}),s},W=a.useCallback(async()=>{t(!0),S(!0);try{let e=await C.default.get(x.getClusters);if(p){let s=await C.default.get(x.uR),t=e.map(e=>({...e,isHistorical:!1})),r=s.map(e=>({...e,isHistorical:!0})),a=[...t];r.forEach(s=>{e.some(e=>e.cluster_hash===s.cluster_hash)||a.push(s)}),v(V(a)),w(a)}else{let s=e.map(e=>({...e,isHistorical:!1}));v(V(s)),w(s)}}catch(e){console.error("Error fetching cluster data:",e),v(V([])),w([])}t(!1),S(!1),I(!1)},[t,p,v]),z=(e,s)=>{var t;let{property:r,operator:a,value:l}=s;if(!l)return!0;if(!r){let s=l.toLowerCase();return Object.values(e).some(e=>null==e?void 0:e.toString().toLowerCase().includes(s))}let n=null===(t=e[r.toLowerCase()])||void 0===t?void 0:t.toString().toLowerCase(),c=l.toString().toLowerCase();switch(a){case"=":return n===c;case":":return null==n?void 0:n.includes(c);default:return!0}},A=a.useMemo(()=>{let e=0===i.length?g:g.filter(e=>{let s=null;for(let t=0;t<i.length;t++){let r=z(e,i[t]);s=null===s?r:s&&r}return s});return(0,f.R0)(e,y.key,y.direction)},[g,y,i]);a.useEffect(()=>{l&&(l.current=W)},[l,W]),(0,a.useEffect)(()=>{w([]);let e=!0;W();let t=setInterval(()=>{e&&W()},s);return()=>{e=!1,clearInterval(t)}},[s,W]),(0,a.useEffect)(()=>{O(1)},[g.length]);let Z=e=>{let s="ascending";y.key===e&&"ascending"===y.direction&&(s="descending"),k({key:e,direction:s})},B=e=>y.key===e?"ascending"===y.direction?" ↑":" ↓":"",P=Math.ceil(A.length/H),U=(_-1)*H,D=U+H,X=A.slice(U,D);return(0,r.jsxs)("div",{children:[(0,r.jsx)(d.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(h.iA,{className:"min-w-full",children:[(0,r.jsx)(h.xD,{children:(0,r.jsxs)(h.SC,{children:[(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("status"),children:["Status",B("status")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("cluster"),children:["Cluster",B("cluster")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("user"),children:["User",B("user")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("workspace"),children:["Workspace",B("workspace")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("infra"),children:["Infra",B("infra")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("resources_str"),children:["Resources",B("resources_str")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("time"),children:["Started",B("time")]}),p&&(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("duration"),children:["Duration",B("duration")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("autostop"),children:["Autostop",B("autostop")]}),(0,r.jsx)(h.ss,{className:"md:sticky md:right-0 md:bg-white",children:"Actions"})]})}),(0,r.jsx)(h.RM,{children:N&&M?(0,r.jsx)(h.SC,{children:(0,r.jsx)(h.pj,{colSpan:9,className:"text-center py-6 text-gray-500",children:(0,r.jsxs)("div",{className:"flex justify-center items-center",children:[(0,r.jsx)(n.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]})})}):X.length>0?X.map((e,s)=>(0,r.jsxs)(h.SC,{children:[(0,r.jsx)(h.pj,{children:(0,r.jsx)(b.OE,{status:e.status})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(o(),{href:"/clusters/".concat(e.isHistorical?e.cluster_hash:e.cluster||e.name),className:"text-blue-600",children:e.cluster||e.name})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(L.H,{username:e.user,userHash:e.user_hash})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(o(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(c.Md,{content:e.full_infra||e.infra,className:"text-sm text-muted-foreground",children:(0,r.jsxs)("span",{children:[(0,r.jsx)(o(),{href:"/infra",className:"text-blue-600 hover:underline",children:e.cloud}),e.infra.includes("(")&&(0,r.jsx)("span",{children:" "+e.infra.substring(e.infra.indexOf("("))})]})})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(c.Md,{content:e.resources_str_full||e.resources_str,className:"text-sm text-muted-foreground",children:(0,r.jsx)("span",{children:e.resources_str})})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(c.Zg,{date:e.time})}),p&&(0,r.jsx)(h.pj,{children:E(e.duration)}),(0,r.jsx)(h.pj,{children:e.isHistorical?"-":R(e.autostop,e.to_down)}),(0,r.jsx)(h.pj,{className:"text-left md:sticky md:right-0 md:bg-white",children:!e.isHistorical&&(0,r.jsx)(q,{cluster:e.cluster,status:e.status,onOpenSSHModal:m,onOpenVSCodeModal:j})})]},s)):(0,r.jsx)(h.SC,{children:(0,r.jsx)(h.pj,{colSpan:9,className:"text-center py-6 text-gray-500",children:p?"No clusters found":"No active clusters"})})})]})})}),g.length>0&&(0,r.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,r.jsxs)("div",{className:"relative inline-block",children:[(0,r.jsxs)("select",{value:H,onChange:e=>{F(parseInt(e.target.value,10)),O(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,r.jsx)("option",{value:10,children:"10"}),(0,r.jsx)("option",{value:30,children:"30"}),(0,r.jsx)("option",{value:50,children:"50"}),(0,r.jsx)("option",{value:100,children:"100"}),(0,r.jsx)("option",{value:200,children:"200"})]}),(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500 absolute right-0 top-1/2 transform -translate-y-1/2 pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,r.jsx)("div",{children:"".concat(U+1," - ").concat(Math.min(D,A.length)," of ").concat(A.length)}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(u.z,{variant:"ghost",size:"icon",onClick:()=>{O(e=>Math.max(e-1,1))},disabled:1===_,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-left",children:(0,r.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,r.jsx)(u.z,{variant:"ghost",size:"icon",onClick:()=>{O(e=>Math.min(e+1,P))},disabled:_===P||0===P,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-right",children:(0,r.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})})]})}let H=(e,s)=>{s&&s(e)},F=(e,s)=>{s?s(e):window.open("ssh://".concat(e))},V=e=>"RUNNING"===e?["connect","VSCode"]:[],W={connect:(0,r.jsx)(g,{className:"w-4 h-4 text-gray-500 inline-block"}),VSCode:(0,r.jsx)(w,{className:"w-4 h-4 text-gray-500 inline-block"})};function q(e){let{withLabel:s=!1,cluster:t,status:a,onOpenSSHModal:l,onOpenVSCodeModal:n}=e,i=V(a),o=(0,k.X)(),u=e=>{switch(e){case"connect":F(t,l);break;case"VSCode":H(t,n);break;default:return}};return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"flex items-center space-x-4",children:Object.entries(W).map(e=>{let t,a,[l,n]=e;switch(l){case"connect":t="Connect",a="Connect with SSH";break;case"VSCode":t="VSCode",a="Open in VS Code"}return(s||(t=""),i.includes(l))?(0,r.jsx)(c.WH,{content:a,className:"capitalize text-sm text-muted-foreground",children:(0,r.jsxs)("button",{onClick:()=>u(l),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[n,!o&&(0,r.jsx)("span",{className:"ml-1.5",children:t})]})},l):(0,r.jsx)(c.WH,{content:a,className:"capitalize text-sm text-muted-foreground",children:(0,r.jsxs)("span",{className:"opacity-30 flex items-center cursor-not-allowed text-sm",title:l,children:[n,!o&&(0,r.jsx)("span",{className:"ml-1.5",children:t})]})},l)})})})}let z=e=>{let{propertyList:s=[],valueList:t,setFilters:l,updateURLParams:n,placeholder:c="Filter clusters"}=e,i=(0,a.useRef)(null),o=(0,a.useRef)(null),[u,d]=(0,a.useState)(!1),[h,x]=(0,a.useState)(""),[p,m]=(0,a.useState)("status"),[f,j]=(0,a.useState)([]);(0,a.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&i.current&&!i.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,a.useEffect)(()=>{let e=[];if(t&&"object"==typeof t)switch(p){case"status":e=t.status||[];break;case"user":e=t.user||[];break;case"cluster":e=t.cluster||[];break;case"workspace":e=t.workspace||[];break;case"infra":e=t.infra||[]}""!==h.trim()&&(e=e.filter(e=>e&&e.toString().toLowerCase().includes(h.toLowerCase()))),j(e)},[p,t,h]);let v=e=>{let t=s.find(s=>s.value===e);return t?t.label:e},g=e=>{l(s=>{let t=[...s,{property:v(p),operator:":",value:e}];return n(t),t}),d(!1),x(""),i.current.focus()};return(0,r.jsxs)("div",{className:"flex flex-row border border-gray-300 rounded-md overflow-visible",children:[(0,r.jsx)("div",{className:"border-r border-gray-300 flex-shrink-0",children:(0,r.jsxs)(N.Ph,{onValueChange:m,value:p,children:[(0,r.jsx)(N.i4,{"aria-label":"Filter Property",className:"focus:ring-0 focus:ring-offset-0 border-none rounded-l-md rounded-r-none w-20 sm:w-24 md:w-32 h-8 text-xs sm:text-sm",children:(0,r.jsx)(N.ki,{placeholder:"Status"})}),(0,r.jsx)(N.Bw,{children:s.map((e,s)=>(0,r.jsx)(N.Ql,{value:e.value,children:e.label},"property-item-".concat(s)))})]})}),(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("input",{type:"text",ref:i,placeholder:c,value:h,onChange:e=>{x(e.target.value),u||d(!0)},onFocus:()=>{d(!0)},onKeyDown:e=>{"Enter"===e.key&&""!==h.trim()?(l(e=>{let s=[...e,{property:v(p),operator:":",value:h}];return n(s),s}),x(""),d(!1)):"Escape"===e.key&&(d(!1),i.current.blur())},className:"h-8 w-full sm:w-96 px-3 pr-8 text-sm border-none rounded-l-none rounded-r-md focus:ring-0 focus:outline-none",autoComplete:"off"}),h&&(0,r.jsx)("button",{onClick:()=>{x(""),d(!1)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear filter",tabIndex:-1,children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),u&&f.length>0&&(0,r.jsx)("div",{ref:o,className:"absolute z-50 mt-1 w-full bg-white border border-gray-200 rounded-md shadow-lg max-h-60 overflow-y-auto",style:{zIndex:9999},children:f.map((e,s)=>(0,r.jsx)("div",{className:"px-3 py-2 cursor-pointer hover:bg-gray-50 text-sm ".concat(s!==f.length-1?"border-b border-gray-100":""),onClick:()=>g(e),children:(0,r.jsx)("span",{className:"text-sm text-gray-700",children:e})},"".concat(e,"-").concat(s)))})]})]})},A=e=>{let{filters:s=[],setFilters:t,updateURLParams:a}=e,l=e=>{t(s=>{let t=s.filter((s,t)=>t!==e);return a(t),t})};return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"flex items-center gap-4 py-2 px-2",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-content gap-2",children:[s.map((e,s)=>(0,r.jsx)(Z,{filter:e,onRemove:()=>l(s)},"filteritem-".concat(s))),s.length>0&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("button",{onClick:()=>{a([]),t([])},className:"rounded-full px-4 py-1 text-sm text-gray-700 bg-gray-200 hover:bg-gray-300",children:"Clear filters"})})]})})})},Z=e=>{let{filter:s,onRemove:t}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex items-center text-blue-600 bg-blue-100 px-1 py-1 rounded-full text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2",children:[(0,r.jsx)("span",{children:"".concat(s.property," ")}),(0,r.jsx)("span",{children:"".concat(s.operator," ")}),(0,r.jsx)("span",{children:" ".concat(s.value)})]}),(0,r.jsx)("button",{onClick:()=>t(),className:"p-0.5 ml-1 transform text-gray-400 hover:text-gray-600 bg-blue-500 hover:bg-blue-600 rounded-full flex flex-col items-center",title:"Clear filter",children:(0,r.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"white",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:5,d:"M6 18L18 6M6 6l12 12"})})})]})})}},12003:function(e,s,t){t.d(s,{j:function(){return n}});var r=t(90512);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,l=r.W,n=(e,s)=>t=>{var r;if((null==s?void 0:s.variants)==null)return l(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:n,defaultVariants:c}=s,i=Object.keys(n).map(e=>{let s=null==t?void 0:t[e],r=null==c?void 0:c[e];if(null===s)return null;let l=a(s)||a(r);return n[e][l]}),o=t&&Object.entries(t).reduce((e,s)=>{let[t,r]=s;return void 0===r||(e[t]=r),e},{});return l(e,i,null==s?void 0:null===(r=s.compoundVariants)||void 0===r?void 0:r.reduce((e,s)=>{let{class:t,className:r,...a}=s;return Object.entries(a).every(e=>{let[s,t]=e;return Array.isArray(t)?t.includes({...c,...o}[s]):({...c,...o})[s]===t})?[...e,t,r]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3785],{42557:function(e,s,r){r.d(s,{I:function(){return l}});var t=r(85893),a=r(67294),n=r(32350);let l=a.forwardRef((e,s)=>{let{className:r,type:a,...l}=e;return(0,t.jsx)("input",{type:a,className:(0,n.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),ref:s,...l})});l.displayName="Input"},36185:function(e,s,r){r.d(s,{_:function(){return c}});var t=r(85893),a=r(67294),n=r(49102),l=r(12003),i=r(32350);let o=(0,l.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)(n.f,{ref:s,className:(0,i.cn)(o(),r),...a})});c.displayName=n.f.displayName},33785:function(e,s,r){r.r(s),r.d(s,{NewWorkspace:function(){return b}});var t=r(85893),a=r(67294),n=r(11163),l=r(41664),i=r.n(l),o=r(5152),c=r.n(o),u=r(17324),d=r(30803),f=r(42557),m=r(36185),p=r(37673);let x=c()(()=>Promise.all([r.e(616),r.e(5739),r.e(7411),r.e(1272),r.e(1559),r.e(6989),r.e(3850),r.e(8969),r.e(8056),r.e(6135),r.e(6601),r.e(9159),r.e(1141)]).then(r.bind(r,11141)).then(e=>e.WorkspaceEditor),{loadableGenerated:{webpack:()=>[11141]},ssr:!1});function b(){(0,n.useRouter)();let[e,s]=(0,a.useState)(""),[r,l]=(0,a.useState)(!1),[o,c]=(0,a.useState)({}),[b,h]=(0,a.useState)(!0);(0,a.useEffect)(()=>{v()},[]);let v=async()=>{try{let e=await (0,u.fX)();c(e)}catch(e){console.error("Failed to fetch existing workspaces:",e)}finally{h(!1)}},k=()=>{e.trim()&&!y&&l(!0)},y=e.trim()&&o.hasOwnProperty(e.trim()),w=e.trim()&&!y;return r?(0,t.jsx)(x,{workspaceName:e,isNewWorkspace:!0}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-4 h-5",children:(0,t.jsxs)("div",{className:"text-base flex items-center",children:[(0,t.jsx)(i(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,t.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,t.jsx)("span",{className:"text-sky-blue",children:"New Workspace"})]})}),(0,t.jsxs)(p.Zb,{className:"max-w-md",children:[(0,t.jsx)(p.Ol,{children:(0,t.jsx)(p.ll,{className:"text-base font-normal",children:"Create New Workspace"})}),(0,t.jsxs)(p.aY,{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(m._,{htmlFor:"workspace-name",className:"text-sm font-normal",children:"Workspace name"}),(0,t.jsx)(f.I,{id:"workspace-name",value:e,onChange:e=>s(e.target.value),placeholder:"Enter workspace name",autoFocus:!0,onKeyPress:e=>{"Enter"===e.key&&w&&k()}}),y?(0,t.jsxs)("p",{className:"text-sm text-gray-500 mt-1",children:['Workspace "',e,'" already exists.'," ",(0,t.jsx)(i(),{href:"/workspaces/".concat(e),className:"text-blue-600 hover:underline",children:"View the workspace"})]}):(0,t.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Choose a unique name for your workspace"})]}),(0,t.jsx)(d.z,{onClick:k,disabled:!w||b,className:"w-full bg-sky-600 hover:bg-sky-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:b?"Loading...":"Next: Configure Workspace"})]})]})]})}},49102:function(e,s,r){r.d(s,{f:function(){return i}});var t=r(67294),a=r(75320),n=r(85893),l=t.forwardRef((e,s)=>(0,n.jsx)(a.WV.label,{...e,ref:s,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(e.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));l.displayName="Label";var i=l},12003:function(e,s,r){r.d(s,{j:function(){return l}});var t=r(90512);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=t.W,l=(e,s)=>r=>{var t;if((null==s?void 0:s.variants)==null)return n(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:l,defaultVariants:i}=s,o=Object.keys(l).map(e=>{let s=null==r?void 0:r[e],t=null==i?void 0:i[e];if(null===s)return null;let n=a(s)||a(t);return l[e][n]}),c=r&&Object.entries(r).reduce((e,s)=>{let[r,t]=s;return void 0===t||(e[r]=t),e},{});return n(e,o,null==s?void 0:null===(t=s.compoundVariants)||void 0===t?void 0:t.reduce((e,s)=>{let{class:r,className:t,...a}=s;return Object.entries(a).every(e=>{let[s,r]=e;return Array.isArray(r)?r.includes({...i,...c}[s]):({...i,...c})[s]===r})?[...e,r,t]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}}}]);