Git Product home page Git Product logo

Comments (6)

stroxler avatar stroxler commented on May 28, 2024 1

Hi @henrylhtsang.

Unfortunately, there's an architectural issue in Pyre (and a number of other tools too) where we assume that a fully qualified name means something unambiguous in Python, so that torchrec.distributed.shard has to refer to either a module or a function but not both.

The pattern of shadowing a module with a function imported into the parent then causes any tool indexing the code this way to fail to understand it. Until recently, Pyre was failing to analyze the code (which meant it dropped type information) silently, and we recently changed Pyre to warn users that the import can't be analyzed.

This is pretty disruptive, and we also hope we can change Pyre to understand that fully qualified names are not unambiguous and it's necessary to model the effect of an import on scope more precisely, but this will take at least several months for us to fix, possibly longer.

In the meantime, your best bet is probably to rename something. Because you are a library and backward compatibility matters, it's tricky to decide what exactly to do, but:

  • if users typically run from torchrec.distributed import shard then you probably don't want to change the meaning of that, which means you might want to change shard.py to sharding.py or something like that
  • if you're worried that users are also directly importing the module (import torchrec.distributed.shard, or from torchrec.distributed.shard import <something>, then you could potentially also keep shard.py and modify it to just from .sharding import *. At that point, Pyre won't be able to see shard.py but at least at runtime it will be there, so users won't see breakages (unless they are using Pyre)

from pyre-check.

migeed-z avatar migeed-z commented on May 28, 2024

Totally understand the frustration. This is a known issue. Unfortunately, the fix will take some time to land, so I would recommend finding a workaround.

from pyre-check.

henrylhtsang avatar henrylhtsang commented on May 28, 2024

@migeed-z thanks, is there a timeline?

from pyre-check.

stroxler avatar stroxler commented on May 28, 2024

(You can of course use a # pyre-ignore to suppress the error you are seeing, but unfortunately users of your library who are using Pyre - which includes most Meta users - will run into the same problem in that case so I wouldn't recommend that approach)

from pyre-check.

henrylhtsang avatar henrylhtsang commented on May 28, 2024

@stroxler thanks, will explore changing names

from pyre-check.

vthemelis avatar vthemelis commented on May 28, 2024

This is a duplicate of #232

from pyre-check.

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.