Skip to content

Add SMS++ solver version probing and minimum-version compatibility gate - #124

Draft
davide-f with Copilot wants to merge 15 commits into
mainfrom
copilot/spsunipi-123-include-smspp-tool-version
Draft

davide-f with Copilot wants to merge 15 commits into
mainfrom
copilot/spsunipi-123-include-smspp-tool-version

Conversation

Copilot AI commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

pySMSpp did not expose solver version information and could not enforce tool-level compatibility requirements. This change adds a first-class version API for SMS++ solver wrappers and an optional minimum-version check that blocks incompatible runs before solver execution.

  • Version retrieval in solver wrappers

    • Added SMSPPSolverTool.version() to query solver version via --version with optional -V fallback.
    • Parses semantic versions from tool output (e.g. SMS++ tools version 0.7.1 → 0.7.1).
    • Handles fallback when primary flag output is unparsable and avoids duplicate probes when flags are identical.
    • Supports both standard and shell=True command modes.
  • Compatibility enforcement before optimize

    • Added optional constructor args:
      • minimum_version
      • version_option / fallback_version_option
    • Added ensure_minimum_version() and invoked it at the start of optimize().
    • Raises a clear error when the installed solver is older than required.
  • Caching and execution behavior

    • Caches parsed version/output to avoid repeated subprocess probes.
    • Caches successful minimum-version checks keyed by the required minimum version.
    • Keeps version probing context-aware while avoiding invalid working-directory assumptions.
  • Targeted coverage for new behavior

    • Added focused tests for:
      • version parsing
      • fallback semantics
      • shell-mode version probing
      • deduped/cached probes
      • minimum-version gating (including abort-before-launch behavior)
from pysmspp import UCBlockSolver

solver = UCBlockSolver(
    fp_network="network.nc4",
    configfile="uc_solverconfig.txt",
    minimum_version="0.7.1",
)

print(solver.version(print_message=False))  # e.g. "0.7.1"
solver.optimize()  # raises ValueError if solver version < 0.7.1

Copilot AI and others added 11 commits September 28, 2026 15:07
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for reading SMS++ tool version in pysmspp Add SMS++ solver version probing and minimum-version compatibility gate Sep 28, 2026
Copilot AI requested a review from davide-f September 28, 2026 15:16

@davide-f davide-f left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot remove mimimum version, add only an utility to get the version of a sms++ tool. avoid adding new dependencies

Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot remove mimimum version, add only an utility to get the version of a sms++ tool. avoid adding new dependencies

Done in commit a678ec2. I removed the minimum-version API/checking logic and kept only the solver version utility (version() with --version and optional -V fallback), without adding dependencies.

Copilot AI requested a review from davide-f October 1, 2026 16:05

@davide-f davide-f left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot revise to accommodate my comments

Comment thread pysmspp/smspp_tools.py Outdated
import os
import queue
import re
import shlex

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

drop shlex

Comment thread pysmspp/smspp_tools.py Outdated
return None if res is None else int(res.group())


def _parse_tool_version(version):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Avoid the extra definition of this function

Comment thread pysmspp/smspp_tools.py Outdated
Comment on lines +99 to +100
version_option: str = "--version",
fallback_version_option: str | None = "-V",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this shall not be an option

Comment thread pysmspp/smspp_tools.py Outdated
Comment on lines +128 to +132
version_option : str, optional
The option to display the version message, by default "--version".
fallback_version_option : str | None, optional
Alternative version option when version_option is not supported,
by default "-V".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

drop

Comment thread pysmspp/smspp_tools.py Outdated
print(msg)
return msg

def version(self, print_message=True):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Simplify this function to minimize the code changes. The option "-V" shall be an argument to the function

Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot revise to accommodate my comments

Addressed in commit 6b1e059. I revised the implementation per your review notes: removed shlex, dropped the extra version parser helper, removed constructor version options, and simplified version() so -V is an argument of the function.

Copilot AI requested a review from davide-f October 1, 2026 16:19
@davide-f

davide-f commented Oct 1, 2026

Copy link
Copy Markdown
Member

@copilot remember always the precommit

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot remember always the precommit

Noted. I’ll run pre-commit before committing changes.

@davide-f davide-f left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot no fallback option, make the only single option in the argument

Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com>

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot no fallback option, make the only single option in the argument

Addressed in commit 9d2c2ca. version() now takes a single option argument (default --version) and no longer performs fallback probing.

Copilot AI requested a review from davide-f October 1, 2026 16:29

This branch has not been deployed

No deployments
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.

Include features to read smspp tool version

2 participants