KEMBAR78
[DebuggerV2] Highlight stack frame being shown in SourceCodeComponent by caisq · Pull Request #3550 · tensorflow/tensorboard · GitHub
Skip to content

Conversation

@caisq
Copy link
Contributor

@caisq caisq commented Apr 25, 2020

  • Motivation for features / changes
    • Make it clearer in the StackFrameComponent which frame (if any) is being highlighted in the SourceCodeComponent.
  • Technical description of changes
    • In StackFrameContainer's internal selector, add a boolean field to the return value called focused. It is used in the template ng html to apply a CSS class (.focused-stack-frame) to the focused stack frame and only the focused stack frame.
    • While adding new unit test for the new feature, simplify existing ones by using overrideSelector.
    • To conform to style guide, replace toEqual() with toBe() where applicable in the touched unit tests.
  • Screenshots of UI changes
    • image
  • Detailed steps to verify changes work correctly (as executed by you)
    • Unit test added
    • Existing unit tests for StackFrameContainer are simplified by replacing setState() with overrideSelector().

@caisq caisq changed the title Dbg2 highlight stack frame [DebuggerV2] Highlight stack frame being shown in SourceCodeComponent Apr 25, 2020
@caisq caisq marked this pull request as ready for review April 25, 2020 19:13
@caisq caisq requested a review from psybuzz April 25, 2020 19:18
Copy link
Contributor

@psybuzz psybuzz 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! Just some minor comments

expect(functionElements[2].nativeElement.innerText).toEqual(
stackFrame2[3]
expect(focusedFilePathElement.nativeElement.innerText).toBe(
stackFrame1[1].slice(stackFrame1[1].lastIndexOf('/') + 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

This same slicing logic is on L928, 932, 936. Perhaps create a helper function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is a test, I'll opt not to add a helper function now. It's my preference to keep test logic explicit even when it's sometimes a little more verbose.

expect(filePathElements[0].nativeElement.innerText).toEqual(
expect(filePathElements.length).toBe(3);
expect(filePathElements[0].nativeElement.innerText).toBe(
stackFrame0[1].slice(stackFrame0[1].lastIndexOf('/') + 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

While reading this test, I found myself going back to lookup which indices in the stackFrame array correspond to which fields. I think it might be helpful for readability if createTestStackFrame returned an object with named properties like 'filePath'. Although since that was outside of this PR, it's fine to not change in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add a TODO item to debugger_types.ts. The background here is this is how Python's traceback.extract_tb returns tuples like (file_path, lineno, function_name). So this "leaks" into the data types in debugger v2 a little.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, thanks for the todo+context.

expect(filePathElements[1].nativeElement.innerText).toBe(
stackFrame1[1].slice(stackFrame1[1].lastIndexOf('/') + 1)
);
expect(filePathElements[1].nativeElement.title).toEqual(stackFrame1[1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this also use toBe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Done.

);
expect(stackFrameContainers.length).toEqual(0);
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Use toBe on L1028?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

@caisq caisq left a comment

Choose a reason for hiding this comment

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

Thanks for the review!

expect(filePathElements[1].nativeElement.innerText).toBe(
stackFrame1[1].slice(stackFrame1[1].lastIndexOf('/') + 1)
);
expect(filePathElements[1].nativeElement.title).toEqual(stackFrame1[1]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Done.

expect(functionElements[2].nativeElement.innerText).toEqual(
stackFrame2[3]
expect(focusedFilePathElement.nativeElement.innerText).toBe(
stackFrame1[1].slice(stackFrame1[1].lastIndexOf('/') + 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is a test, I'll opt not to add a helper function now. It's my preference to keep test logic explicit even when it's sometimes a little more verbose.

);
expect(stackFrameContainers.length).toEqual(0);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

expect(filePathElements[0].nativeElement.innerText).toEqual(
expect(filePathElements.length).toBe(3);
expect(filePathElements[0].nativeElement.innerText).toBe(
stackFrame0[1].slice(stackFrame0[1].lastIndexOf('/') + 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add a TODO item to debugger_types.ts. The background here is this is how Python's traceback.extract_tb returns tuples like (file_path, lineno, function_name). So this "leaks" into the data types in debugger v2 a little.

@caisq caisq merged commit b929fae into tensorflow:master Apr 27, 2020
caisq added a commit to caisq/tensorboard that referenced this pull request May 19, 2020
…tensorflow#3550)

* Motivation for features / changes
  * Make it clearer in the StackFrameComponent which frame (if any) is being highlighted in the SourceCodeComponent.
* Technical description of changes
  * In StackFrameContainer's internal selector, add a boolean field to the return value called `focused`. It is used in the template ng html to apply a CSS class (`.focused-stack-frame`) to the focused stack frame and only the focused stack frame.
  * While adding new unit test for the new feature, simplify existing ones by using `overrideSelector`.
  * To conform to style guide, replace `toEqual()` with `toBe()` where applicable in the touched unit tests.
* Screenshots of UI changes
  * ![image](https://user-images.githubusercontent.com/16824702/80288736-ed102300-8707-11ea-9638-7aa197a23ff6.png)
* Detailed steps to verify changes work correctly (as executed by you)
  * Unit test added
  * Existing unit tests for `StackFrameContainer` are simplified by replacing `setState()` with `overrideSelector()`.
caisq added a commit that referenced this pull request May 27, 2020
…#3550)

* Motivation for features / changes
  * Make it clearer in the StackFrameComponent which frame (if any) is being highlighted in the SourceCodeComponent.
* Technical description of changes
  * In StackFrameContainer's internal selector, add a boolean field to the return value called `focused`. It is used in the template ng html to apply a CSS class (`.focused-stack-frame`) to the focused stack frame and only the focused stack frame.
  * While adding new unit test for the new feature, simplify existing ones by using `overrideSelector`.
  * To conform to style guide, replace `toEqual()` with `toBe()` where applicable in the touched unit tests.
* Screenshots of UI changes
  * ![image](https://user-images.githubusercontent.com/16824702/80288736-ed102300-8707-11ea-9638-7aa197a23ff6.png)
* Detailed steps to verify changes work correctly (as executed by you)
  * Unit test added
  * Existing unit tests for `StackFrameContainer` are simplified by replacing `setState()` with `overrideSelector()`.
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.

3 participants