Skip to content

FIREFLY-1331: Add Version validation for compatibility check between python client and firefly server#79

Open
jaladh-singhal wants to merge 4 commits intomasterfrom
FIREFLY-1331-version-validation
Open

FIREFLY-1331: Add Version validation for compatibility check between python client and firefly server#79
jaladh-singhal wants to merge 4 commits intomasterfrom
FIREFLY-1331-version-validation

Conversation

@jaladh-singhal
Copy link
Copy Markdown
Member

@jaladh-singhal jaladh-singhal commented Apr 10, 2026

Fixes FIREFLY-1331

  • Added server compatibility check on FireflyClient initialization — raises ValueError if the server version is below the required minimum, warns and proceeds if the version endpoint is unreachable
  • Added _server_compat.py module with version parsing logic, which also handles Firefly's non-standard version strings (DEV with branch/commit suffix, PRE releases)
  • Added unit tests (tests/test_server_compat.py) and a dev test notebook (examples/development_tests/test-version.ipynb)

Also see Firefly PR: Caltech-IPAC/firefly#1936

Extra:

  • Introduced unit tests to this package for the first time: Added pytest as an optional [tests] dependency; updated developer docs with instructions to run tests
  • Updated url_cmd_service from sticky/CmdSrv to CmdSrv/sync which seems more modern

Testing

  1. Check the test notebook (examples/development_tests/test-version.ipynb): nb-review's rendered version in the following comment.
  2. Check the unit test file (tests/test_server_compat.py) to understand how version parsing and compatiblity check logic is working for different cases
  3. [Optional] Run the unit tests and test notebook locally by checking out this branch and then following instructions in development docs:

- Introduced _server_compat.py for managing server version compatibility.
- Implemented version retrieval and compatibility checking in FireflyClient.
- Updated pyproject.toml to include packaging dependency.
And update documentation and pyproject.toml for pytest
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@jaladh-singhal jaladh-singhal changed the title Firefly 1331 version validation FIREFLY-1331: Add Version validation for compatibility check between python client and firefly server Apr 10, 2026

[project.optional-dependencies]
tests = [
"pytest",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is an optional dependency for tests so won't impact end user.

"websocket-client",
"requests"
"requests",
"packaging",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

packaging is one of the core utilities developed and maintained by python packaging authority (pypa): https://github.com/pypa/packaging. It's also used by pip itself internally so in most cases, it is already installed in user's python environment.

Comment on lines +41 to +45
def is_server_compatible(server_version: str|None) -> bool:
if not server_version:
return False
version = standardize_version(server_version)
return version is not None and version >= _MIN_VERSION
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am concerned that this might not be the best way to validate the version. This look like just a string compare. I think you need to separate the major and the minor the do something similar to BrowserInfo.js. That way you can ignore the type of build.

https://github.com/Caltech-IPAC/firefly/blob/252b29119973f6ac0ad1fa0e38ed17e92cfc91d1/src/firefly/js/util/BrowserInfo.js#L118-L125

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's not a string compare, it's comparing two packaging.Version objects (standardize_version converts firefly version string to Version object) which knows how to handle relational operators.

You can look at the unit tests to confirm if it's missing any of the cases you are concerned about: https://github.com/Caltech-IPAC/firefly_client/blob/FIREFLY-1331-version-validation/tests/test_server_compat.py#L31-L49

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok, I am going to probably need an overview of how this works. Maybe we can do that on Monday.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You can read each test case as: ver >= min_ver = bool. So:

_FIXED_MIN_VERSION = standardize_version('2026.1-DEV')

('2026.1-PRE-3',          True),   # pre-release of same version cycle
('2026.1',                True),   # formal release >= minimum

becomes:

'2026.1-PRE-3' >= '2026.1-DEV' = True
'2026.1' >= '2026.1-DEV' = True

and so on

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I can demo it on Monday too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants