Skip to content

Commit 20fddd3

Browse files
committed
refactor: rename execution entrypoint to command script
Signed-off-by: thxCode <[email protected]>
1 parent 70a32d3 commit 20fddd3

File tree

2 files changed

+42
-38
lines changed

2 files changed

+42
-38
lines changed

gpustack_runtime/cmds/deployer.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class CreateRunnerWorkloadSubCommand(SubCommand):
8585

8686
backend: str
8787
device: str
88-
entrypoint: str
88+
command_script: str
8989
port: int
9090
host_network: bool
9191
check: bool
@@ -118,9 +118,9 @@ def register(parser: _SubParsersAction):
118118
)
119119

120120
deploy_parser.add_argument(
121-
"--entrypoint-file",
121+
"--command-script-file",
122122
type=str,
123-
help="Path of entrypoint for the workload",
123+
help="Path of command script for the workload",
124124
)
125125

126126
deploy_parser.add_argument(
@@ -192,12 +192,14 @@ def __init__(self, args: Namespace):
192192
msg = "The name and volume arguments are required."
193193
raise ValueError(msg)
194194

195-
if args.entrypoint_file:
196-
entrypoint_file = Path(args.entrypoint_file)
197-
if not entrypoint_file.is_file():
198-
msg = f"The entrypoint file '{entrypoint_file}' does not exist."
195+
if args.command_script_file:
196+
command_script_file = Path(args.command_script_file)
197+
if not command_script_file.is_file():
198+
msg = f"The command script file '{command_script_file}' does not exist."
199199
raise ValueError(msg)
200-
self.entrypoint = entrypoint_file.read_text(encoding="utf-8").strip()
200+
self.command_script = command_script_file.read_text(
201+
encoding="utf-8",
202+
).strip()
201203

202204
def run(self):
203205
env = [
@@ -230,7 +232,7 @@ def run(self):
230232
]
231233
execution = ContainerExecution(
232234
privileged=True,
233-
entrypoint=self.entrypoint,
235+
command_script=self.command_script,
234236
args=self.extra_args,
235237
)
236238
ports = (
@@ -315,7 +317,7 @@ class CreateWorkloadSubCommand(SubCommand):
315317

316318
backend: str
317319
device: str
318-
entrypoint: str
320+
command_script: str
319321
port: int
320322
host_network: bool
321323
check: bool
@@ -347,9 +349,9 @@ def register(parser: _SubParsersAction):
347349
)
348350

349351
deploy_parser.add_argument(
350-
"--entrypoint-file",
352+
"--command-script-file",
351353
type=str,
352-
help="Path of entrypoint for the workload",
354+
help="Path of command script for the workload",
353355
)
354356

355357
deploy_parser.add_argument(
@@ -420,12 +422,14 @@ def __init__(self, args: Namespace):
420422
msg = "The name, image, and volume arguments are required."
421423
raise ValueError(msg)
422424

423-
if args.entrypoint_file:
424-
entrypoint_file = Path(args.entrypoint_file)
425-
if not entrypoint_file.is_file():
426-
msg = f"The entrypoint file '{entrypoint_file}' does not exist."
425+
if args.command_script_file:
426+
command_script_file = Path(args.command_script_file)
427+
if not command_script_file.is_file():
428+
msg = f"The command script file '{command_script_file}' does not exist."
427429
raise ValueError(msg)
428-
self.entrypoint = entrypoint_file.read_text(encoding="utf-8").strip()
430+
self.command_script = command_script_file.read_text(
431+
encoding="utf-8",
432+
).strip()
429433

430434
def run(self):
431435
env = [
@@ -458,7 +462,7 @@ def run(self):
458462
]
459463
execution = ContainerExecution(
460464
privileged=True,
461-
entrypoint=self.entrypoint,
465+
command_script=self.command_script,
462466
args=self.extra_args,
463467
)
464468
ports = (

gpustack_runtime/deployer/__types__.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,10 @@ class ContainerExecution(ContainerSecurity):
170170
Attributes:
171171
working_dir (str | None):
172172
Working directory for the container.
173-
entrypoint (str | None):
174-
Entrypoint content for the container,
173+
command (list[str] | None):
174+
Command to run in the container.
175+
command_script (str | None):
176+
Command(in form of script) for the container,
175177
only work if `readonly_rootfs` is False.
176178
When it is set, it will override the `command` field.
177179
For example,
@@ -182,8 +184,6 @@ class ContainerExecution(ContainerSecurity):
182184
echo "Hello, World!"
183185
exec /path/to/bin "$@"
184186
```
185-
command (list[str] | None):
186-
Command to run in the container.
187187
args (list[str] | None):
188188
Arguments to pass to the command.
189189
run_as_user (int | None):
@@ -204,9 +204,13 @@ class ContainerExecution(ContainerSecurity):
204204
"""
205205
Working directory for the container.
206206
"""
207-
entrypoint: str | None = None
207+
command: list[str] | None = None
208+
"""
209+
Command to run in the container.
210+
"""
211+
command_script: str | None = None
208212
"""
209-
Entrypoint content for the container,
213+
Command(in form of script) for the container,
210214
only work if `readonly_rootfs` is False.
211215
When it is set, it will override the `command` field.
212216
For example,
@@ -218,10 +222,6 @@ class ContainerExecution(ContainerSecurity):
218222
exec /path/to/bin "$@"
219223
```
220224
"""
221-
command: list[str] | None = None
222-
"""
223-
Command to run in the container.
224-
"""
225225
args: list[str] | None = None
226226
"""
227227
Arguments to pass to the command.
@@ -1001,22 +1001,22 @@ def validate_and_default(self):
10011001
c.restart_policy = ContainerRestartPolicyEnum.NEVER
10021002
elif not c.restart_policy:
10031003
c.restart_policy = ContainerRestartPolicyEnum.ALWAYS
1004-
# Mutate container entrypoint.
1005-
if c.execution and c.execution.entrypoint:
1004+
# Mutate container command.
1005+
if c.execution and c.execution.command_script:
10061006
if c.execution.readonly_rootfs:
1007-
msg = f"Readonly rootfs Container '{c.name}' cannot have an entrypoint."
1007+
msg = f"Readonly rootfs Container '{c.name}' cannot configure `command_script`."
10081008
raise ValueError(msg)
1009-
entrypoint_script_name = f"/gpustack-entrypoint-{fnv1a_32_hex(c.name)}"
1010-
entrypoint_file = ContainerFile(
1011-
path=entrypoint_script_name,
1009+
command_script_name = f"/gpustack-command-{fnv1a_32_hex(c.name)}"
1010+
command_script = ContainerFile(
1011+
path=command_script_name,
10121012
mode=0o755,
1013-
content=c.execution.entrypoint,
1013+
content=c.execution.command_script,
10141014
)
10151015
if not c.files:
10161016
c.files = []
1017-
c.files.append(entrypoint_file)
1018-
c.execution.command = [entrypoint_script_name] # Override command.
1019-
c.execution.entrypoint = None
1017+
c.files.append(command_script)
1018+
c.execution.command = [command_script_name] # Override command.
1019+
c.execution.command_script = None
10201020
# Add default registry if needed.
10211021
if (
10221022
envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY

0 commit comments

Comments
 (0)