xpk 0.4.0__py3-none-any.whl → 0.6.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.
- xpk/__init__.py +15 -0
- xpk/commands/__init__.py +15 -0
- xpk/commands/batch.py +109 -0
- xpk/commands/cluster.py +784 -0
- xpk/commands/cluster_gcluster.py +185 -0
- xpk/commands/info.py +245 -0
- xpk/commands/inspector.py +363 -0
- xpk/commands/job.py +197 -0
- xpk/commands/kind.py +253 -0
- xpk/commands/shell.py +120 -0
- xpk/commands/version.py +39 -0
- xpk/commands/workload.py +692 -0
- xpk/core/__init__.py +15 -0
- xpk/core/blueprint/__init__.py +15 -0
- xpk/core/blueprint/blueprint_definitions.py +61 -0
- xpk/core/blueprint/blueprint_generator.py +652 -0
- xpk/core/cluster_private.py +197 -0
- xpk/core/commands.py +352 -0
- xpk/core/core.py +2824 -0
- xpk/core/docker_manager.py +308 -0
- xpk/core/gcluster_manager.py +158 -0
- xpk/core/kjob.py +205 -0
- xpk/core/kueue.py +352 -0
- xpk/core/nap.py +349 -0
- xpk/core/pathways.py +298 -0
- xpk/core/ray.py +222 -0
- xpk/core/system_characteristics.py +1395 -0
- xpk/core/workload.py +133 -0
- xpk/core/workload_decorators/__init__.py +15 -0
- xpk/core/workload_decorators/rdma_decorator.py +109 -0
- xpk/core/workload_decorators/tcpxo_decorator.py +157 -0
- xpk/main.py +73 -0
- xpk/parser/__init__.py +15 -0
- xpk/parser/batch.py +184 -0
- xpk/parser/cluster.py +621 -0
- xpk/parser/common.py +71 -0
- xpk/parser/core.py +109 -0
- xpk/parser/info.py +63 -0
- xpk/parser/inspector.py +65 -0
- xpk/parser/job.py +126 -0
- xpk/parser/kind.py +94 -0
- xpk/parser/shell.py +50 -0
- xpk/parser/validators.py +39 -0
- xpk/parser/version.py +23 -0
- xpk/parser/workload.py +684 -0
- xpk/utils/__init__.py +15 -0
- xpk/utils/console.py +55 -0
- xpk/utils/file.py +82 -0
- xpk/utils/network.py +168 -0
- xpk/utils/objects.py +85 -0
- xpk/utils/yaml.py +30 -0
- {xpk-0.4.0.dist-info → xpk-0.6.0.dist-info}/METADATA +307 -38
- xpk-0.6.0.dist-info/RECORD +57 -0
- {xpk-0.4.0.dist-info → xpk-0.6.0.dist-info}/WHEEL +1 -1
- xpk-0.6.0.dist-info/entry_points.txt +2 -0
- xpk-0.4.0.dist-info/RECORD +0 -7
- xpk-0.4.0.dist-info/entry_points.txt +0 -2
- xpk.py +0 -7218
- {xpk-0.4.0.dist-info → xpk-0.6.0.dist-info}/LICENSE +0 -0
- {xpk-0.4.0.dist-info → xpk-0.6.0.dist-info}/top_level.txt +0 -0
xpk/parser/core.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
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 ..utils.console import xpk_print
|
|
20
|
+
from .cluster import set_cluster_parser
|
|
21
|
+
from .inspector import set_inspector_parser
|
|
22
|
+
from .workload import set_workload_parsers
|
|
23
|
+
from .batch import set_batch_parser
|
|
24
|
+
from .job import set_job_parser
|
|
25
|
+
from .info import set_info_parser
|
|
26
|
+
from .kind import set_kind_parser
|
|
27
|
+
from .shell import set_shell_parser
|
|
28
|
+
from .version import set_version_parser
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def set_parser(parser: argparse.ArgumentParser):
|
|
32
|
+
xpk_subcommands = parser.add_subparsers(
|
|
33
|
+
title="xpk subcommands", dest="xpk_subcommands", help="Top level commands"
|
|
34
|
+
)
|
|
35
|
+
workload_parser = xpk_subcommands.add_parser(
|
|
36
|
+
"workload", help="Commands around workload management."
|
|
37
|
+
)
|
|
38
|
+
cluster_parser = xpk_subcommands.add_parser(
|
|
39
|
+
"cluster",
|
|
40
|
+
help="Commands around creating, deleting, and viewing clusters.",
|
|
41
|
+
)
|
|
42
|
+
inspector_parser = xpk_subcommands.add_parser(
|
|
43
|
+
"inspector",
|
|
44
|
+
help="Commands around investigating workload, and Kueue failures.",
|
|
45
|
+
)
|
|
46
|
+
info_parser = xpk_subcommands.add_parser(
|
|
47
|
+
"info",
|
|
48
|
+
help="Commands around listing kueue clusterqueues and localqueues.",
|
|
49
|
+
)
|
|
50
|
+
batch_parser = xpk_subcommands.add_parser(
|
|
51
|
+
"batch",
|
|
52
|
+
help="commands around running batch job",
|
|
53
|
+
)
|
|
54
|
+
job_parser = xpk_subcommands.add_parser(
|
|
55
|
+
"job", help="commands around listing, cancelling and investigating jobs"
|
|
56
|
+
)
|
|
57
|
+
kind_parser = xpk_subcommands.add_parser(
|
|
58
|
+
"kind",
|
|
59
|
+
help="commands around Kind cluster management",
|
|
60
|
+
)
|
|
61
|
+
shell_parser = xpk_subcommands.add_parser(
|
|
62
|
+
"shell", help="Commands around configuring and using interactive shell."
|
|
63
|
+
)
|
|
64
|
+
version_parser = xpk_subcommands.add_parser(
|
|
65
|
+
"version", help="Command to get xpk version"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
def default_subcommand_function(
|
|
69
|
+
_args,
|
|
70
|
+
) -> int: # args is unused, so pylint: disable=invalid-name
|
|
71
|
+
"""Default subcommand function.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
_args: user provided arguments for running the command.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
0 if successful and 1 otherwise.
|
|
78
|
+
"""
|
|
79
|
+
xpk_print("Welcome to XPK! See below for overall commands:", flush=True)
|
|
80
|
+
parser.print_help()
|
|
81
|
+
cluster_parser.print_help()
|
|
82
|
+
workload_parser.print_help()
|
|
83
|
+
batch_parser.print_help()
|
|
84
|
+
info_parser.print_help()
|
|
85
|
+
job_parser.print_help()
|
|
86
|
+
shell_parser.print_help()
|
|
87
|
+
version_parser.print_help()
|
|
88
|
+
kind_parser.print_help()
|
|
89
|
+
|
|
90
|
+
return 0
|
|
91
|
+
|
|
92
|
+
parser.set_defaults(func=default_subcommand_function)
|
|
93
|
+
workload_parser.set_defaults(func=default_subcommand_function)
|
|
94
|
+
cluster_parser.set_defaults(func=default_subcommand_function)
|
|
95
|
+
batch_parser.set_defaults(func=default_subcommand_function)
|
|
96
|
+
info_parser.set_defaults(func=default_subcommand_function)
|
|
97
|
+
job_parser.set_defaults(func=default_subcommand_function)
|
|
98
|
+
kind_parser.set_defaults(func=default_subcommand_function)
|
|
99
|
+
shell_parser.set_defaults(func=default_subcommand_function)
|
|
100
|
+
version_parser.set_defaults(func=default_subcommand_function)
|
|
101
|
+
set_workload_parsers(workload_parser=workload_parser)
|
|
102
|
+
set_cluster_parser(cluster_parser=cluster_parser)
|
|
103
|
+
set_inspector_parser(inspector_parser=inspector_parser)
|
|
104
|
+
set_batch_parser(batch_parser=batch_parser)
|
|
105
|
+
set_info_parser(info_parser=info_parser)
|
|
106
|
+
set_job_parser(job_parser=job_parser)
|
|
107
|
+
set_kind_parser(kind_parser=kind_parser)
|
|
108
|
+
set_shell_parser(shell_parser=shell_parser)
|
|
109
|
+
set_version_parser(version_parser=version_parser)
|
xpk/parser/info.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
import argparse
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def set_info_parser(info_parser: argparse.ArgumentParser) -> None:
|
|
23
|
+
info_required_arguments = info_parser.add_argument_group(
|
|
24
|
+
'Required Arguments', 'Arguments required for info.'
|
|
25
|
+
)
|
|
26
|
+
info_optional_arguments = info_parser.add_argument_group(
|
|
27
|
+
'Optional Arguments', 'Arguments optional for info.'
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
info_required_arguments.add_argument(
|
|
31
|
+
'--cluster',
|
|
32
|
+
type=str,
|
|
33
|
+
default=None,
|
|
34
|
+
help='Cluster to which command applies.',
|
|
35
|
+
required=True,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
info_optional_arguments.add_argument(
|
|
39
|
+
'--namespace',
|
|
40
|
+
type=str,
|
|
41
|
+
default='',
|
|
42
|
+
help='Namespace to which resources and queues belong',
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
queues_flitering_group = (
|
|
46
|
+
info_optional_arguments.add_mutually_exclusive_group()
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
queues_flitering_group.add_argument(
|
|
50
|
+
'--clusterqueue',
|
|
51
|
+
action='store_true',
|
|
52
|
+
default=None,
|
|
53
|
+
help='Show only clusterqueues resources and usage',
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
queues_flitering_group.add_argument(
|
|
57
|
+
'--localqueue',
|
|
58
|
+
action='store_true',
|
|
59
|
+
default=None,
|
|
60
|
+
help='Show only localqueues resources and usage',
|
|
61
|
+
)
|
|
62
|
+
add_shared_arguments(info_optional_arguments)
|
|
63
|
+
info_parser.set_defaults(func=info)
|
xpk/parser/inspector.py
ADDED
|
@@ -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 workload_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=str,
|
|
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=workload_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)
|
xpk/parser/job.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
from ..commands.job import job_info, job_list, job_cancel
|
|
19
|
+
|
|
20
|
+
from .common import add_shared_arguments
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def set_job_parser(job_parser: argparse.ArgumentParser):
|
|
24
|
+
job_subcommands = job_parser.add_subparsers(
|
|
25
|
+
title='job subcommands',
|
|
26
|
+
dest='xpk_job_subcommands',
|
|
27
|
+
help=(
|
|
28
|
+
'These are commands related to job management. Look at help for'
|
|
29
|
+
' specific subcommands for more details.'
|
|
30
|
+
),
|
|
31
|
+
)
|
|
32
|
+
set_job_info_parser(
|
|
33
|
+
job_info_parser=job_subcommands.add_parser(
|
|
34
|
+
'info', help='Show information about specified job.'
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
set_job_list_parser(
|
|
38
|
+
job_list_parser=job_subcommands.add_parser('ls', help='List jobs.')
|
|
39
|
+
)
|
|
40
|
+
set_job_cancel_parser(
|
|
41
|
+
job_cancel_parser=job_subcommands.add_parser(
|
|
42
|
+
'cancel', help='Cancel job execution.'
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def set_job_info_parser(job_info_parser: argparse.ArgumentParser):
|
|
48
|
+
job_info_parser_required_arguments = job_info_parser.add_argument_group(
|
|
49
|
+
'Required arguments',
|
|
50
|
+
'The basic information required to identify the job.',
|
|
51
|
+
)
|
|
52
|
+
job_info_parser_required_arguments.add_argument(
|
|
53
|
+
'name',
|
|
54
|
+
type=str,
|
|
55
|
+
default=None,
|
|
56
|
+
help='Name of the job.',
|
|
57
|
+
)
|
|
58
|
+
job_info_parser.set_defaults(func=job_info)
|
|
59
|
+
add_shared_arguments(job_info_parser)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def set_job_list_parser(job_list_parser: argparse.ArgumentParser):
|
|
63
|
+
job_list_required_arguments = job_list_parser.add_argument_group(
|
|
64
|
+
'Required Arguments',
|
|
65
|
+
'Arguments required for job list.',
|
|
66
|
+
)
|
|
67
|
+
job_list_optional_arguments = job_list_parser.add_argument_group(
|
|
68
|
+
'Optional Arguments', 'Arguments optional for job list.'
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
### Required arguments
|
|
72
|
+
job_list_required_arguments.add_argument(
|
|
73
|
+
'--cluster',
|
|
74
|
+
type=str,
|
|
75
|
+
default=None,
|
|
76
|
+
help='The name of the cluster to list jobs on.',
|
|
77
|
+
required=True,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
job_list_optional_arguments.add_argument(
|
|
81
|
+
'--kind-cluster',
|
|
82
|
+
type=bool,
|
|
83
|
+
action=argparse.BooleanOptionalAction,
|
|
84
|
+
default=False,
|
|
85
|
+
help='Apply command to a local test cluster.',
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
job_list_parser.set_defaults(func=job_list)
|
|
89
|
+
add_shared_arguments(job_list_optional_arguments)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def set_job_cancel_parser(job_cancel_parser: argparse.ArgumentParser):
|
|
93
|
+
job_cancel_required_arguments = job_cancel_parser.add_argument_group(
|
|
94
|
+
'Required Arguments',
|
|
95
|
+
'Arguments required for job cancel.',
|
|
96
|
+
)
|
|
97
|
+
job_cancel_optional_arguments = job_cancel_parser.add_argument_group(
|
|
98
|
+
'Optional Arguments', 'Arguments optional for job cancel.'
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
job_cancel_required_arguments.add_argument(
|
|
102
|
+
'name',
|
|
103
|
+
type=str,
|
|
104
|
+
default=None,
|
|
105
|
+
help='The name of the job to be cancelled.',
|
|
106
|
+
nargs='+',
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
job_cancel_required_arguments.add_argument(
|
|
110
|
+
'--cluster',
|
|
111
|
+
type=str,
|
|
112
|
+
default=None,
|
|
113
|
+
help='The name of the cluster to delete the job on.',
|
|
114
|
+
required=True,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
job_cancel_optional_arguments.add_argument(
|
|
118
|
+
'--kind-cluster',
|
|
119
|
+
type=bool,
|
|
120
|
+
action=argparse.BooleanOptionalAction,
|
|
121
|
+
default=False,
|
|
122
|
+
help='Apply command to a local test cluster.',
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
job_cancel_parser.set_defaults(func=job_cancel)
|
|
126
|
+
add_shared_arguments(job_cancel_optional_arguments)
|
xpk/parser/kind.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
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.kind import (
|
|
18
|
+
cluster_create,
|
|
19
|
+
cluster_delete,
|
|
20
|
+
cluster_list,
|
|
21
|
+
)
|
|
22
|
+
from .common import add_global_arguments
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def set_kind_parser(kind_parser):
|
|
26
|
+
cluster_subcommands = kind_parser.add_subparsers(
|
|
27
|
+
title='kind subcommands',
|
|
28
|
+
dest='xpk_kind_subcommands',
|
|
29
|
+
help=(
|
|
30
|
+
'These are commands related to kind management. Look at help for'
|
|
31
|
+
' specific subcommands for more details.'
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
### "cluster create" command parser ###
|
|
36
|
+
cluster_create_parser = cluster_subcommands.add_parser(
|
|
37
|
+
'create', help='Create local clusters.'
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
### Optional Arguments
|
|
41
|
+
cluster_create_parser.add_argument(
|
|
42
|
+
'--cluster',
|
|
43
|
+
type=str,
|
|
44
|
+
default='kind',
|
|
45
|
+
help=(
|
|
46
|
+
'The name of the cluster. Will be used as the prefix for internal'
|
|
47
|
+
' objects in the cluster.'
|
|
48
|
+
),
|
|
49
|
+
required=False,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
cluster_create_parser.add_argument(
|
|
53
|
+
'--k8s-version',
|
|
54
|
+
type=str,
|
|
55
|
+
default='',
|
|
56
|
+
help='The Kubernetes version of the cluster.',
|
|
57
|
+
required=False,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
add_global_arguments(cluster_create_parser)
|
|
61
|
+
cluster_create_parser.set_defaults(func=cluster_create)
|
|
62
|
+
|
|
63
|
+
### "cluster delete" command parser ###
|
|
64
|
+
cluster_delete_parser = cluster_subcommands.add_parser(
|
|
65
|
+
'delete',
|
|
66
|
+
help='Delete cloud clusters.',
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
cluster_delete_required_arguments = cluster_delete_parser.add_argument_group(
|
|
70
|
+
'Required Arguments',
|
|
71
|
+
'Arguments required for cluster delete.',
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
### Required arguments
|
|
75
|
+
cluster_delete_required_arguments.add_argument(
|
|
76
|
+
'--cluster',
|
|
77
|
+
type=str,
|
|
78
|
+
default=None,
|
|
79
|
+
help='The name of the cluster to be deleted.',
|
|
80
|
+
required=True,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
### Optional Arguments
|
|
84
|
+
add_global_arguments(cluster_delete_parser)
|
|
85
|
+
cluster_delete_parser.set_defaults(func=cluster_delete)
|
|
86
|
+
|
|
87
|
+
# "cluster list" command parser.
|
|
88
|
+
cluster_list_parser = cluster_subcommands.add_parser(
|
|
89
|
+
'list', help='List cloud clusters.'
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
### Optional Arguments
|
|
93
|
+
add_global_arguments(cluster_list_parser)
|
|
94
|
+
cluster_list_parser.set_defaults(func=cluster_list)
|
xpk/parser/shell.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
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.shell import shell, shell_stop
|
|
18
|
+
from .common import add_shared_arguments
|
|
19
|
+
import argparse
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def set_shell_parser(shell_parser: argparse.ArgumentParser) -> None:
|
|
23
|
+
shell_optional_arguments = shell_parser.add_argument_group(
|
|
24
|
+
'Optional Arguments', 'Arguments optional for shell.'
|
|
25
|
+
)
|
|
26
|
+
add_shared_arguments(shell_optional_arguments)
|
|
27
|
+
shell_parser.set_defaults(func=shell)
|
|
28
|
+
|
|
29
|
+
shell_subcommands = shell_parser.add_subparsers(
|
|
30
|
+
title='shell subcommands',
|
|
31
|
+
dest='xpk_shell_subcommands',
|
|
32
|
+
help=(
|
|
33
|
+
'These are commands related to interactive shell. Look at help for'
|
|
34
|
+
' specific subcommands for more details.'
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
set_shell_stop_parser(
|
|
39
|
+
shell_stop_parser=shell_subcommands.add_parser(
|
|
40
|
+
name='stop', help='Stop the running shell.'
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def set_shell_stop_parser(shell_stop_parser: argparse.ArgumentParser):
|
|
46
|
+
shell_stop_optional_arguments = shell_stop_parser.add_argument_group(
|
|
47
|
+
'Optional Arguments', 'Arguments optional for shell stop.'
|
|
48
|
+
)
|
|
49
|
+
add_shared_arguments(shell_stop_optional_arguments)
|
|
50
|
+
shell_stop_parser.set_defaults(func=shell_stop)
|
xpk/parser/validators.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import os
|
|
19
|
+
import re
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def workload_name_type(value, pat=re.compile(r'[a-z]([-a-z0-9]*[a-z0-9])?')):
|
|
23
|
+
"""Validate that the workload name matches the expected pattern."""
|
|
24
|
+
match = pat.fullmatch(value)
|
|
25
|
+
if not match or len(match.group(0)) > 40:
|
|
26
|
+
raise argparse.ArgumentTypeError(
|
|
27
|
+
'Workload name must be less than 40 characters and match the pattern'
|
|
28
|
+
f' `{pat.pattern}`'
|
|
29
|
+
f' Name is currently {value}'
|
|
30
|
+
)
|
|
31
|
+
return value
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def directory_path_type(value):
|
|
35
|
+
if not os.path.isdir(value):
|
|
36
|
+
raise argparse.ArgumentTypeError(
|
|
37
|
+
f'Directory path is invalid. User provided path was {value}'
|
|
38
|
+
)
|
|
39
|
+
return value
|
xpk/parser/version.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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 ..commands.version import (version)
|
|
18
|
+
from .common import add_shared_arguments
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def set_version_parser(version_parser):
|
|
22
|
+
add_shared_arguments(version_parser)
|
|
23
|
+
version_parser.set_defaults(func=version)
|