You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm noticing what I think is unexpected behaviour when trying to load classes from iris. Basically, many of the submodules are unavailable when only importing the iris module and not running anything. My context is, I want to access specific iris classes (e.g. Cube, CubeList) to provide type hints in my package.
When I run or import the modules separately, they become available under the iris module. I'm using a fresh conda environment with iris 3.2.1 and Python 3.9 The command to create the environment is conda create -n iris python=3.9 iris -c conda-forge.
I was having problems only with the cube module, but after running this snippet, I realised it was happening with other attributes, which led me to believe this may be related to the problem reported in #3242.
Try accessing one of the attributes listed above: iris.cube
Expected behaviour
Have all of the ['_data_manager', '_lazy_data', '_merge', 'analysis', 'aux_factory', 'common', 'coord_systems', 'coords', 'cube', 'std_names', 'time', 'util'] available in the iris module without having to import any submodules or run any functions before.
Environment
I tested this on a Mac and also on a Linux Docker container with iris 3.2 and 3.1.
OS & Version: ['Linux-5.10.76-linuxkit-x86_64-with-glibc2.31', 'macOS-10.16-x86_64-i386-64bit']
Iris Version: ['3.2.1', '3.1']
Please let me know if you need any more information and thank you for any assistance you can provide.
Best,
V
The text was updated successfully, but these errors were encountered:
Thanks for getting in touch @vinisalazar, and with so much helpful detail 🙂. Sorry but this behaviour is intentional (part of #4174) in order to reduce Iris' import time. The previous import time of >1 second was causing problems in some of our users' specialist workflows.
The new behaviour that you have observed means users only import the parts of Iris they need for their script. But it does unfortunately need more granular import commands, as you've demonstrated.
Thanks @trexfeathers for clarifying, that makes sense. I would, however, suggest to add some sort of exception handling providing an informative message, or at least document this behaviour clearly in the documentation page (apologies if that's already the case and I missed it!).
🐛 Bug Report
Hi,
I'm noticing what I think is unexpected behaviour when trying to load classes from iris. Basically, many of the submodules are unavailable when only importing the
iris
module and not running anything. My context is, I want to access specific iris classes (e.g.Cube
,CubeList
) to provide type hints in my package.When I run or import the modules separately, they become available under the
iris
module. I'm using a fresh conda environment with iris 3.2.1 and Python 3.9 The command to create the environment isconda create -n iris python=3.9 iris -c conda-forge
.Here's what's happening:
Strangely, this is solved if I import a module individually:
The same happens if I call any functions from the
iris
module, e.g.iris.load_raw()
.This snippet shows exactly which submodules/attributes become available after importing a submodule individually or running a function:
I was having problems only with the
cube
module, but after running this snippet, I realised it was happening with other attributes, which led me to believe this may be related to the problem reported in #3242.How To Reproduce
Steps to reproduce the behaviour:
conda create -n iris iris python=3.9 -c conda-forge && conda activate
python
import iris
iris.cube
Expected behaviour
Have all of the
['_data_manager', '_lazy_data', '_merge', 'analysis', 'aux_factory', 'common', 'coord_systems', 'coords', 'cube', 'std_names', 'time', 'util']
available in theiris
module without having to import any submodules or run any functions before.Environment
I tested this on a Mac and also on a Linux Docker container with iris 3.2 and 3.1.
['Linux-5.10.76-linuxkit-x86_64-with-glibc2.31', 'macOS-10.16-x86_64-i386-64bit']
['3.2.1', '3.1']
Please let me know if you need any more information and thank you for any assistance you can provide.
Best,
V
The text was updated successfully, but these errors were encountered: