Skip to content

refactor: timeout refactor to use CLI option value#86

Merged
JPHutchins merged 6 commits intointercreate:mainfrom
etiennedm:smpmgr-timeout-refactor
Apr 3, 2026
Merged

refactor: timeout refactor to use CLI option value#86
JPHutchins merged 6 commits intointercreate:mainfrom
etiennedm:smpmgr-timeout-refactor

Conversation

@etiennedm
Copy link
Copy Markdown
Contributor

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.

@etiennedm
Copy link
Copy Markdown
Contributor Author

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 smpclient = {git = "https://github.com/etiennedm/smpclient.git", branch = "smpclient-timeout-refactor" } but poetry is not happy with it (something to do with dynamic versioning and strict mode I'm guessing?)

@JPHutchins
Copy link
Copy Markdown
Collaborator

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 smpclient = {git = "https://github.com/etiennedm/smpclient.git", branch = "smpclient-timeout-refactor" } but poetry is not happy with it (something to do with dynamic versioning and strict mode I'm guessing?)

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.

@etiennedm
Copy link
Copy Markdown
Contributor Author

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 smpclient = { path = "../smpclient", develop = true } for the smpclient dependency.

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?

@JPHutchins
Copy link
Copy Markdown
Collaborator

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 smpclient = { path = "../smpclient", develop = true } for the smpclient dependency.

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.

@etiennedm etiennedm force-pushed the smpmgr-timeout-refactor branch from c306eea to 40a702d Compare December 24, 2025 17:41
@JPHutchins
Copy link
Copy Markdown
Collaborator

@etiennedm If you don't mind, I'll rebase this and get the feature merged in a new PR.

@etiennedm
Copy link
Copy Markdown
Contributor Author

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.
@etiennedm etiennedm force-pushed the smpmgr-timeout-refactor branch from 40a702d to 8918c16 Compare April 3, 2026 17:36
Copy link
Copy Markdown
Collaborator

@JPHutchins JPHutchins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.timeout into SMPClient construction and remove per-call timeout wiring for connect_with_spinner(...).
  • Simplify smp_request(...) call sites by removing the options parameter and relying on client defaults / per-command overrides.
  • Bump smpclient dependency to ^6.1.0 (and refresh poetry.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_request always passes a second argument to smpclient.request(...) even when timeout_s is None. Since other code in this repo calls smpclient.request(request) without providing a timeout, passing None here can change semantics (e.g., disable the client's default timeout or raise in downstream code). Consider calling smpclient.request(request) when timeout_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.

@etiennedm
Copy link
Copy Markdown
Contributor Author

Yes the single CLI timeout arg applies to the connection and subsequent commands when it is None, if I understood your question correctly.

@JPHutchins JPHutchins merged commit 2296f7d into intercreate:main Apr 3, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants