Skip to content

Add __main__ guards to fx tests #154715

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

AnthonyBarbier
Copy link
Collaborator

@AnthonyBarbier AnthonyBarbier commented May 30, 2025

This PR is part of a series attempting to re-submit #134592 as smaller PRs.

In fx tests:

  • Add and use a common raise_on_run_directly method for when a user runs a test file directly which should not be run this way. Print the file which the user should have run.
  • Raise a RuntimeError on tests which have been disabled (not run)
  • Remove any remaining uses of "unittest.main()""

cc @ezyang @SherlockNoMad @EikanWang @jgong5 @wenzhe-nrv

@AnthonyBarbier AnthonyBarbier requested a review from a team as a code owner May 30, 2025 10:27
Copy link

pytorch-bot bot commented May 30, 2025

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ You can merge normally! (1 Unrelated Failure)

As of commit 7d07eed with merge base 0d0058d (image):

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

@pytorch-bot pytorch-bot bot added the release notes: fx release notes category label May 30, 2025
@AnthonyBarbier
Copy link
Collaborator Author

I don't think the CI failure is related to my changes?

This PR is part of a series attempting to re-submit pytorch#134592 as smaller PRs.

In fx tests:

- Add and use a common raise_on_run_directly method for when a user runs a test file directly which should not be run this way. Print the file which the user should have run.
- Raise a RuntimeError on tests which have been disabled (not run)
- Remove any remaining uses of "unittest.main()""
@AnthonyBarbier AnthonyBarbier force-pushed the anthonyb/guarded_tests_fx branch from f4cbd1c to 7d07eed Compare June 2, 2025 17:16
@AnthonyBarbier
Copy link
Collaborator Author

Same here: @Skylion007 Could you please merge the PR if you're happy with it? (I don't have the permissions to do it)

@AnthonyBarbier
Copy link
Collaborator Author

@pytorchmergebot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jun 4, 2025
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

angelayi pushed a commit to angelayi/pytorch that referenced this pull request Jun 5, 2025
This PR is part of a series attempting to re-submit pytorch#134592 as smaller PRs.

In fx tests:

- Add and use a common raise_on_run_directly method for when a user runs a test file directly which should not be run this way. Print the file which the user should have run.
- Raise a RuntimeError on tests which have been disabled (not run)
- Remove any remaining uses of "unittest.main()""

Pull Request resolved: pytorch#154715
Approved by: https://github.com/Skylion007
pytorchmergebot pushed a commit that referenced this pull request Aug 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request fx Merged open source release notes: fx release notes category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants