Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 2b98092

Browse files
use the common method_description infrastructure for shell driver
eliminate the extra RPC introduced in https://github.com/jumpstarter-dev/jumpstarter/pull/685 (cherry picked from commit c1ec0c8)
1 parent 3bfed12 commit 2b98092

3 files changed

Lines changed: 17 additions & 26 deletions

File tree

packages/jumpstarter-driver-shell/jumpstarter_driver_shell/client.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,12 @@ def method_command(args, env):
7575
if returncode != 0:
7676
raise click.exceptions.Exit(returncode)
7777

78-
# Try to get custom description, fall back to default for older than 0.7 servers
79-
try:
80-
description = self.call("get_method_description", method_name)
81-
except Exception:
82-
description = f"Execute the {method_name} shell method"
83-
8478
# Decorate and register the command with help text
8579
method_command = click.argument('args', nargs=-1, type=click.UNPROCESSED)(method_command)
8680
method_command = click.option('--env', '-e', multiple=True,
8781
help='Environment variables in KEY=VALUE format')(method_command)
8882
method_command = group.command(
8983
name=method_name,
90-
help=description,
84+
help=self.methods_description.get( method_name, f"Execute the {method_name} shell method"),
9185
context_settings={"ignore_unknown_options": True, "allow_interspersed_args": False},
9286
)(method_command)

packages/jumpstarter-driver-shell/jumpstarter_driver_shell/driver.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ class Shell(Driver):
2121
timeout: int = 300
2222
cwd: str | None = None
2323

24+
def __post_init__(self):
25+
super().__post_init__()
26+
# Extract descriptions from methods configuration and populate methods_description
27+
for method_name, method_config in self.methods.items():
28+
if isinstance(method_config, dict) and "description" in method_config:
29+
self.methods_description[method_name] = method_config["description"]
30+
2431
def _get_method_command(self, method: str) -> str:
2532
"""Extract the command string from a method configuration"""
2633
method_config = self.methods[method]
2734
if isinstance(method_config, str):
2835
return method_config
2936
return method_config.get("command", "echo Hello")
3037

31-
def _get_method_description(self, method: str) -> str:
32-
"""Extract the description from a method configuration"""
33-
method_config = self.methods[method]
34-
if isinstance(method_config, str):
35-
return f"Execute the {method} shell method"
36-
return method_config.get("description", f"Execute the {method} shell method")
37-
3838
def _get_method_timeout(self, method: str) -> int:
3939
"""Extract the timeout from a method configuration, fallback to global timeout"""
4040
method_config = self.methods[method]
@@ -52,11 +52,6 @@ def get_methods(self) -> list[str]:
5252
self.logger.debug(f"get_methods called, returning methods: {methods}")
5353
return methods
5454

55-
@export
56-
def get_method_description(self, method: str) -> str:
57-
"""Get the description for a specific method"""
58-
return self._get_method_description(method)
59-
6055
@export
6156
async def call_method(self, method: str, env, *args) -> AsyncGenerator[tuple[str, str, int | None], None]:
6257
"""

packages/jumpstarter-driver-shell/jumpstarter_driver_shell/driver_test.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,24 +199,26 @@ def test_cli_default_descriptions():
199199
assert test_cmd.help == "Execute the test_method shell method"
200200

201201

202-
def test_get_method_description_unified():
203-
"""Test the get_method_description export method with unified format"""
202+
def test_methods_description_populated():
203+
"""Test that methods_description is populated from methods configuration"""
204204
shell = Shell(
205205
methods={
206206
"method1": {
207207
"command": "echo",
208208
"description": "Custom description for method1"
209209
},
210-
"method2": "ls", # String format, should use default description
210+
"method2": "ls", # String format, no description in methods_description
211211
}
212212
)
213213

214214
with serve(shell) as client:
215-
# Test with custom description (unified format)
216-
assert client.call("get_method_description", "method1") == "Custom description for method1"
215+
# Test that custom descriptions are in methods_description
216+
assert "method1" in client.methods_description
217+
assert client.methods_description["method1"] == "Custom description for method1"
217218

218-
# Test with default description (string format)
219-
assert client.call("get_method_description", "method2") == "Execute the method2 shell method"
219+
# Test that string-format methods are not in methods_description
220+
# (will fall back to default in client)
221+
assert "method2" not in client.methods_description
220222

221223

222224
def test_mixed_format_methods():

0 commit comments

Comments
 (0)