refactor: timeout refactor to use CLI option value#86
refactor: timeout refactor to use CLI option value#86JPHutchins merged 6 commits intointercreate:mainfrom
Conversation
|
I'm assuming the linting fails because it's not using the updated version of smpclient. It works locally. Any trick here to make it work/test it is ok before bumping the version? I tried to specify the dependency as |
Running poetry lock and pushing the changes should work. But the we have to remember to retarget pypi after the upstream is released, which won't be too long. |
|
I'm not sure what needs to be done, I'm not very familiar with poetry. Right now my poetry.lock diff is showing a bunch of changes, and I have I guess the easiest would be to do a release of smpclient once you merge intercreate/smpclient#94, which we could then target in the dependencies of smpmgr? |
Yeah, that's easiest in the sense that it doesn't require coming back to this PR to update the pyproject and lock. |
c306eea to
40a702d
Compare
|
@etiennedm If you don't mind, I'll rebase this and get the feature merged in a new PR. |
|
Sure, go for it! |
Delegate default value to the client implementation.
Which can be configure with the '--timeout' option in the root command. It is still possible to provide an additional '--timeout' option that applies specifically to the shell command.
Since all uses are based on options.timeout, rely on the fact that the SMPClient is defaulting to precisely this value by construction.
40a702d to
8918c16
Compare
JPHutchins
left a comment
There was a problem hiding this comment.
Am I right in thinking that the single timeout arg applies to connection, and then to each subsequent command? Trying to remember what we decided. If that's right, I want to confirm that I'm OK with it as a stop gap until it's refactored to separate the initial connection timeout from subsequent request timeouts.
There was a problem hiding this comment.
Pull request overview
This PR refactors timeout handling so the CLI-provided --timeout value is applied via the SMPClient instance (rather than being threaded through connect_with_spinner / smp_request call sites), aligning with the timeout unification request raised in #71.
Changes:
- Pass
options.timeoutintoSMPClientconstruction and remove per-call timeout wiring forconnect_with_spinner(...). - Simplify
smp_request(...)call sites by removing theoptionsparameter and relying on client defaults / per-command overrides. - Bump
smpclientdependency to^6.1.0(and refreshpoetry.lock).
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| smpmgr/common.py | Centralizes timeout behavior in client creation; updates helper APIs (connect_with_spinner, smp_request). |
| smpmgr/main.py | Updates upgrade flow to new helper signatures; continues to support request-specific timeouts via smp_request. |
| smpmgr/shell_management.py | Makes shell command timeout optional and forwards it to smp_request. |
| smpmgr/stat_management.py | Updates stats commands to new connect_with_spinner / smp_request signatures. |
| smpmgr/os_management.py | Updates OS management commands to new helper signatures. |
| smpmgr/image_management.py | Updates image management commands to new helper signatures. |
| smpmgr/file_management.py | Updates file management commands to new helper signatures. |
| smpmgr/enumeration_management.py | Updates enumeration commands to new helper signatures. |
| smpmgr/user/intercreate.py | Updates Intercreate upload to new connect_with_spinner signature. |
| plugins/example_group.py | Updates plugin example to new connect_with_spinner signature. |
| plugins/another/another_group.py | Updates plugin example to new connect_with_spinner signature. |
| pyproject.toml | Bumps smpclient dependency version. |
| poetry.lock | Updates lockfile to match dependency resolution (including smpclient 6.1.0). |
Comments suppressed due to low confidence (1)
smpmgr/common.py:128
smp_requestalways passes a second argument tosmpclient.request(...)even whentimeout_sisNone. Since other code in this repo callssmpclient.request(request)without providing a timeout, passingNonehere can change semantics (e.g., disable the client's default timeout or raise in downstream code). Consider callingsmpclient.request(request)whentimeout_s is None, and only passing the timeout argument when it’s a real float value.
description = description or f"Waiting for response to {request.__class__.__name__}..."
task = progress.add_task(description=description, total=None)
try:
r = await smpclient.request(request, timeout_s)
progress.update(task, description=f"{description} OK", completed=True)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Yes the single CLI timeout arg applies to the connection and subsequent commands when it is None, if I understood your question correctly. |
This is to address my comment in #71. Do note that I have not updated the smpclient version in the dependencies. I'm not sure how to do it since I'm guessing it will need a release of smpclient first.
See intercreate/smpclient#94 for the necessary changes in smpclient.