Skip to content
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

Sort run names with leading numbers differently #6664

Merged
merged 6 commits into from
Oct 25, 2023

Conversation

rileyajones
Copy link
Contributor

@rileyajones rileyajones commented Oct 24, 2023

Motivation for features / changes

We have been treating all run names as strings even though some run names are (serialized) numbers and some begin with numbers. This means that sorting worked pretty unintuitively.

Note: I've also changed the behavior around sorting undefined values. When sorting descending they should now appear at the top of the list. This was a recent change but it wasn't clear it was intentional and I found it made the code more complex.

#6651

Internal users see b/278671226

Screenshots of UI changes (or N/A)

Before:
image

After:
image

image

AFTER,
}

interface SortOptions {
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 interface with a single attribute. Is there a reason you cannot just use the enum directly everywhere this interface is used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a pretty complicated function and I thought that using an object as a parameter would make the options provided more readable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am ok with that justification. I think I would prefer naming the enum something more readable....UndefinedValuePlacement?

I cant really think of something good. Maybe this is best.

tensorboard/webapp/runs/views/runs_table/sorting_utils.ts Outdated Show resolved Hide resolved
});
return sortedItems;

function orderFromLocalComparison(
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not understand the name of this function. Maybe just call it compareValues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, compareValues it is.

]);
});

it('places undefined values at the end', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are going to have the ability to place undefined values before(which I am not sure we really need). Then you should have a test for 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.

We kinda have that already, that is what sorts runs with purely numeric run names before runs with leading numbers is checking

Copy link
Contributor

Choose a reason for hiding this comment

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

I can see how that test along with returns undefined when a non numeric value is provided kind of tests for it.

@@ -28,6 +28,7 @@ describe('sorting utils', () => {
expect(parseNumericPrefix('0')).toEqual(0);
expect(parseNumericPrefix('123')).toEqual(123);
expect(parseNumericPrefix('123/')).toEqual(123);
expect(parseNumericPrefix('123/foo')).toEqual(123);
Copy link
Contributor

Choose a reason for hiding this comment

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

This still has a '/' after the number. I was thinking something like 123train. Still just a nit though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, okay. I'll add that case too

@rileyajones rileyajones merged commit e8dd1ca into tensorflow:master Oct 25, 2023
13 checks passed
bmd3k pushed a commit to bmd3k/tensorboard that referenced this pull request Nov 2, 2023
## Motivation for features / changes
We have been treating all run names as strings even though some run
names are (serialized) numbers and some begin with numbers. This means
that sorting worked pretty unintuitively.

Note: I've also changed the behavior around sorting `undefined` values.
When sorting descending they should now appear at the top of the list.
This was a recent change but it wasn't clear it was intentional and I
found it made the code more complex.

tensorflow#6651

Internal users see [b/278671226](http://b/278671226)

## Screenshots of UI changes (or N/A)

Before:

![image](https://github.com/tensorflow/tensorboard/assets/78179109/5f805c37-283d-4f55-b1bf-3dfa4d9ea1da)

After:

![image](https://github.com/tensorflow/tensorboard/assets/78179109/0d740b6e-2ed5-4762-aec0-22400eeb152d)


![image](https://github.com/tensorflow/tensorboard/assets/78179109/5283bade-b4da-401d-9893-932d9fb9d378)
@bmd3k bmd3k mentioned this pull request Nov 2, 2023
bmd3k pushed a commit that referenced this pull request Nov 2, 2023
## Motivation for features / changes
We have been treating all run names as strings even though some run
names are (serialized) numbers and some begin with numbers. This means
that sorting worked pretty unintuitively.

Note: I've also changed the behavior around sorting `undefined` values.
When sorting descending they should now appear at the top of the list.
This was a recent change but it wasn't clear it was intentional and I
found it made the code more complex.

#6651

Internal users see [b/278671226](http://b/278671226)

## Screenshots of UI changes (or N/A)

Before:

![image](https://github.com/tensorflow/tensorboard/assets/78179109/5f805c37-283d-4f55-b1bf-3dfa4d9ea1da)

After:

![image](https://github.com/tensorflow/tensorboard/assets/78179109/0d740b6e-2ed5-4762-aec0-22400eeb152d)


![image](https://github.com/tensorflow/tensorboard/assets/78179109/5283bade-b4da-401d-9893-932d9fb9d378)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants