Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FX] Make wrapped functions traceable #46692

Closed
wants to merge 3 commits into from

Conversation

jamesr66a
Copy link
Collaborator

@jamesr66a jamesr66a commented Oct 22, 2020

Stack from ghstack:

This patch does two things:

  1. For the purpose of introspecting arguments, this patch adds a call to inspect.unwrap to unwrap any layers of functools.wraps decorators on the function. This is similar to what inspect.signature is doing as well. This allows for functions/methods with wrapping decorators applied to them to be traced
  2. Fixes a poor error message where a variadic method without an explicit self argument was trying to be traced. I elected to just throw in this case for now. Conceptually we could support this but I was running into some weird correctness issues and I think that's better addressed in a follow-up PR.

Closes #46665

Differential Revision: D24465958

This patch does two things:
1. For the purpose of introspecting arguments, this patch adds a call to `inspect.unwrap` to unwrap any layers of `functools.wraps` decorators on the function. This is similar to what `inspect.signature` is doing as well. This allows for functions/methods with wrapping decorators applied to them to be traced
2. Fixes a poor error message where a variadic method without an explicit `self` argument was trying to be traced. I elected to just throw in this case for now. Conceptually we could support this but I was running into some weird correctness issues and I think that's better addressed in a follow-up PR.

Closes #46665

Differential Revision: [D24465958](https://our.internmc.facebook.com/intern/diff/D24465958)

[ghstack-poisoned]
@jamesr66a jamesr66a requested review from zdevito and suo October 22, 2020 00:22
This patch does two things:
1. For the purpose of introspecting arguments, this patch adds a call to `inspect.unwrap` to unwrap any layers of `functools.wraps` decorators on the function. This is similar to what `inspect.signature` is doing as well. This allows for functions/methods with wrapping decorators applied to them to be traced
2. Fixes a poor error message where a variadic method without an explicit `self` argument was trying to be traced. I elected to just throw in this case for now. Conceptually we could support this but I was running into some weird correctness issues and I think that's better addressed in a follow-up PR.

Closes #46665

Differential Revision: [D24465958](https://our.internmc.facebook.com/intern/diff/D24465958)

[ghstack-poisoned]
@dr-ci
Copy link

dr-ci bot commented Oct 22, 2020

💊 CI failures summary and remediations

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


None of the CI failures appear to be your fault 💚



🚧 1 ongoing upstream failure:

These were probably caused by upstream breakages that are not fixed yet:


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 3 times.

jamesr66a pushed a commit that referenced this pull request Oct 22, 2020
ghstack-source-id: 97c7d1b97ed9a6e54dacfe032ea7871820c150b7
Pull Request resolved: #46692
Copy link
Collaborator

@dzhulgakov dzhulgakov left a comment

Choose a reason for hiding this comment

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

Magic

@facebook-github-bot
Copy link
Contributor

@jamesr66a merged this pull request in 9ccf85b.

@facebook-github-bot facebook-github-bot deleted the gh/jamesr66a/304/head branch October 26, 2020 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants