Skip to content

Conversation

@laithsakka
Copy link
Contributor

@laithsakka laithsakka commented Aug 22, 2024

I had a night mare rewriting tests in test_misc.py specifically :

  1. graphs can have comments that refers to my files "/lsakka/.." we really dont care about comments add option to ignore comments.
  2. empty lines added when EXPECTTEST_ACCEPT=1 are changed with linter causing tests to fail or linter fail!
    add flag to ignore empty lines.
  3. EXPECTTEST_ACCEPT fails when the text have some not readable characters. those should not effect comparing strings, also those causes weird diffs comments when tests fails. I removed ansi_escape chars Re-design functionalization to minimize miss in-placing when args are views. #133045

this is used in

Stack from ghstack (oldest at bottom):

…optins to skip comments and empty lines

[ghstack-poisoned]
@laithsakka laithsakka requested a review from a team as a code owner August 22, 2024 17:34
@pytorch-bot
Copy link

pytorch-bot bot commented Aug 22, 2024

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 888c7ee with merge base 938f37b (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@laithsakka laithsakka changed the title remove ansi escape chars before calling assertExpectedInline and add optins to skip comments and empty lines remove ansi escape chars in assertExpectedInline and add options to skip comments and empty lines Aug 22, 2024
@laithsakka laithsakka changed the title remove ansi escape chars in assertExpectedInline and add options to skip comments and empty lines Remove ansi escape chars in assertExpectedInline and add options to skip comments and to skip empty lines Aug 22, 2024
@laithsakka laithsakka requested review from oulgen and zou3519 August 22, 2024 17:41
Copy link
Contributor

@aorenste aorenste left a comment

Choose a reason for hiding this comment

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

Is this actually better than finding where the escape codes are coming from and adding an option to turn them off?
(Where are they coming from? Something internal or external?)

Copy link
Contributor

@oulgen oulgen left a comment

Choose a reason for hiding this comment

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

This comes from colored argument to _gen_python_code

verbose: bool = False, include_stride: bool = False, include_device: bool = False, colored: bool = False

Can you just set it false for unit tests?

@laithsakka
Copy link
Contributor Author

laithsakka commented Aug 22, 2024

This comes from colored argument to _gen_python_code

verbose: bool = False, include_stride: bool = False, include_device: bool = False, colored: bool = False

Can you just set it false for unit tests?

we can but why not making the tool insensitive to those?
note that comparing when those exists is not issue, its just when:

  1. EXPECTTEST_ACCEPT then it will fail .
  2. if it fails for a text change the diff comment generates weired hints.

@laithsakka
Copy link
Contributor Author

laithsakka commented Aug 22, 2024

Is this actually better than finding where the escape codes are coming from and adding an option to turn them off? (Where are they coming from? Something internal or external?)

yeh i think its better, since when comparing strings anyway those are not taken into account.

Copy link
Contributor

@aorenste aorenste left a comment

Choose a reason for hiding this comment

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

Approving - I think this isn't unreasonable. In general our tools shouldn't be unconditionally emitting ansi codes in their output, but maybe that's a separate battle.

def assertExpectedInline(self, actual, expect, skip=0):
def _remove_ansi_escape(self, input):
# 7-bit C1 ANSI sequences
ansi_escape = re.compile(r'''
Copy link
Contributor

Choose a reason for hiding this comment

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

I dislike the fact that this regex uses sequences that cross chartype boundaries (like "@-Z") but in general is reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alternatively I can add a flag ignore_ansi_escape, like the other two flags.

…ptions to skip comments and to skip empty lines"

I had a night mare rewriting tests in test_misc.py specifically :
1. graphs can have comments that refers to my files "/lsakka/.." we really dont care about comments add option to ignore comments. 
2. empty lines added when EXPECTTEST_ACCEPT=1  are changed with linter causing tests to fail or linter fail!
add flag to ignore empty lines. 
3. EXPECTTEST_ACCEPT fails when the text have some not readable characters. those should not effect comparing strings, also those causes weird diffs comments when tests fails. I removed ansi_escape chars #133045

this is used in  
 



[ghstack-poisoned]
@laithsakka
Copy link
Contributor Author

@pytorchbot merge

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

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 Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants