xpk 0.5.0__py3-none-any.whl → 0.7.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 (95) hide show
  1. xpk/__init__.py +15 -0
  2. xpk/api/__init__.py +15 -0
  3. xpk/api/storage_crd.yaml +52 -0
  4. xpk/commands/__init__.py +15 -0
  5. xpk/commands/batch.py +131 -0
  6. xpk/commands/cluster.py +808 -0
  7. xpk/commands/cluster_gcluster.py +269 -0
  8. xpk/commands/common.py +44 -0
  9. xpk/commands/config.py +29 -0
  10. xpk/commands/info.py +243 -0
  11. xpk/commands/inspector.py +357 -0
  12. xpk/commands/job.py +199 -0
  13. xpk/commands/kind.py +283 -0
  14. xpk/commands/kjob_common.py +44 -0
  15. xpk/commands/run.py +128 -0
  16. xpk/commands/shell.py +140 -0
  17. xpk/commands/storage.py +267 -0
  18. xpk/commands/version.py +27 -0
  19. xpk/commands/workload.py +889 -0
  20. xpk/core/__init__.py +15 -0
  21. xpk/core/blueprint/__init__.py +15 -0
  22. xpk/core/blueprint/blueprint_definitions.py +62 -0
  23. xpk/core/blueprint/blueprint_generator.py +708 -0
  24. xpk/core/capacity.py +185 -0
  25. xpk/core/cluster.py +564 -0
  26. xpk/core/cluster_private.py +200 -0
  27. xpk/core/commands.py +356 -0
  28. xpk/core/config.py +179 -0
  29. xpk/core/docker_container.py +225 -0
  30. xpk/core/docker_image.py +210 -0
  31. xpk/core/docker_manager.py +308 -0
  32. xpk/core/docker_resources.py +350 -0
  33. xpk/core/filestore.py +251 -0
  34. xpk/core/gcloud_context.py +196 -0
  35. xpk/core/gcluster_manager.py +176 -0
  36. xpk/core/gcsfuse.py +50 -0
  37. xpk/core/kjob.py +444 -0
  38. xpk/core/kueue.py +358 -0
  39. xpk/core/monitoring.py +134 -0
  40. xpk/core/nap.py +361 -0
  41. xpk/core/network.py +377 -0
  42. xpk/core/nodepool.py +581 -0
  43. xpk/core/pathways.py +377 -0
  44. xpk/core/ray.py +222 -0
  45. xpk/core/remote_state/__init__.py +15 -0
  46. xpk/core/remote_state/fuse_remote_state.py +99 -0
  47. xpk/core/remote_state/remote_state_client.py +38 -0
  48. xpk/core/resources.py +238 -0
  49. xpk/core/scheduling.py +253 -0
  50. xpk/core/storage.py +581 -0
  51. xpk/core/system_characteristics.py +1432 -0
  52. xpk/core/vertex.py +105 -0
  53. xpk/core/workload.py +341 -0
  54. xpk/core/workload_decorators/__init__.py +15 -0
  55. xpk/core/workload_decorators/rdma_decorator.py +129 -0
  56. xpk/core/workload_decorators/storage_decorator.py +52 -0
  57. xpk/core/workload_decorators/tcpxo_decorator.py +190 -0
  58. xpk/main.py +75 -0
  59. xpk/parser/__init__.py +15 -0
  60. xpk/parser/batch.py +43 -0
  61. xpk/parser/cluster.py +662 -0
  62. xpk/parser/common.py +259 -0
  63. xpk/parser/config.py +49 -0
  64. xpk/parser/core.py +135 -0
  65. xpk/parser/info.py +64 -0
  66. xpk/parser/inspector.py +65 -0
  67. xpk/parser/job.py +147 -0
  68. xpk/parser/kind.py +95 -0
  69. xpk/parser/run.py +47 -0
  70. xpk/parser/shell.py +59 -0
  71. xpk/parser/storage.py +316 -0
  72. xpk/parser/validators.py +39 -0
  73. xpk/parser/version.py +23 -0
  74. xpk/parser/workload.py +726 -0
  75. xpk/templates/__init__.py +15 -0
  76. xpk/templates/storage.yaml +13 -0
  77. xpk/utils/__init__.py +15 -0
  78. xpk/utils/console.py +55 -0
  79. xpk/utils/file.py +82 -0
  80. xpk/utils/gcs_utils.py +125 -0
  81. xpk/utils/kubectl.py +57 -0
  82. xpk/utils/network.py +168 -0
  83. xpk/utils/objects.py +88 -0
  84. xpk/utils/templates.py +28 -0
  85. xpk/utils/validation.py +80 -0
  86. xpk/utils/yaml.py +30 -0
  87. {xpk-0.5.0.dist-info → xpk-0.7.0.dist-info}/METADATA +456 -32
  88. xpk-0.7.0.dist-info/RECORD +92 -0
  89. {xpk-0.5.0.dist-info → xpk-0.7.0.dist-info}/WHEEL +1 -1
  90. xpk-0.7.0.dist-info/entry_points.txt +2 -0
  91. xpk-0.5.0.dist-info/RECORD +0 -7
  92. xpk-0.5.0.dist-info/entry_points.txt +0 -2
  93. xpk.py +0 -7282
  94. {xpk-0.5.0.dist-info → xpk-0.7.0.dist-info}/LICENSE +0 -0
  95. {xpk-0.5.0.dist-info → xpk-0.7.0.dist-info}/top_level.txt +0 -0
xpk/parser/common.py ADDED
@@ -0,0 +1,259 @@
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
+ import argparse
18
+
19
+
20
+ def add_shared_arguments(
21
+ custom_parser: argparse.ArgumentParser, required=False
22
+ ) -> None:
23
+ """Add shared arguments to the parser.
24
+
25
+ Args:
26
+ custom_parser: parser to add shared arguments to.
27
+ """
28
+ custom_parser.add_argument(
29
+ '--project',
30
+ type=str,
31
+ default=None,
32
+ help='GCE project name, defaults to "gcloud config project."',
33
+ required=required,
34
+ )
35
+ custom_parser.add_argument(
36
+ '--zone',
37
+ type=str,
38
+ default=None,
39
+ help=(
40
+ 'GCE zone, e.g. us-central2-b, defaults to "gcloud config '
41
+ 'compute/zone." Only one of --zone or --region is allowed in a '
42
+ 'command.'
43
+ ),
44
+ required=required,
45
+ )
46
+ custom_parser.add_argument(
47
+ '--dry-run',
48
+ type=bool,
49
+ action=argparse.BooleanOptionalAction,
50
+ default=False,
51
+ help=(
52
+ 'If given `--dry-run`, xpk will print the commands it wants to run'
53
+ ' but not run them. This is imperfect in cases where xpk might'
54
+ ' branch based on the output of commands'
55
+ ),
56
+ required=required,
57
+ )
58
+
59
+
60
+ def add_cluster_arguments(
61
+ custom_parser: argparse.ArgumentParser, required=False
62
+ ) -> None:
63
+ """Add cluster argument to the parser.
64
+
65
+ Args:
66
+ custom_parser: parser to add shared arguments to.
67
+ """
68
+ custom_parser.add_argument(
69
+ '--cluster',
70
+ type=str,
71
+ default=None,
72
+ help='The name of the cluster.',
73
+ required=required,
74
+ )
75
+
76
+
77
+ def add_kind_cluster_arguments(custom_parser: argparse.ArgumentParser) -> None:
78
+ """Add kind cluster arguments to the parser.
79
+
80
+ Args:
81
+ custom_parser: parser to add shared arguments to.
82
+ """
83
+ custom_parser.add_argument(
84
+ '--kind-cluster',
85
+ type=bool,
86
+ action=argparse.BooleanOptionalAction,
87
+ default=False,
88
+ help='Apply command to a local test cluster.',
89
+ )
90
+
91
+
92
+ def add_global_arguments(custom_parser: argparse.ArgumentParser):
93
+ """Add global - no cloud dependent - arguments to the parser.
94
+
95
+ Args:
96
+ custom_parser: parser to add global arguments to.
97
+ """
98
+ custom_parser.add_argument(
99
+ '--dry-run',
100
+ type=bool,
101
+ action=argparse.BooleanOptionalAction,
102
+ default=False,
103
+ help=(
104
+ 'If given `--dry-run`, xpk will print the commands it wants to run'
105
+ ' but not run them. This is imperfect in cases where xpk might'
106
+ ' branch based on the output of commands'
107
+ ),
108
+ )
109
+
110
+
111
+ def add_slurm_arguments(custom_parser: argparse.ArgumentParser):
112
+ """Add Slurm job arguments to the parser.
113
+
114
+ Args:
115
+ custom_parser: parser to add global arguments to.
116
+ """
117
+ custom_parser.add_argument(
118
+ '--ignore-unknown-flags',
119
+ type=bool,
120
+ action=argparse.BooleanOptionalAction,
121
+ default=False,
122
+ help='Ignore all the unsupported flags in the bash script.',
123
+ )
124
+ custom_parser.add_argument(
125
+ '-a',
126
+ '--array',
127
+ type=str,
128
+ default=None,
129
+ help=(
130
+ 'Submit a job array, multiple jobs to be executed with identical'
131
+ ' parameters. The indexes specification identifies what array index'
132
+ ' values should be used. For example, "--array=0-15" or'
133
+ ' "--array=0,6,16-32". Multiple values may be specified using a comma'
134
+ ' separated list and/or a range of values with a "-" separator. For'
135
+ ' example "--array=0-15%%4" will limit the number of simultaneously'
136
+ ' running tasks from this job array to 4. The minimum index value is'
137
+ ' 0. The maximum index value is 2147483647.'
138
+ ),
139
+ )
140
+ custom_parser.add_argument(
141
+ '-c',
142
+ '--cpus-per-task',
143
+ type=str,
144
+ default=None,
145
+ help='How much cpus a container inside a pod requires.',
146
+ )
147
+ custom_parser.add_argument(
148
+ '--gpus-per-task',
149
+ type=str,
150
+ default=None,
151
+ help='How much gpus a container inside a pod requires.',
152
+ )
153
+ custom_parser.add_argument(
154
+ '--mem',
155
+ type=str,
156
+ default=None,
157
+ help='How much memory a pod requires.',
158
+ )
159
+ custom_parser.add_argument(
160
+ '--mem-per-task',
161
+ type=str,
162
+ default=None,
163
+ help='How much memory a container requires.',
164
+ )
165
+ custom_parser.add_argument(
166
+ '--mem-per-cpu',
167
+ type=str,
168
+ default=None,
169
+ help=(
170
+ 'How much memory a container requires, it multiplies the number '
171
+ 'of requested cpus per task by mem-per-cpu.'
172
+ ),
173
+ )
174
+ custom_parser.add_argument(
175
+ '--mem-per-gpu',
176
+ type=str,
177
+ default=None,
178
+ help=(
179
+ 'How much memory a container requires, it multiplies the number '
180
+ 'of requested gpus per task by mem-per-gpu.'
181
+ ),
182
+ )
183
+ custom_parser.add_argument(
184
+ '-N',
185
+ '--nodes',
186
+ type=int,
187
+ default=None,
188
+ help='Number of pods to be used at a time.',
189
+ )
190
+ custom_parser.add_argument(
191
+ '-n',
192
+ '--ntasks',
193
+ type=int,
194
+ default=None,
195
+ help='Number of identical containers inside of a pod, usually 1.',
196
+ )
197
+ custom_parser.add_argument(
198
+ '-o',
199
+ '--output',
200
+ type=str,
201
+ default=None,
202
+ help=(
203
+ 'Where to redirect the standard output stream of a task. If not'
204
+ ' passed it proceeds to stdout, and is available via kubectl logs.'
205
+ ),
206
+ )
207
+ custom_parser.add_argument(
208
+ '-e',
209
+ '--error',
210
+ type=str,
211
+ default=None,
212
+ help=(
213
+ 'Where to redirect std error stream of a task. If not passed it'
214
+ ' proceeds to stdout, and is available via kubectl logs.'
215
+ ),
216
+ )
217
+ custom_parser.add_argument(
218
+ '--input',
219
+ type=str,
220
+ default=None,
221
+ help='What to pipe into the script.',
222
+ )
223
+ custom_parser.add_argument(
224
+ '-J',
225
+ '--job-name',
226
+ type=str,
227
+ default=None,
228
+ help='What is the job name.',
229
+ )
230
+ custom_parser.add_argument(
231
+ '-D',
232
+ '--chdir',
233
+ type=str,
234
+ default=None,
235
+ help='Change directory before executing the script.',
236
+ )
237
+ custom_parser.add_argument(
238
+ '-t',
239
+ '--time',
240
+ type=str,
241
+ default=None,
242
+ help=(
243
+ 'Set a limit on the total run time of the job. '
244
+ 'A time limit of zero requests that no time limit be imposed. '
245
+ 'Acceptable time formats include "minutes", "minutes:seconds", '
246
+ '"hours:minutes:seconds", "days-hours", "days-hours:minutes" '
247
+ 'and "days-hours:minutes:seconds".'
248
+ ),
249
+ )
250
+ custom_parser.add_argument(
251
+ '--priority',
252
+ type=str,
253
+ default='medium',
254
+ choices=['very-low', 'low', 'medium', 'high', 'very-high'],
255
+ help=(
256
+ 'A priority, one of `very-low`, `low`, `medium`, `high` or'
257
+ ' `very-high`. Defaults to `medium`.'
258
+ ),
259
+ )
xpk/parser/config.py ADDED
@@ -0,0 +1,49 @@
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 ..commands.config import get_config, set_config
18
+ from ..core.config import DEFAULT_KEYS
19
+ from .common import add_shared_arguments
20
+
21
+
22
+ def set_config_parsers(config_parser):
23
+ add_shared_arguments(config_parser)
24
+
25
+ config_subcommands = config_parser.add_subparsers(
26
+ title='config subcommands', dest='xpk_config_subcommands'
27
+ )
28
+ config_set_parser = config_subcommands.add_parser(
29
+ 'set', help='set config key'
30
+ )
31
+ config_get_parser = config_subcommands.add_parser(
32
+ 'get', help='get config key'
33
+ )
34
+ config_set_parser.add_argument(
35
+ 'set_config_args',
36
+ help=f"""Pair of (key, value) to be set in config. Allowed keys are: {DEFAULT_KEYS}.
37
+ Command usage: `xpk config set key value`""",
38
+ type=str,
39
+ nargs=2,
40
+ )
41
+ config_get_parser.add_argument(
42
+ 'get_config_key',
43
+ help=f"""Get key value from config. Allowed keys are: {DEFAULT_KEYS} .
44
+ Command usage: `xpk config get key`""",
45
+ type=str,
46
+ nargs=1,
47
+ )
48
+ config_set_parser.set_defaults(func=set_config)
49
+ config_get_parser.set_defaults(func=get_config)
xpk/parser/core.py ADDED
@@ -0,0 +1,135 @@
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
+ import argparse
18
+
19
+ from .config import set_config_parsers
20
+
21
+ from ..utils.console import xpk_print
22
+ from .cluster import set_cluster_parser
23
+ from .inspector import set_inspector_parser
24
+ from .storage import set_storage_parser
25
+ from .workload import set_workload_parsers
26
+ from .batch import set_batch_parser
27
+ from .job import set_job_parser
28
+ from .info import set_info_parser
29
+ from .kind import set_kind_parser
30
+ from .shell import set_shell_parser
31
+ from .version import set_version_parser
32
+ from .run import set_run_parser
33
+
34
+
35
+ def set_parser(parser: argparse.ArgumentParser):
36
+ xpk_subcommands = parser.add_subparsers(
37
+ title="xpk subcommands", dest="xpk_subcommands", help="Top level commands"
38
+ )
39
+ workload_parser = xpk_subcommands.add_parser(
40
+ "workload", help="Commands around workload management"
41
+ )
42
+ storage_parser = xpk_subcommands.add_parser(
43
+ "storage", help="Commands around storage management"
44
+ )
45
+ cluster_parser = xpk_subcommands.add_parser(
46
+ "cluster",
47
+ help="Commands around creating, deleting, and viewing clusters.",
48
+ )
49
+ inspector_parser = xpk_subcommands.add_parser(
50
+ "inspector",
51
+ help="Commands around investigating workload, and Kueue failures.",
52
+ )
53
+ info_parser = xpk_subcommands.add_parser(
54
+ "info",
55
+ help="Commands around listing kueue clusterqueues and localqueues.",
56
+ )
57
+ batch_parser = xpk_subcommands.add_parser(
58
+ "batch",
59
+ help="commands around running batch job",
60
+ )
61
+ job_parser = xpk_subcommands.add_parser(
62
+ "job", help="commands around listing, cancelling and investigating jobs"
63
+ )
64
+ kind_parser = xpk_subcommands.add_parser(
65
+ "kind",
66
+ help="commands around Kind cluster management",
67
+ )
68
+ shell_parser = xpk_subcommands.add_parser(
69
+ "shell", help="Commands around configuring and using interactive shell."
70
+ )
71
+ version_parser = xpk_subcommands.add_parser(
72
+ "version", help="Command to get xpk version"
73
+ )
74
+
75
+ config_parser = xpk_subcommands.add_parser(
76
+ "config", help="Commands to set and retrieve values from xpk config."
77
+ )
78
+
79
+ run_parser = xpk_subcommands.add_parser(
80
+ "run",
81
+ help="Command to run parallel jobs",
82
+ )
83
+
84
+ def default_subcommand_function(
85
+ _args,
86
+ ) -> int: # args is unused, so pylint: disable=invalid-name
87
+ """Default subcommand function.
88
+
89
+ Args:
90
+ _args: user provided arguments for running the command.
91
+
92
+ Returns:
93
+ 0 if successful and 1 otherwise.
94
+ """
95
+ xpk_print("Welcome to XPK! See below for overall commands:", flush=True)
96
+ parser.print_help()
97
+ cluster_parser.print_help()
98
+ workload_parser.print_help()
99
+ batch_parser.print_help()
100
+ info_parser.print_help()
101
+ job_parser.print_help()
102
+ shell_parser.print_help()
103
+ version_parser.print_help()
104
+ kind_parser.print_help()
105
+ config_parser.print_help()
106
+ run_parser.print_help()
107
+
108
+ storage_parser.print_help()
109
+ return 0
110
+
111
+ parser.set_defaults(func=default_subcommand_function)
112
+ workload_parser.set_defaults(func=default_subcommand_function)
113
+ cluster_parser.set_defaults(func=default_subcommand_function)
114
+ batch_parser.set_defaults(func=default_subcommand_function)
115
+ info_parser.set_defaults(func=default_subcommand_function)
116
+ job_parser.set_defaults(func=default_subcommand_function)
117
+ kind_parser.set_defaults(func=default_subcommand_function)
118
+ shell_parser.set_defaults(func=default_subcommand_function)
119
+ storage_parser.set_defaults(func=default_subcommand_function)
120
+ version_parser.set_defaults(func=default_subcommand_function)
121
+ config_parser.set_defaults(func=default_subcommand_function)
122
+ run_parser.set_defaults(func=default_subcommand_function)
123
+
124
+ set_workload_parsers(workload_parser=workload_parser)
125
+ set_cluster_parser(cluster_parser=cluster_parser)
126
+ set_inspector_parser(inspector_parser=inspector_parser)
127
+ set_batch_parser(batch_parser=batch_parser)
128
+ set_info_parser(info_parser=info_parser)
129
+ set_job_parser(job_parser=job_parser)
130
+ set_kind_parser(kind_parser=kind_parser)
131
+ set_shell_parser(shell_parser=shell_parser)
132
+ set_storage_parser(storage_parser=storage_parser)
133
+ set_version_parser(version_parser=version_parser)
134
+ set_config_parsers(config_parser=config_parser)
135
+ set_run_parser(run_parser=run_parser)
xpk/parser/info.py ADDED
@@ -0,0 +1,64 @@
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 ..commands.info import info
18
+ from .common import add_shared_arguments
19
+ from .validators import name_type
20
+ import argparse
21
+
22
+
23
+ def set_info_parser(info_parser: argparse.ArgumentParser) -> None:
24
+ info_required_arguments = info_parser.add_argument_group(
25
+ 'Required Arguments', 'Arguments required for info.'
26
+ )
27
+ info_optional_arguments = info_parser.add_argument_group(
28
+ 'Optional Arguments', 'Arguments optional for info.'
29
+ )
30
+
31
+ info_required_arguments.add_argument(
32
+ '--cluster',
33
+ type=name_type,
34
+ default=None,
35
+ help='Cluster to which command applies.',
36
+ required=True,
37
+ )
38
+
39
+ info_optional_arguments.add_argument(
40
+ '--namespace',
41
+ type=str,
42
+ default='',
43
+ help='Namespace to which resources and queues belong',
44
+ )
45
+
46
+ queues_flitering_group = (
47
+ info_optional_arguments.add_mutually_exclusive_group()
48
+ )
49
+
50
+ queues_flitering_group.add_argument(
51
+ '--clusterqueue',
52
+ action='store_true',
53
+ default=None,
54
+ help='Show only clusterqueues resources and usage',
55
+ )
56
+
57
+ queues_flitering_group.add_argument(
58
+ '--localqueue',
59
+ action='store_true',
60
+ default=None,
61
+ help='Show only localqueues resources and usage',
62
+ )
63
+ add_shared_arguments(info_optional_arguments)
64
+ info_parser.set_defaults(func=info)
@@ -0,0 +1,65 @@
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 ..commands.inspector import inspector
18
+ from .validators import name_type
19
+ from .common import add_shared_arguments
20
+
21
+
22
+ def set_inspector_parser(inspector_parser):
23
+ inspector_parser.add_subparsers(
24
+ title='inspector subcommands',
25
+ dest='xpk_inspector_subcommands',
26
+ help='Investigate workload, and Kueue failures.',
27
+ )
28
+
29
+ inspector_parser_required_arguments = inspector_parser.add_argument_group(
30
+ 'inspector Built-in Arguments', 'Arguments required for `inspector`.'
31
+ )
32
+ inspector_parser_optional_arguments = inspector_parser.add_argument_group(
33
+ 'Optional Arguments', 'Arguments optional for `inspector`.'
34
+ )
35
+
36
+ ### "inspector" Required arguments
37
+
38
+ inspector_parser_required_arguments.add_argument(
39
+ '--cluster',
40
+ type=name_type,
41
+ default=None,
42
+ help='The name of the cluster to investigate.',
43
+ required=True,
44
+ )
45
+
46
+ ### "inspector" Optional Arguments
47
+ add_shared_arguments(inspector_parser_optional_arguments)
48
+
49
+ inspector_parser_optional_arguments.add_argument(
50
+ '--workload',
51
+ type=name_type,
52
+ default=None,
53
+ help='The name of the workload to investigate.',
54
+ )
55
+
56
+ inspector_parser_optional_arguments.add_argument(
57
+ '--print-to-terminal',
58
+ action='store_true',
59
+ help=(
60
+ 'Prints inspector output to terminal. A user can always look at the'
61
+ ' returned file.'
62
+ ),
63
+ )
64
+
65
+ inspector_parser.set_defaults(func=inspector)