Git Product home page Git Product logo

Comments (7)

tsupinie avatar tsupinie commented on July 19, 2024

Yes, I see what you mean. I agree that just importing the sharptab module shouldn't require importing all the other stuff that requires PySide.

It appears that when you run import sharppy.sharptab, it executes all the statements in sharppy/__init__.py, even though we only want the sharptab submodule. I suppose this makes sense, but it's still counter-intuitive to me. The decision to have all the __init__.py files import all the submodules was made before I started working on SHARPpy. I'll have to decide what's the best course of action for resolving this.

from sharppy.

keltonhalbert avatar keltonhalbert commented on July 19, 2024

I have personally encountered this issue when trying to import on graphic-less servers as well.

To be honest, I didn't know much about how the import system was supposed to be structured, so that's how it ended up in the state it's in. I'm all in favor of changing it though. What's the best means of resolving this?

from sharppy.

wblumberg avatar wblumberg commented on July 19, 2024

Ditto. I've just been commenting out all references to PySide as a solution, however it's possible the "import pyside" statements could go in a "try, except" block with a message that it's not installed or not found. That should run upon import of any SHARPpy package.

from sharppy.

tsupinie avatar tsupinie commented on July 19, 2024

@wblumberg, that could work, but that doesn't take care of the unused imports that @aarande noted. The unused imports won't break things, but it uses unnecessary time and memory to load all that stuff and then never use it.

One method (and I think my favored one) would be to remove all import statements from the __init__.py files. I've had issues with circular imports with all those in the past, so that would clear them up in the future.

The other method is try to figure out in sharppy/__init__.py if we're just importing the sharptab module and, and if we are, bypass all the rest of the imports. This is not my favored method because a) it's an awful, awful hack and b) I don't know off the top of my head how we'd do it or if there's even a way to do it.

from sharppy.

tsupinie avatar tsupinie commented on July 19, 2024

Okay, I think I've successfully implemented the first method described in my previous post. It's checked into the xenia (development) branch.

from sharppy.

aarande avatar aarande commented on July 19, 2024

Thanks for your work on this! I just recently was able to grab the xenia release and work with it. It is working fine now but I am a little worried we may have taken this too far. I think we just needed to remove the imports from the top level sharppy init.py but not from sharptab. It would still be nice to be able to do from sharppy import sharptab and then be able to call things like sharptab.profile, sharptab.interp, etc. The problem came about because by calling from sharppy import sharptab it would run the init.py in sharppy which would import all the viz stuff. I worry a little about namespace collision now since have to do a from sharppy.sharptab import * or name the module level file. It can also get confusing to a user when they are using names like profile, interp, etc. It would keep things cleaner and avoid namespace collision if we were calling them by sharptab.profile, sharptab.interp, etc.

I will play around with this some more and let you know what I find and maybe submit a pull request.

Again thanks for all your work!

from sharppy.

tsupinie avatar tsupinie commented on July 19, 2024

The internal SHARPpy code makes frequent use of the import sharppy.sharptab.profile as profile constructs, so might I suggest that, if you don't want to clutter up your namespace. We (I) decided to go with the "explicit is better than implicit" philosophy when re-designing the package imports. And a lot of the internal code was already imported that way, anyway.

from sharppy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.