KEMBAR78
safer check for isatty in fx/_utils.py by GoatGirl98 · Pull Request #140876 · pytorch/pytorch · GitHub
Skip to content

Conversation

@GoatGirl98
Copy link
Contributor

@GoatGirl98 GoatGirl98 commented Nov 16, 2024

if no isatty method is defined, it's probably not a tty

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

if no isatty method is defined, it's probably not a tty
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 16, 2024

🔗 Helpful Links

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

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:

✅ No Failures

As of commit f6ab9fd with merge base ce77409 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 16, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@pytorch-bot pytorch-bot bot added the release notes: fx release notes category label Nov 16, 2024

if "colored" in kwargs and not sys.stdout.isatty():
kwargs["colored"] = False
_stream_stdout = getattr(sys, 'stdout')
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to do this? It seems equivalent to accessing sys.stdout

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a reason to do this? It seems equivalent to accessing sys.stdout

I changed sys.stdout to an object that does not imitate _io.TextIOWrapper in my project, so there is no method isatty in this case and will raise AttributeError.

torch._dynamo.exc.InternalTorchDynamoError: AttributeError: 'F' object has no attribute 'isatty'

Copy link
Contributor

Choose a reason for hiding this comment

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

Specifically, why say getattr(sys, 'stdout') when sys.stdout seems like it would work

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah lint complaining about it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah lint complaining about it

My bad, sorry for the inconvenience. Unnecessary code has been removed in the latest commit in this PR.

@ezyang
Copy link
Contributor

ezyang commented Nov 17, 2024

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 17, 2024
@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

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@ezyang
Copy link
Contributor

ezyang commented Nov 19, 2024

@pytorchbot merge

@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

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@GoatGirl98
Copy link
Contributor Author

@pytorchbot merge

@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

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 3 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@GoatGirl98
Copy link
Contributor Author

GoatGirl98 commented Nov 21, 2024

@pytorchbot merge

@ezyang I've made further changes trying to fix the issue for lint no-clang, could you please merge it again? Sorry for the inconvenience. :)

@ezyang
Copy link
Contributor

ezyang commented Nov 22, 2024

Meh FIIINE

@ezyang
Copy link
Contributor

ezyang commented Nov 22, 2024

@pytorchbot merge

@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

pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
if no isatty method is defined, it's probably not a tty

Pull Request resolved: pytorch#140876
Approved by: https://github.com/ezyang
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