Skip to content

Introduce UserDefinedExceptionClassVariable #146504

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

Closed

Conversation

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Feb 5, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/146504

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 7507f1c with merge base 50c9f6d (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@guilhermeleobas guilhermeleobas marked this pull request as ready for review February 10, 2025 22:15
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Copy link
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

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

UserDefinedExceptionClassVariable and UserDefinedExceptionObjectVariable still own an ExceptionVariable

[ghstack-poisoned]
[ghstack-poisoned]
return variables.ConstantVariable(None)
return super().call_method(tx, name, args, kwargs)

def __getattr__(self, name):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The UserDefinedExceptionObjectVariable holds an exception variable under the hood (self.exc_vt). This function is to redirect some of the calls to the underlying self.exc_vt variable if the outer object doesn't overload it. For instance, a getattr(obj, '__context__') will redirect to getattr(obj.exc_vt, '__context__').

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to manually write out what methods we're passing along? Otherwise the code gets harder to read. e.g. if you just need __context__ then just define a context property that calls self.exc_vt

so I guess the question is, how many fields do you need to pass through?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just two. I changed the implementation, so this is more explicit.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Copy link
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

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

Looks good to me, I'll defer to @anijain2305 for the final review (and what to do about the getattr piece)

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #146502

1 similar comment
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #146502

pytorchmergebot pushed a commit that referenced this pull request Mar 11, 2025
@github-actions github-actions bot deleted the gh/guilhermeleobas/105/head branch April 12, 2025 02:10
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.

6 participants