xpk 0.17.2__py3-none-any.whl → 1.0.0__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 (41) hide show
  1. xpk/commands/cluster.py +4 -35
  2. xpk/commands/cluster_gcluster.py +1 -13
  3. xpk/commands/cluster_gcluster_test.py +2 -10
  4. xpk/commands/cluster_test.py +0 -4
  5. xpk/commands/workload.py +10 -3
  6. xpk/commands/workload_test.py +1 -0
  7. xpk/core/cluster.py +10 -9
  8. xpk/core/config.py +5 -17
  9. xpk/core/kueue_manager_test.py +2 -0
  10. xpk/core/nodepool.py +6 -0
  11. xpk/core/nodepool_test.py +4 -0
  12. xpk/core/scheduling.py +28 -3
  13. xpk/core/scheduling_test.py +38 -1
  14. xpk/core/system_characteristics.py +39 -16
  15. xpk/core/system_characteristics_test.py +11 -0
  16. xpk/core/workload_decorators/rdma_decorator.py +0 -15
  17. xpk/core/workload_decorators/tcpx_decorator.py +0 -8
  18. xpk/core/workload_decorators/tcpx_decorator_test.py +0 -78
  19. xpk/core/workload_decorators/tcpxo_decorator.py +0 -16
  20. xpk/parser/common.py +0 -17
  21. xpk/parser/core.py +0 -39
  22. xpk/parser/storage.py +0 -11
  23. xpk/utils/feature_flags.py +1 -1
  24. xpk/utils/validation.py +0 -8
  25. {xpk-0.17.2.dist-info → xpk-1.0.0.dist-info}/METADATA +15 -4
  26. {xpk-0.17.2.dist-info → xpk-1.0.0.dist-info}/RECORD +30 -41
  27. xpk/commands/batch.py +0 -144
  28. xpk/commands/job.py +0 -244
  29. xpk/commands/kind.py +0 -286
  30. xpk/commands/kjob_common.py +0 -60
  31. xpk/commands/run.py +0 -140
  32. xpk/commands/shell.py +0 -142
  33. xpk/parser/batch.py +0 -43
  34. xpk/parser/job.py +0 -147
  35. xpk/parser/kind.py +0 -95
  36. xpk/parser/run.py +0 -47
  37. xpk/parser/shell.py +0 -59
  38. {xpk-0.17.2.dist-info → xpk-1.0.0.dist-info}/WHEEL +0 -0
  39. {xpk-0.17.2.dist-info → xpk-1.0.0.dist-info}/entry_points.txt +0 -0
  40. {xpk-0.17.2.dist-info → xpk-1.0.0.dist-info}/licenses/LICENSE +0 -0
  41. {xpk-0.17.2.dist-info → xpk-1.0.0.dist-info}/top_level.txt +0 -0
xpk/commands/kind.py DELETED
@@ -1,286 +0,0 @@
1
- """
2
- Copyright 2024 Google LLC
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- https://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- """
16
-
17
- from ..core.kueue_manager import (KueueConfig, KueueManager)
18
- from ..core.commands import (
19
- run_command_for_value,
20
- run_command_with_updates,
21
- )
22
- from ..core.cluster import set_jobset_on_cluster, setup_k8s_env
23
- from ..core.kjob import (
24
- verify_kjob_installed,
25
- prepare_kjob,
26
- apply_kjob_crds,
27
- )
28
- from ..core.scheduling import get_total_chips_requested_from_args
29
- from ..core.storage import install_storage_crd
30
- from ..core.system_characteristics import (
31
- SystemCharacteristics,
32
- AcceleratorType,
33
- DockerPlatform,
34
- )
35
- from ..utils.console import (xpk_exit, xpk_print)
36
- from ..utils.validation import validate_dependencies_list, SystemDependency, should_validate_dependencies
37
-
38
-
39
- def cluster_create(args) -> None:
40
- """Function around cluster creation.
41
-
42
- Args:
43
- args: user provided arguments for running the command.
44
-
45
- Returns:
46
- 0 if successful and 1 otherwise.
47
- """
48
- if should_validate_dependencies(args):
49
- validate_dependencies_list([
50
- SystemDependency.KUBECTL,
51
- SystemDependency.KJOB,
52
- SystemDependency.GCLOUD,
53
- ])
54
- xpk_print(f'Starting cluster create for cluster {args.cluster}:', flush=True)
55
-
56
- create_cluster_command_code = create_cluster_if_necessary(args)
57
- if create_cluster_command_code != 0:
58
- xpk_exit(create_cluster_command_code)
59
-
60
- set_cluster_command_code = set_local_cluster_command(args)
61
- if set_cluster_command_code != 0:
62
- xpk_exit(set_cluster_command_code)
63
-
64
- xpk_print(
65
- 'Enabling the jobset API on our cluster, to be deprecated when Jobset is'
66
- ' globally available'
67
- )
68
- set_jobset_on_cluster_code = set_jobset_on_cluster(args)
69
- if set_jobset_on_cluster_code != 0:
70
- xpk_exit(set_jobset_on_cluster_code)
71
-
72
- xpk_print('Verifying kjob installation')
73
- err_code = verify_kjob_installed()
74
- if err_code > 0:
75
- xpk_exit(err_code)
76
-
77
- xpk_print('Applying kjob CDRs')
78
- err_code = apply_kjob_crds()
79
- if err_code > 0:
80
- xpk_exit(err_code)
81
-
82
- args.kind_cluster = True
83
- err_code = prepare_kjob(args)
84
- if err_code > 0:
85
- xpk_exit(err_code)
86
-
87
- k8s_client = setup_k8s_env(args)
88
- install_storage_crd(k8s_client)
89
-
90
- args.num_slices = 1
91
- args.enable_pathways = False
92
- system = SystemCharacteristics(
93
- 'N/A',
94
- 1,
95
- 'N/A',
96
- 'N/A',
97
- 1,
98
- AcceleratorType.CPU,
99
- 'kind',
100
- supports_sub_slicing=False,
101
- supports_super_slicing=False,
102
- docker_platform=DockerPlatform.ARM,
103
- )
104
-
105
- kueue_manager = KueueManager(project='', zone='')
106
- kueue_manager.install_or_upgrade(
107
- KueueConfig(
108
- system,
109
- total_chips=get_total_chips_requested_from_args(args, system),
110
- autoprovisioning_enabled=False,
111
- num_slices=args.num_slices,
112
- memory_limit='',
113
- cpu_limit=0,
114
- is_pathways_cluster=False,
115
- flex=False,
116
- configure_sub_slicing=False,
117
- configure_super_slicing=False,
118
- ),
119
- )
120
-
121
- xpk_print('Kind commands done! Resources are created.')
122
- xpk_exit(0)
123
-
124
-
125
- def cluster_delete(args) -> None:
126
- """Function around cluster delete.
127
-
128
- Args:
129
- args: user provided arguments for running the command.
130
-
131
- Returns:
132
- 0 if successful and 1 otherwise.
133
- """
134
- if should_validate_dependencies(args):
135
- validate_dependencies_list([SystemDependency.GCLOUD])
136
- xpk_print(f'Starting cluster delete for cluster: {args.cluster}', flush=True)
137
-
138
- run_kind_cluster_delete_command_code = run_kind_cluster_delete_command(args)
139
- if run_kind_cluster_delete_command_code != 0:
140
- xpk_exit(run_kind_cluster_delete_command_code)
141
- xpk_print(f'Kind commands done! Cluster {args.cluster} deleted.')
142
- xpk_exit(0)
143
-
144
-
145
- def cluster_list(args) -> None:
146
- """Function around cluster list.
147
-
148
- Returns:
149
- 0 if successful and 1 otherwise.
150
- """
151
- if should_validate_dependencies(args):
152
- validate_dependencies_list([SystemDependency.GCLOUD])
153
- if run_kind_clusters_list_command():
154
- xpk_exit(1)
155
- xpk_exit(0)
156
-
157
-
158
- def create_cluster_if_necessary(args) -> int:
159
- """Creates cluster if not present in the project.
160
-
161
- Args:
162
- args: user provided arguments for running the command.
163
-
164
- Returns:
165
- 0 if successful and 1 otherwise.
166
- """
167
- all_clusters, return_code = get_all_local_clusters_programmatic()
168
- if return_code > 0:
169
- xpk_print('Listing all clusters failed!')
170
- return 1
171
- if args.cluster in all_clusters:
172
- xpk_print('Skipping cluster creation since it already exists.')
173
- return 0
174
- else:
175
- return run_kind_cluster_create_command(args)
176
-
177
-
178
- def run_kind_cluster_delete_command(args) -> int:
179
- """Run the Delete Kind Cluster request.
180
-
181
- Args:
182
- args: user provided arguments for running the command.
183
-
184
- Returns:
185
- 0 if successful and 1 otherwise.
186
- """
187
- command = 'kind delete cluster'
188
-
189
- if args.cluster:
190
- command += f' --name={args.cluster}'
191
-
192
- return_code = run_command_with_updates(command, 'Cluster Delete')
193
- if return_code != 0:
194
- xpk_print(f'Cluster delete request returned ERROR {return_code}')
195
- return 1
196
-
197
- return 0
198
-
199
-
200
- def run_kind_clusters_list_command() -> int:
201
- """List Kind Clusters within the project and location.
202
-
203
- Returns:
204
- 0 if successful and 1 otherwise.
205
- """
206
- command = 'kind get clusters'
207
- return_code = run_command_with_updates(command, 'Cluster List')
208
- if return_code != 0:
209
- xpk_print(f'Cluster list request returned ERROR {return_code}')
210
- return 1
211
-
212
- return 0
213
-
214
-
215
- def run_kind_cluster_create_command(args) -> int:
216
- """Run the Create Kind Cluster request.
217
-
218
- Args:
219
- args: user provided arguments for running the command.
220
-
221
- Returns:
222
- 0 if successful and 1 otherwise.
223
- """
224
- command = 'kind create cluster'
225
-
226
- if args.cluster:
227
- command += f' --name={args.cluster}'
228
-
229
- if args.k8s_version:
230
- command += f' --image=kindest/node:v{args.k8s_version}'
231
-
232
- return_code = run_command_with_updates(command, 'Kind Cluster Create')
233
- if return_code != 0:
234
- xpk_print(f'GKE Cluster Create request returned ERROR {return_code}')
235
- return 1
236
- return 0
237
-
238
-
239
- def get_all_local_clusters_programmatic() -> tuple[list[str], int]:
240
- """Gets all the local clusters.
241
-
242
- Returns:
243
- List of cluster names and 0 if successful and 1 otherwise.
244
- """
245
- command = 'kind get clusters'
246
- return_code, raw_cluster_output = run_command_for_value(
247
- command, 'Find if Cluster Exists'
248
- )
249
- if return_code != 0:
250
- xpk_print(f'Find if Cluster Exists returned ERROR {return_code}')
251
- return [], return_code
252
-
253
- return raw_cluster_output.splitlines(), 0
254
-
255
-
256
- def set_local_cluster_command(args) -> int:
257
- """Run local cluster configuration command to set the kubectl config.
258
-
259
- Args:
260
- args: user provided arguments for running the command.
261
-
262
- Returns:
263
- 0 if successful and 1 otherwise.
264
- """
265
- if not args.cluster:
266
- command = 'kubectl config current-context'
267
- return_code, current_context = run_command_for_value(
268
- command, 'get current-context'
269
- )
270
- xpk_print(
271
- 'No local cluster name specified. Using current-context'
272
- f' `{current_context.strip()}`'
273
- )
274
- return return_code
275
-
276
- command = (
277
- f'kubectl config use-context kind-{args.cluster} --namespace=default'
278
- )
279
- task = f'switch to cluster {args.cluster}'
280
- return_code = run_command_with_updates(
281
- command,
282
- task,
283
- )
284
- if return_code != 0:
285
- xpk_print(f'{task} returned ERROR {return_code}')
286
- return return_code
@@ -1,60 +0,0 @@
1
- """
2
- Copyright 2025 Google LLC
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- https://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- """
16
-
17
- from ..core.capacity import (
18
- B200_DEVICE_TYPE,
19
- H100_MEGA_DEVICE_TYPE,
20
- H200_DEVICE_TYPE,
21
- )
22
- from ..core.cluster import get_gpu_type_from_cluster
23
- from ..core.kjob import (
24
- get_a3mega_pod_template_annotations,
25
- get_a3ultra_pod_template_annotations,
26
- get_a4_pod_template_annotations,
27
- Kueue_TAS_annotation,
28
- )
29
- from .common import is_TAS_possible
30
- from ..core.resources import get_cluster_capacity_type, get_cluster_system_characteristics
31
-
32
-
33
- def add_gpu_networking_annotations_to_command(args, cmd: str) -> str:
34
- gpu_type = get_gpu_type_from_cluster(args)
35
-
36
- annotations: tuple
37
- if gpu_type == H100_MEGA_DEVICE_TYPE:
38
- annotations = get_a3mega_pod_template_annotations()
39
- elif gpu_type == H200_DEVICE_TYPE:
40
- annotations = get_a3ultra_pod_template_annotations()
41
- elif gpu_type == B200_DEVICE_TYPE:
42
- annotations = get_a4_pod_template_annotations()
43
- else:
44
- annotations = tuple()
45
-
46
- flags = [
47
- f" --pod-template-annotation {annotation} " for annotation in annotations
48
- ]
49
- cmd += "\\\n".join(flags)
50
-
51
- return cmd
52
-
53
-
54
- def add_TAS_annotations_to_command(args, cmd: str) -> str:
55
- system_characteristics = get_cluster_system_characteristics(args)
56
- capacity_type = get_cluster_capacity_type(args)
57
- if is_TAS_possible(system_characteristics, capacity_type):
58
- cmd += f" --pod-template-annotation {Kueue_TAS_annotation}"
59
-
60
- return cmd
xpk/commands/run.py DELETED
@@ -1,140 +0,0 @@
1
- """
2
- Copyright 2025 Google LLC
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- https://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- """
16
-
17
- from argparse import Namespace
18
-
19
- from ..core.cluster import (
20
- setup_k8s_service_accounts,
21
- get_cluster_credentials,
22
- )
23
- from ..core.commands import run_command_with_full_controls
24
- from ..core.gcloud_context import add_zone_and_project
25
- from ..core.kjob import (
26
- AppProfileDefaults,
27
- JobTemplateDefaults,
28
- get_storage_annotations,
29
- prepare_kjob,
30
- )
31
- from ..core.kueue_manager import LOCAL_QUEUE_NAME
32
- from ..utils.console import xpk_exit, xpk_print
33
- from ..utils.validation import validate_dependencies_list, SystemDependency, should_validate_dependencies
34
- from .kind import set_local_cluster_command
35
- from .kjob_common import add_gpu_networking_annotations_to_command, add_TAS_annotations_to_command
36
-
37
-
38
- def run(args: Namespace) -> None:
39
- """Run task.
40
- This function runs passed script in non-blocking manner.
41
- Args:
42
- args: user provided arguments for running the command.
43
- Returns:
44
- None
45
- """
46
- if should_validate_dependencies(args):
47
- validate_dependencies_list([
48
- SystemDependency.KUBECTL,
49
- SystemDependency.KJOB,
50
- SystemDependency.GCLOUD,
51
- ])
52
- if not args.kind_cluster:
53
- add_zone_and_project(args)
54
- get_cluster_credentials(args)
55
- else:
56
- set_cluster_command_code = set_local_cluster_command(args)
57
- if set_cluster_command_code != 0:
58
- xpk_exit(set_cluster_command_code)
59
-
60
- err_code = prepare_kjob(args)
61
- if err_code > 0:
62
- xpk_exit(err_code)
63
- setup_k8s_service_accounts()
64
-
65
- submit_job(args)
66
-
67
-
68
- def submit_job(args: Namespace) -> None:
69
- cmd = (
70
- 'kubectl kjob create slurm --profile'
71
- f' {AppProfileDefaults.NAME.value} '
72
- f' --localqueue {LOCAL_QUEUE_NAME} '
73
- f' --stream-container {JobTemplateDefaults.CONTAINER_NAME.value}'
74
- f' --worker-container {JobTemplateDefaults.CONTAINER_NAME.value}'
75
- ' --wait --rm --first-node-ip'
76
- )
77
- cmd = add_gpu_networking_annotations_to_command(args, cmd)
78
- cmd = add_TAS_annotations_to_command(args, cmd)
79
-
80
- for annotation in get_storage_annotations(args):
81
- cmd += f' --pod-template-annotation {annotation}'
82
-
83
- if args.timeout:
84
- cmd += f' --wait-timeout {args.timeout}s'
85
-
86
- if args.ignore_unknown_flags:
87
- cmd += ' --ignore-unknown-flags'
88
-
89
- cmd += f' -- {args.script} --partition {LOCAL_QUEUE_NAME}'
90
-
91
- if args.array is not None:
92
- cmd += f' --array {args.array}'
93
-
94
- if args.cpus_per_task is not None:
95
- cmd += f' --cpus-per-task {args.cpus_per_task}'
96
-
97
- if args.gpus_per_task is not None:
98
- cmd += f' --gpus-per-task {args.gpus_per_task}'
99
-
100
- if args.mem is not None:
101
- cmd += f' --mem {args.mem}'
102
-
103
- if args.mem_per_task is not None:
104
- cmd += f' --mem-per-task {args.mem_per_task}'
105
-
106
- if args.mem_per_cpu is not None:
107
- cmd += f' --mem-per-cpu {args.mem_per_cpu}'
108
-
109
- if args.mem_per_gpu is not None:
110
- cmd += f' --mem-per-gpu {args.mem_per_gpu}'
111
-
112
- if args.nodes is not None:
113
- cmd += f' --nodes {args.nodes}'
114
-
115
- if args.ntasks is not None:
116
- cmd += f' --ntasks {args.ntasks}'
117
-
118
- if args.output is not None:
119
- cmd += f' --output {args.output}'
120
-
121
- if args.error is not None:
122
- cmd += f' --error {args.error}'
123
-
124
- if args.input is not None:
125
- cmd += f' --input {args.input}'
126
-
127
- if args.job_name is not None:
128
- cmd += f' --job-name {args.job_name}'
129
-
130
- if args.chdir is not None:
131
- cmd += f' --chdir {args.chdir}'
132
-
133
- if args.time is not None:
134
- cmd += f' --time {args.time}'
135
-
136
- return_code = run_command_with_full_controls(cmd, 'run task')
137
-
138
- if return_code != 0:
139
- xpk_print(f'Running task returned ERROR {return_code}')
140
- xpk_exit(return_code)
xpk/commands/shell.py DELETED
@@ -1,142 +0,0 @@
1
- """
2
- Copyright 2024 Google LLC
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
- https://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, software
8
- distributed under the License is distributed on an "AS IS" BASIS,
9
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- See the License for the specific language governing permissions and
11
- limitations under the License.
12
- """
13
-
14
- from ..core.commands import run_command_with_full_controls, run_command_for_value, run_command_with_updates
15
- from ..core.cluster import get_cluster_credentials, add_zone_and_project, setup_k8s_service_accounts
16
- from ..utils.console import xpk_exit, xpk_print
17
- from ..utils.validation import validate_dependencies_list, SystemDependency, should_validate_dependencies
18
- from argparse import Namespace
19
-
20
- from ..core.kjob import (
21
- AppProfileDefaults,
22
- prepare_kjob,
23
- get_pod_template_interactive_command,
24
- get_storage_annotations,
25
- )
26
-
27
- exit_instructions = 'To exit the shell input "exit".'
28
-
29
-
30
- def shell(args: Namespace):
31
- """Enter interactive shell.
32
- Args:
33
- args: user provided arguments for running the command.
34
- Returns:
35
- 0 if successful and 1 otherwise.
36
- """
37
- if should_validate_dependencies(args):
38
- validate_dependencies_list([
39
- SystemDependency.KUBECTL,
40
- SystemDependency.KJOB,
41
- SystemDependency.GCLOUD,
42
- ])
43
- exisitng_shell_pod_name = get_existing_shell_pod_name(args)
44
-
45
- if exisitng_shell_pod_name is None:
46
- return_code = connect_to_new_interactive_shell(args)
47
- else:
48
- return_code = connect_to_existing_interactive_shell(exisitng_shell_pod_name)
49
-
50
- if return_code != 0:
51
- xpk_print(f'The command failed with code {return_code}.')
52
- xpk_exit(return_code)
53
-
54
- xpk_exit(0)
55
-
56
-
57
- def get_existing_shell_pod_name(args: Namespace) -> str | None:
58
- if not args.kind_cluster:
59
- add_zone_and_project(args)
60
- get_cluster_credentials(args)
61
-
62
- return_code, shell_name = run_command_for_value(
63
- command=(
64
- 'kubectl get pods --no-headers --field-selector status.phase=Running'
65
- ' -o custom-columns=":metadata.name"'
66
- ),
67
- task='Get existing interactive shell pod name.',
68
- )
69
- if return_code != 0:
70
- xpk_print(
71
- f'Encounter an error with a code {return_code} when checking for'
72
- ' existing running shell.'
73
- )
74
- xpk_exit(return_code)
75
-
76
- pod_names = shell_name.strip().split('\n')
77
- kjob_pod_names = [
78
- name for name in pod_names if AppProfileDefaults.NAME.value in name
79
- ]
80
- shell_pod_names = [name for name in kjob_pod_names if 'interactive' in name]
81
-
82
- return shell_pod_names[0] if shell_pod_names else None
83
-
84
-
85
- def connect_to_new_interactive_shell(args: Namespace) -> int:
86
- err_code = prepare_kjob(args)
87
- if err_code > 0:
88
- xpk_exit(err_code)
89
- setup_k8s_service_accounts()
90
-
91
- cmd = (
92
- 'kubectl-kjob create interactive --profile'
93
- f' {AppProfileDefaults.NAME.value} --pod-running-timeout 180s'
94
- )
95
-
96
- for annotation in get_storage_annotations(args):
97
- cmd += f' --pod-template-annotation {annotation}'
98
-
99
- return run_command_with_full_controls(
100
- command=cmd,
101
- task='Creating new interactive shell and entering it',
102
- instructions=exit_instructions,
103
- )
104
-
105
-
106
- def connect_to_existing_interactive_shell(pod_name: str) -> int:
107
- return run_command_with_full_controls(
108
- command=(
109
- f'kubectl exec --stdin --tty {pod_name} --'
110
- f' {get_pod_template_interactive_command()}'
111
- ),
112
- task='Entering existing interactive shell',
113
- instructions=exit_instructions,
114
- )
115
-
116
-
117
- def shell_stop(args: Namespace):
118
- """Stop the running interactive shell by deleting the pod.
119
- Args:
120
- args: user provided arguments for running the command.
121
- Returns:
122
- 0 if successful and 1 otherwise.
123
- """
124
- if should_validate_dependencies(args):
125
- validate_dependencies_list(
126
- [SystemDependency.KUBECTL, SystemDependency.GCLOUD]
127
- )
128
- exisitng_shell_pod_name = get_existing_shell_pod_name(args)
129
-
130
- if exisitng_shell_pod_name is None:
131
- xpk_print('There is no shell running to stop')
132
- xpk_exit(0)
133
-
134
- return_code = run_command_with_updates(
135
- command=f'kubectl delete pod {exisitng_shell_pod_name}',
136
- task='Deleting the existing shell.',
137
- )
138
- if return_code != 0:
139
- xpk_exit(return_code)
140
-
141
- xpk_print('The shell was deleted successfully.')
142
- xpk_exit(0)
xpk/parser/batch.py DELETED
@@ -1,43 +0,0 @@
1
- """
2
- Copyright 2024 Google LLC
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- https://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- """
16
-
17
- from .common import (
18
- add_shared_arguments,
19
- add_slurm_arguments,
20
- add_cluster_arguments,
21
- add_kind_cluster_arguments,
22
- )
23
- from ..commands.batch import batch
24
-
25
-
26
- def set_batch_parser(batch_parser):
27
- batch_required_arguments = batch_parser.add_argument_group(
28
- 'batch Built-in Arguments', 'Arguments required for `batch`.'
29
- )
30
- batch_optional_arguments = batch_parser.add_argument_group(
31
- 'Optional Arguments', 'Arguments optional for `batch`.'
32
- )
33
-
34
- ### "batch" Required arguments
35
- batch_required_arguments.add_argument(
36
- 'script', help='script with batch task to run'
37
- )
38
-
39
- add_cluster_arguments(batch_optional_arguments)
40
- add_kind_cluster_arguments(batch_optional_arguments)
41
- add_shared_arguments(batch_optional_arguments)
42
- add_slurm_arguments(batch_optional_arguments)
43
- batch_parser.set_defaults(func=batch)