Skip to content

Conversation

PaliC
Copy link
Contributor

@PaliC PaliC commented Jul 5, 2022

Summary:
This pr addresses pytorch/multipy#82 and pytorch/multipy#44. The changes will be copied over to pytorch/multipy as well.

A C extension module behaves a bit differently than a normal python package as it does not contain a __path__ attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module and checks if the module we are looking for is in it's children.

For example, if we are importing torch._C._nn we check if the parent torch._C is a C extension module if necessary, and then check if torch._C._nn is a proper child of torch._C.

Differential Revision: D37630120

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jul 5, 2022

🔗 Helpful links

✅ No Failures (0 Pending)

As of commit 20daf5e (more details on the Dr. CI page):

Expand to see more

💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37630120

@PaliC PaliC requested review from d4l3k, priyaramani and kurman July 5, 2022 22:28
PaliC added a commit to PaliC/multipy that referenced this pull request Jul 5, 2022
…multipy

Summary:
This pr addresses pytorch#82 and pytorch#44.

A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module  and checks if the module we are looking for is in it's children.

For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`.

The corresponding PR in torch.package is pytorch/pytorch#80917

Differential Revision: D37630606

fbshipit-source-id: 4fc5e75524eebc4f71fe978f42fd80e48900d2e4
PaliC added a commit to PaliC/multipy that referenced this pull request Jul 5, 2022
…multipy (pytorch#91)

Summary:
Pull Request resolved: pytorch#91

This pr addresses pytorch#82 and pytorch#44.

A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module  and checks if the module we are looking for is in it's children.

For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`.

The corresponding PR in torch.package is pytorch/pytorch#80917

Differential Revision: D37630606

fbshipit-source-id: 65e549b66550d676a0e766a5f0c38b417f038a20
PaliC added a commit to PaliC/multipy that referenced this pull request Jul 6, 2022
…multipy (pytorch#91)

Summary:
Pull Request resolved: pytorch#91

This pr addresses pytorch#82 and pytorch#44.

A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module  and checks if the module we are looking for is in it's children.

For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`.

The corresponding PR in torch.package is pytorch/pytorch#80917

Differential Revision: D37630606

fbshipit-source-id: f18991665618291664a0b3b34c95f5dbb91247af
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37630120

@PaliC PaliC force-pushed the export-D37630120 branch from d7ed228 to 7bf0fef Compare July 6, 2022 00:36
# so we search if the package is actually there or not before calling the error.
if isinstance(
parent_module.__loader__,
_frozen_importlib_external.ExtensionFileLoader,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use https://docs.python.org/3/library/importlib.html#importlib.machinery.ExtensionFileLoader instead of _frozen_importlib_external since that's an internal module?
It's an alias for it

PaliC added a commit to PaliC/multipy that referenced this pull request Jul 11, 2022
…multipy (pytorch#91)

Summary:
Pull Request resolved: pytorch#91

This pr addresses pytorch#82 and pytorch#44.

A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module  and checks if the module we are looking for is in it's children.

For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`.

The corresponding PR in torch.package is pytorch/pytorch#80917

Reviewed By: d4l3k

Differential Revision: D37630606

fbshipit-source-id: 19e6bb808b893aaab39790929e130eb0bbd62d91
@PaliC PaliC force-pushed the export-D37630120 branch from 7bf0fef to 17b2cd6 Compare July 11, 2022 17:52
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37630120

PaliC added a commit to PaliC/multipy that referenced this pull request Jul 11, 2022
…multipy (pytorch#91)

Summary:
Pull Request resolved: pytorch#91

This pr addresses pytorch#82 and pytorch#44.

A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module  and checks if the module we are looking for is in it's children.

For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`.

The corresponding PR in torch.package is pytorch/pytorch#80917

Reviewed By: d4l3k

Differential Revision: D37630606

fbshipit-source-id: ee562573ea4c0bbc43facc5ae9a0fc4ad8f29cd6
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37630120

@PaliC PaliC force-pushed the export-D37630120 branch from 17b2cd6 to f05ab71 Compare July 11, 2022 18:01
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37630120

@PaliC PaliC force-pushed the export-D37630120 branch from f05ab71 to 3bf527d Compare July 11, 2022 18:25
)

Summary:
Pull Request resolved: pytorch#80917

This pr addresses pytorch/multipy#82 and pytorch/multipy#44. The changes will be copied over to [pytorch/multipy](https://github.com/pytorch/multipy) as well.

A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module  and checks if the module we are looking for is in it's children.

For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`.

Test Plan: buck test caffe2/test:package

Reviewed By: d4l3k

Differential Revision: D37630120

fbshipit-source-id: 920f0838bfd7f9b4497b606125a688d319579a0c
@PaliC PaliC force-pushed the export-D37630120 branch from 3bf527d to 20daf5e Compare July 11, 2022 20:37
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D37630120

facebook-github-bot pushed a commit to pytorch/multipy that referenced this pull request Jul 12, 2022
…multipy (#91)

Summary:
Pull Request resolved: #91

This pr addresses #82 and #44.

A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module  and checks if the module we are looking for is in it's children.

For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`.

The corresponding PR in torch.package is pytorch/pytorch#80917

Reviewed By: d4l3k

Differential Revision: D37630606

fbshipit-source-id: 59b5b7c291ccecef9f598a93c33719d348a339f5
@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a merge job. Check the current status here

@github-actions
Copy link
Contributor

Hey @PaliC.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

facebook-github-bot pushed a commit that referenced this pull request Jul 12, 2022
Summary:
Pull Request resolved: #80917

This pr addresses pytorch/multipy#82 and pytorch/multipy#44. The changes will be copied over to [pytorch/multipy](https://github.com/pytorch/multipy) as well.

A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module  and checks if the module we are looking for is in it's children.

For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`.

Test Plan: buck test caffe2/test:package

Reviewed By: d4l3k

Differential Revision: D37630120

fbshipit-source-id: 4a3b6a465cf03c83d75b04ccc3aceb41b4e9ccc9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants