Giter Club home page Giter Club logo

Comments (5)

rchiodo avatar rchiodo commented on July 18, 2024

Sorry I should have said, the code runs fine, it just can't be interpreted by a static type checker. Our users are confused by this because they can execute their code just fine, but Pylance doesn't think there's a module called keras.models. This makes it harder for them to write code using keras.models because there's no intellisense for it anymore.

from keras.

fchollet avatar fchollet commented on July 18, 2024

@mattdangerw @sampathweb can we resolve this?

from keras.

fchollet avatar fchollet commented on July 18, 2024

The code added in this commit dynamically adds the path to api to the sys path. This isn't something a static type checker can handle.

Basically, publicly-exported APIs are in keras/api/, rather than in the top-level keras/ folder. This is not unlike, e.g. TF APIs, which live in tf._api.v2. Can PyLance only handle packages where the directory structure matches the public namespace?

from keras.

rchiodo avatar rchiodo commented on July 18, 2024

Can PyLance only handle packages where the directory structure matches the public namespace?

We should be able to handle anything that's through static imports. The old code was importing all of the api modules, so Pylance could tell that those were imported in the __init__.py.

The code in the commit I referenced changed to add the api path to the sys.path at runtime. We don't execute any python code, so we can't actually figure out that api should be on the sys.path.

It's kind of similar to how we don't support PEP 660 because we can't execute the dynamic code in the .pth files.

Here's a similar example:
microsoft/pyright#6272

from keras.

rchiodo avatar rchiodo commented on July 18, 2024

We also have a problem with tensorflow too when it imports keras like this:

from tensorflow.keras import activations, initializers, layers, losses, metrics, models, optimizers, regularizers

This is because keras is added to the tensorflow package dynamically.

from keras.

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.