Skip to content

silx.io.url: h5pyd compatibility#4484

Merged
t20100 merged 5 commits intosilx-kit:mainfrom
felix-engelmann:h5pyd-upgrade
Feb 25, 2026
Merged

silx.io.url: h5pyd compatibility#4484
t20100 merged 5 commits intosilx-kit:mainfrom
felix-engelmann:h5pyd-upgrade

Conversation

@felix-engelmann
Copy link
Contributor

h5pyd changed their Config (HDFGroup/h5pyd@880721b) and the current version of silx with h5pyd>=0.20.0 no longer works and fails with an error:

$ silx view http://localhost:8000/  
ERROR:silx.app.view.main:An error occured in silx view:
ERROR:silx.app.view.main:<class 'AttributeError'> module 'h5pyd' has no attribute 'Config'   File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/bin/silx", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/lib/python3.12/site-packages/silx/__main__.py", line 76, in main
    status = launcher.execute(sys.argv)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/lib/python3.12/site-packages/silx/utils/launcher.py", line 289, in execute
    return command.execute(command_argv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/lib/python3.12/site-packages/silx/utils/launcher.py", line 126, in execute
    status = func(argv)
             ^^^^^^^^^^
  File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/lib/python3.12/site-packages/silx/app/view/main.py", line 206, in main
    mainQt(options)
  File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/lib/python3.12/site-packages/silx/app/view/main.py", line 185, in mainQt
    window.appendFile(url.path())
  File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/lib/python3.12/site-packages/silx/app/view/Viewer.py", line 927, in appendFile
    self.__treeview.findHdf5TreeModel().appendFile(filename)
  File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/lib/python3.12/site-packages/silx/gui/hdf5/Hdf5TreeModel.py", line 808, in appendFile
    self.insertFile(filename, -1)
  File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/lib/python3.12/site-packages/silx/gui/hdf5/Hdf5TreeModel.py", line 792, in insertFile
    h5file = silx_io.open(filename)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/lib/python3.12/site-packages/silx/io/utils.py", line 701, in open
    return _open_url_with_h5pyd(filename)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felix/Dokumente/maxiv/laptop/maxiv/projects/hdf5/silx/.venv/lib/python3.12/site-packages/silx/io/utils.py", line 611, in _open_url_with_h5pyd
    cfg = h5pyd.Config()
          ^^^^^^^^^^^^

This PR checks for availability of the new method and falls back to the old version. Therefore it should be compatible with older h5pyd versions as well.

Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR and the test!

Comment on lines +611 to +614
if hasattr(h5pyd, "get_config"):
cfg = h5pyd.get_config()
else:
cfg = h5pyd.Config()
Copy link
Member

Choose a reason for hiding this comment

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

Since we are planing a major release, I would propose to only keep h5pyd.get_config here and add a silx[h5pyd] extra requirements requiring h5pyd>=0.20.0.

If support of older version is needed, it would be best to check h5pyd version rather than using hasattr: this will help clean-up this when removing support of h5pyd<0.20.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a clean solution. I dropped support for old h5pyd as I currently don't need it.
Checking a version and parsing a version string is too tricky.

Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
LGTM

@t20100 t20100 merged commit a87091b into silx-kit:main Feb 25, 2026
3 of 4 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.

2 participants