bjlittle / geovista

Cartographic rendering and mesh analytics powered by PyVista
https://geovista.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
142 stars 22 forks source link

geovista.pantry is not a package - VS Code #965

Open felixdellner opened 3 weeks ago

felixdellner commented 3 weeks ago

🐛 Bug Report

ModuleNotFoundError: No module named 'geovista.pantry.data'; 'geovista.pantry' is not a package

How to Reproduce

Trying to run the examples provided here gives the above error, specifically this line raises the error from geovista.pantry.data import nemo_orca2_gradient

Expected Behaviour

A working example :)

Environment

Tried

scooby --report geovista

or


----------------------------------------------------------------------------------------

                 OS : Windows (10 10.0.22631 SP0 Multiprocessor Free)
             CPU(s) : 12
            Machine : AMD64
       Architecture : 64bit
                RAM : 15.9 GiB
        Environment : Python
         GPU Vendor : NVIDIA Corporation
       GPU Renderer : NVIDIA GeForce RTX 2060/PCIe/SSE2
        GPU Version : 4.5.0 NVIDIA 537.70

  Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit
  (AMD64)]

            cartopy : 0.23.0
              click : 8.1.3
click-default-group : 1.2.4
            cmocean : 4.0.3
           colorcet : Module not found
           geovista : 0.5.0.dev464
         matplotlib : 3.5.2
            netcdf4 : 1.7.1.post1
              numpy : 1.26.4
       platformdirs : 4.1.0
              pooch : 1.8.2
           pykdtree : 1.3.12
             pyproj : 3.6.1
            pyvista : 0.43.10
             scooby : 0.10.0
                vtk : 9.3.1
            IPython : 8.20.0
        fastparquet : 2024.5.0
         ipywidgets : 8.1.3
         jupyterlab : 4.0.10
       nest_asyncio : 1.5.8
             pandas : 2.1.4
              scipy : 1.8.1
              trame : 3.6.3
       trame_client : 3.2.1
       trame_server : 3.0.2
          trame_vtk : 2.8.9
      trame_vuetify : 2.6.0
               tqdm : 4.64.0
             wslink : 2.1.1
----------------------------------------------------------------------------------------

Additional Context

This only happens in Visual Studio Code - in a separate Jupyter Notebook it runs as expected (where I however can not get VTK to run, but I think this might be my own fault, otherwise I'll submit another issue!)

welcome[bot] commented 3 weeks ago

📢 Nice one! Your first issue! Thanks for telling us how to improve geovista 📢

bjlittle commented 3 weeks ago

Hey @felixdellner!

Great to hear from you, and thanks for raising this issue :+1:

Thanks also for including the scooby report, which is really helpful.

I'm guessing that you're using a development installation of geovista given the version is 0.5.0.dev464 and you also mentioned that the example is working outside vscode.

I suspect this might be an issue with the lazy-loader package (and vscode), which we use within geovista to support lazy imports.

Would it be possible for you to set the EAGER_IMPORT environment variable to disable lazy imports to see if this is indeed the root of the problem with vscode, and let me know the outcome?

For reference see here and here.

Also, a quick fix alternative for the example in question might be to explicitly import geovista.pantry as follows:

import geovista as gv
import geovista.pantry                                 # <------ force the import
from geovista.pantry.data import nemo_orca2_gradient
from geovista.pantry.meshes import ZLEVEL_SCALE_CLOUD
import geovista.theme

Could you also give that a try please?

Thanks :+1:

bjlittle commented 3 weeks ago

@all-contributors please add @felixdellner for bug and ideas

allcontributors[bot] commented 3 weeks ago

@bjlittle

I've put up a pull request to add @felixdellner! :tada:

felixdellner commented 3 weeks ago

@bjlittle Huge thanks for the quick reply Bill and the great library! It works just fine on my work Mac and in a separate Notebook. I tried both approaches, and now it compiles! :)

However, now I get a blank frame.

(Assuming you meant os.environ["EAGER_IMPORT"] = "disable" for a way around the lazy loading)

bjlittle commented 3 weeks ago

@felixdellner My pleasure!

Thanks for getting back 👍

Okay, this is really useful to know. I might document this for the community as a known issue within vscode.

There may be a way to resolve this without disabling lazy importing, but that'll require a wee bit of investigation on my behalf 👍

Yup, just setting the environment variable to anything triggers disabling the lazy loader. Nice one.

So are you happy for now with this work around?

If so, then please close this issue and I'll spin up another separate one to follow-up with some investigations.

Otherwise, happy to keep this issue open and assist further, if I can.

Thanks 👍

bjlittle commented 3 weeks ago

However, now I get a blank frame.

What do you mean? Can you explain further or show me a screenshot?

felixdellner commented 3 weeks ago

However, now I get a blank frame.

What do you mean? Can you explain further or show me a screenshot?

Sure thing, now it looks like this: image

I'll close this issue (while I'd say the problem remains, I agree that this particular issue might not be the best place to deal with it.)

bjlittle commented 2 weeks ago

@felixdellner I've done a bit more digging into this, and I've decided to re-open this issue as I believe that I've not fully implemented lazy loading correctly within geovista, given my rediscovery of https://scientific-python.org/specs/spec-0001/#type-checkers.

I'd like to attempt to re-address this, if you've still got the time and motivation to kick the tyres ?