Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fix error message when trying to load a Parthenon dataset without h5py installed #5054

Conversation

neutrinoceros
Copy link
Member

@neutrinoceros neutrinoceros commented Nov 12, 2024

PR Summary

Fix a small oversight from #4323

reprod:
install pooch, pandas, uninstall h5py

import yt
yt.load_sample("parthenon_advection")

error message on main:

Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    yt.load_sample("parthenon_advection")
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/clm/dev/yt-project/yt/yt/loaders.py", line 1684, in load_sample
    return load(loadable_path, **load_kwargs)
  File "/Users/clm/dev/yt-project/yt/yt/_maintenance/deprecation.py", line 68, in inner
    return func(*args, **kwargs)
  File "/Users/clm/dev/yt-project/yt/yt/loaders.py", line 141, in load
    return cls(fn, *args, **kwargs)
  File "/Users/clm/dev/yt-project/yt/yt/frontends/parthenon/data_structures.py", line 153, in __init__
    self._handle = HDF5FileHandler(filename)
                   ~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/clm/dev/yt-project/yt/yt/utilities/file_handler.py", line 32, in __init__
    self.handle = h5py.File(filename, mode="r")
                  ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/Users/clm/dev/yt-project/yt/yt/utilities/on_demand_imports.py", line 39, in __call__
    raise self.error
  File "/Users/clm/dev/yt-project/yt/yt/utilities/on_demand_imports.py", line 77, in inner
    return func(self)
  File "/Users/clm/dev/yt-project/yt/yt/utilities/on_demand_imports.py", line 305, in File
    from h5py import File
ModuleNotFoundError: No module named 'h5py'
Something went wrong while trying to lazy-import h5py. Please make sure that h5py is properly installed.
If the problem persists, please file an issue at https://github.com/yt-project/yt/issues/new

this branch

Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import yt; yt.load_sample('parthenon_advection')
               ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/clm/dev/yt-project/yt/yt/loaders.py", line 1684, in load_sample
    return load(loadable_path, **load_kwargs)
  File "/Users/clm/dev/yt-project/yt/yt/_maintenance/deprecation.py", line 68, in inner
    return func(*args, **kwargs)
  File "/Users/clm/dev/yt-project/yt/yt/loaders.py", line 146, in load
    raise YTUnidentifiedDataType(_input_fn, *args, **kwargs)
yt.utilities.exceptions.YTUnidentifiedDataType: Could not determine input format from PosixPath('/Users/clm/dev/yt-project/test-data-dir/parthenon_advection/advection_2d.out0.final.phdf')
The following types could not be thorougly checked against your data because their requirements are missing. You may want to inspect this list and check your installation:
- ArepoHDF5Dataset (requires: h5py)
- CFRadialDataset (requires: xarray, pyart)
- CM1Dataset (requires: netCDF4)
- ChimeraDataset (requires: h5py)
- ChollaDataset (requires: h5py)
- ChomboDataset (requires: h5py)
- ChomboPICDataset (requires: h5py)
- EagleDataset (requires: h5py)
- EagleNetworkDataset (requires: h5py)
- EnzoDataset (requires: h5py)
- EnzoDatasetInMemory (requires: h5py)
- EnzoEDataset (requires: h5py, libconf)
- EventsFITSDataset (requires: astropy)
- ExodusIIDataset (requires: netCDF4)
- FITSDataset (requires: astropy)
- FLASHDataset (requires: h5py)
- FLASHParticleDataset (requires: h5py)
- GAMERDataset (requires: h5py)
- GDFDataset (requires: h5py)
- GadgetFOFDataset (requires: h5py)
- GadgetHDF5Dataset (requires: h5py)
- GizmoDataset (requires: h5py)
- MoabHex8Dataset (requires: h5py)
- OWLSDataset (requires: h5py)
- OWLSSubfindDataset (requires: h5py)
- OpenPMDDataset (requires: h5py)
- OpenPMDGroupBasedDataset (requires: h5py)
- Orion2Dataset (requires: h5py)
- ParthenonDataset (requires: h5py)
- PlutoDataset (requires: h5py)
- SkyDataFITSDataset (requires: astropy)
- SpectralCubeFITSDataset (requires: astropy)
- SwiftDataset (requires: h5py)
- YTClumpTreeDataset (requires: h5py)
- YTDataContainerDataset (requires: h5py)
- YTDataLightRayDataset (requires: h5py)
- YTFITSDataset (requires: astropy)
- YTGridDataset (requires: h5py)
- YTHaloCatalogDataset (requires: h5py)
- YTNonspatialDataset (requires: h5py)
- YTProfileDataset (requires: h5py)
- YTSpatialPlotDataset (requires: h5py)

Please make sure you are running a sufficiently recent version of yt.

PR Checklist

  • New features are documented, with docstrings and narrative docs
  • Adds a test for any bugs fixed. Adds tests for new features.

@neutrinoceros neutrinoceros added this to the 4.4.1 milestone Nov 12, 2024
@neutrinoceros neutrinoceros added bug UX user-experience code frontends Things related to specific frontends frontend: parthenon labels Nov 12, 2024
@neutrinoceros neutrinoceros force-pushed the parthenon/bug/missing_load_requirements branch from 4664106 to 43d6b12 Compare November 12, 2024 09:42
@neutrinoceros neutrinoceros marked this pull request as ready for review November 12, 2024 09:59
Copy link
Contributor

@pgrete pgrete left a comment

Choose a reason for hiding this comment

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

Looks good to me (in case I can approve)

@chrishavlin chrishavlin merged commit 35a0297 into yt-project:main Nov 13, 2024
13 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/yt that referenced this pull request Nov 13, 2024
…ad a Parthenon dataset without h5py installed
@neutrinoceros neutrinoceros deleted the parthenon/bug/missing_load_requirements branch November 13, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug code frontends Things related to specific frontends frontend: parthenon UX user-experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants