spacetelescope / jdaviz

JWST astronomical data analysis tools in the Jupyter platform
https://jdaviz.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
142 stars 74 forks source link

[BUG]I think Cubeviz might be incompatible with the latest version of astropy #3150

Closed samrose30 closed 3 months ago

samrose30 commented 3 months ago

Jdaviz component

Cubeviz

Description

Cubeviz fails to import for astropy version 6.1.2 Can get it to work for astropy version 5.3.4 Seems to be an inssue within spectral_cube

How to Reproduce

See below the traceback error when importing cubeviz.

ImportError                               Traceback (most recent call last)
Cell In[1], line 3
      1 import os
      2 from astroquery.mast import Observations
----> 3 from jdaviz import Cubeviz

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/jdaviz/__init__.py:15
     12 test = TestRunner.make_test_runner_in(os.path.dirname(__file__))
     14 # Top-level API as exposed to users.
---> 15 from jdaviz.app import *  # noqa: F401, F403
     16 from jdaviz.configs.specviz import Specviz  # noqa: F401
     17 from jdaviz.configs.specviz2d import Specviz2d  # noqa: F401

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/jdaviz/app.py:31
     29 from glue.core.units import unit_converter
     30 from glue_astronomy.spectral_coordinates import SpectralCoordinates
---> 31 from glue_astronomy.translators.regions import roi_subset_state_to_region
     32 from glue_jupyter.app import JupyterApplication
     33 from glue_jupyter.common.toolbar_vuetify import read_icon

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/glue_astronomy/translators/__init__.py:3
      1 from . import nddata  # noqa
      2 from . import regions  # noqa
----> 3 from . import spectral_cube  # noqa
      4 from . import spectrum1d  # noqa
      5 from . import trace # noqa

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/glue_astronomy/translators/spectral_cube.py:9
      6 from astropy import units as u
      7 from astropy.wcs import WCSSUB_STOKES, WCS
----> 9 from spectral_cube import BooleanArrayMask
     10 from spectral_cube.spectral_cube import (BaseSpectralCube, SpectralCube,
     11                                          VaryingResolutionSpectralCube)
     12 from spectral_cube.dask_spectral_cube import DaskSpectralCube, DaskVaryingResolutionSpectralCube

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/spectral_cube/__init__.py:3
      1 # Licensed under a 3-clause BSD style license - see LICENSE.rst
----> 3 from ._astropy_init import __version__, test
      5 from pkg_resources import get_distribution, DistributionNotFound
      7 from .spectral_cube import (SpectralCube, VaryingResolutionSpectralCube)

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/spectral_cube/_astropy_init.py:7
      5 import os
      6 from warnings import warn
----> 7 from astropy.config.configuration import (
      8     update_default_config,
      9     ConfigurationDefaultMissingError,
     10     ConfigurationDefaultMissingWarning)
     12 try:
     13     from .version import version as __version__

ImportError: cannot import name 'update_default_config' from 'astropy.config.configuration' (/Users/samrose/opt/anaconda3/envs/webb/lib/python3.10/site-packages/astropy/config/configuration.py)``

Expected behavior

No response

Browser

No response

Jupyter

jupyter --version IPython : 8.10.0 ipykernel : 6.21.2 ipywidgets : 8.1.3 jupyter_client : 7.4.1 jupyter_core : 5.2.0 jupyter_server : 1.23.6 jupyterlab : 3.6.1 nbclient : 0.7.2 nbconvert : 7.2.9 nbformat : 5.7.3 notebook : 6.5.2 qtconsole : 5.4.1 traitlets : 5.9.0

Software versions

macOS-10.16-x86_64-i386-64bit Python 3.10.9 (main, Jan 11 2023, 09:18:20) [Clang 14.0.6 ] Numpy 1.25.2 astropy 6.1.2 matplotlib 3.7.0 scipy 1.9.3 scikit-image 0.24.0 asdf 3.2.0 stdatamodels 2.0.0 gwcs 0.21.0 regions 0.7 specutils 1.16.0 specreduce 1.3.0 photutils 1.12.0 astroquery 0.4.6 pyyaml 6.0.1 asteval 0.9.29 idna 3.4 traitlets 5.9.0 bqplot 0.12.43 bqplot-image-gl 1.4.11 glue-core 1.21.1 glue-jupyter 0.22.0 glue-astronomy 0.10.0 echo 0.8.0 ipyvue 1.9.0 ipyvuetify 1.8.4 ipysplitpanes 0.2.0 ipygoldenlayout 0.4.0 ipypopout 1.0.0 Jinja2 3.1.2 voila 0.4.0 vispy 0.12.1 sidecar 0.5.2

kecnry commented 3 months ago

What version of jdaviz are you seeing this? The upcoming release of jdaviz will require astropy 6.0+, but maybe there is something that we need to backport as a bugfix to jdaviz 3.10.x that slipped by. (And while you're at it, can you please update the issue description with all the versions of python packages listed above so we can try to reproduce and track down what's happening?) Thanks!

samrose30 commented 3 months ago

Using jdaviz 3.10.3, software packages updated above, thanks!

pllim commented 3 months ago

@samrose30 , can you please upgrade spectral-cube ?

pip install spectral-cube -U

samrose30 commented 3 months ago

after updating spectral cube from 0.6.0 to 0.6.5 the same traceback error appears when trying to import jdaviz

pllim commented 3 months ago

The offending code was removed last year in https://github.com/radio-astro-tools/spectral-cube/pull/891 (released in v0.6.3). So it is quite impossible to get that traceback in 0.6.5. Did you restart your Python session and so on?

pllim commented 3 months ago

Also for completeness, Jdaviz does not use spectral-cube but glue pulls it in anyway, hence the trouble of us unable to pin it directly.

Related:

samrose30 commented 3 months ago

ImportError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from jdaviz import Cubeviz

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/jdaviz/init.py:15 12 test = TestRunner.make_test_runner_in(os.path.dirname(file)) 14 # Top-level API as exposed to users. ---> 15 from jdaviz.app import * # noqa: F401, F403 16 from jdaviz.configs.specviz import Specviz # noqa: F401 17 from jdaviz.configs.specviz2d import Specviz2d # noqa: F401

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/jdaviz/app.py:31 29 from glue.core.units import unit_converter 30 from glue_astronomy.spectral_coordinates import SpectralCoordinates ---> 31 from glue_astronomy.translators.regions import roi_subset_state_to_region 32 from glue_jupyter.app import JupyterApplication 33 from glue_jupyter.common.toolbar_vuetify import read_icon

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/glue_astronomy/translators/init.py:3 1 from . import nddata # noqa 2 from . import regions # noqa ----> 3 from . import spectral_cube # noqa 4 from . import spectrum1d # noqa 5 from . import trace # noqa

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/glue_astronomy/translators/spectral_cube.py:9 6 from astropy import units as u 7 from astropy.wcs import WCSSUB_STOKES, WCS ----> 9 from spectral_cube import BooleanArrayMask 10 from spectral_cube.spectral_cube import (BaseSpectralCube, SpectralCube, 11 VaryingResolutionSpectralCube) 12 from spectral_cube.dask_spectral_cube import DaskSpectralCube, DaskVaryingResolutionSpectralCube

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/spectral_cube/init.py:5 1 # Licensed under a 3-clause BSD style license - see LICENSE.rst 3 from ._astropy_init import version, test ----> 5 from .spectral_cube import (SpectralCube, VaryingResolutionSpectralCube) 6 from .dask_spectral_cube import (DaskSpectralCube, DaskVaryingResolutionSpectralCube) 7 from .stokes_spectral_cube import StokesSpectralCube

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/spectral_cube/spectral_cube.py:33 29 from astropy.io.registry import UnifiedReadWriteMethod 31 import numpy as np ---> 33 from radio_beam import Beam, Beams 35 from . import cube_utils 36 from . import wcs_utils

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/radio_beam/init.py:3 1 # Licensed under a 3-clause BSD style license - see LICENSE.rst ----> 3 from ._astropy_init import version, test 5 from pkg_resources import get_distribution, DistributionNotFound 7 from .beam import (Beam, EllipticalGaussian2DKernel, 8 EllipticalTophat2DKernel)

File ~/opt/anaconda3/envs/webb/lib/python3.10/site-packages/radio_beam/_astropy_init.py:21 19 import os 20 from warnings import warn ---> 21 from astropy.config.configuration import ( 22 update_default_config, 23 ConfigurationDefaultMissingError, 24 ConfigurationDefaultMissingWarning) 26 # Create the test function for self test 27 from astropy.tests.runner import TestRunner

ImportError: cannot import name 'update_default_config' from 'astropy.config.configuration' (/Users/samrose/opt/anaconda3/envs/webb/lib/python3.10/site-packages/astropy/config/configuration.py)

After restarting python session, it is a different traceback

pllim commented 3 months ago

Ah, that is from yet another package we don't need but got pulled in by glue-astronomy. Please update this too.

pip install radio-beam -U

samrose30 commented 3 months ago

0.3.4 to 0.3.7 and that fixes it, thanks!

pllim commented 3 months ago

Good to hear. Thanks for letting us know!