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

Add plot to redirect click event #625

Merged
merged 9 commits into from
Feb 2, 2024

Conversation

hrntsm
Copy link
Collaborator

@hrntsm hrntsm commented Sep 22, 2023

Contributor License Agreement

This repository (optuna-dashboard) and Goptuna share common code.
This pull request may therefore be ported to Goptuna.
Make sure that you understand the consequences concerning licenses and check the box below if you accept the term before creating this pull request.

  • I agree this patch may be ported to Goptuna by other Goptuna contributors.

Reference Issues/PRs

What does this implement/fix? Explain your changes.

To make it easier to check the results, it make possible to jump to the details of the trial from the history and pareto-front plots.

Screen.Recording.2023-09-22.at.21.18.13.mov

@codecov
Copy link

codecov bot commented Sep 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1dd3849) 56.40% compared to head (db2f631) 62.45%.
Report is 339 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #625      +/-   ##
==========================================
+ Coverage   56.40%   62.45%   +6.04%     
==========================================
  Files          35       35              
  Lines        2193     2224      +31     
==========================================
+ Hits         1237     1389     +152     
+ Misses        956      835     -121     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@keisuke-umezawa keisuke-umezawa left a comment

Choose a reason for hiding this comment

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

Alghouth I left some nits comment, It works well in my local.

element.on("plotly_click", function (data) {
const link =
URL_PREFIX +
`/studies/${studies[0].id}}/trials?numbers=${data.points[0].x}`
Copy link
Member

Choose a reason for hiding this comment

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

In this ref, it seems that we can get curveNumber from data.

How about replace studies[0] to studies[Math.floor(data.points[0].curveNumber / 2)]? In that case, it also work with studies.length >=1 .

element.on("plotly_click", function (data) {
const link =
URL_PREFIX +
`/studies/${studies[0].id}}/trials?numbers=${data.points[0].x}`
Copy link
Member

Choose a reason for hiding this comment

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

[nits] It seems to have redundant } here.

Copy link
Member

Choose a reason for hiding this comment

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

As a result, the url became something like http://localhost:8080/dashboard/studies/0%7D/trials?numbers=0, where %7D comes from }.

)
const link =
URL_PREFIX +
`/studies/${study.id}}/trials?numbers=${plotTextInfo.number}`
Copy link
Member

Choose a reason for hiding this comment

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

[nits] It seems to have redundant } here.

@hrntsm
Copy link
Collaborator Author

hrntsm commented Sep 24, 2023

Thanks for the review @keisuke-umezawa .
I have fixed the points you suggested.

if (element != null && studies.length >= 1) {
// @ts-ignore
element.on("plotly_click", function (data) {
if (data.points[0].data.mode !== "lines") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As an addition, the x coordinate of the point was used for the history redirection, which also worked for the best value line.
I want to redirect only when the trial point itself is clicked, so it will not work when the line is clicked like below.

Screenshot 2023-09-24 at 21 56 55

@c-bata c-bata self-assigned this Sep 25, 2023
c-bata
c-bata previously requested changes Sep 29, 2023
Copy link
Member

@c-bata c-bata left a comment

Choose a reason for hiding this comment

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

Thank you for your pull request! I left a suggestion.

Comment on lines 77 to 82
const link =
URL_PREFIX +
`/studies/${
studies[Math.floor(data.points[0].curveNumber / 2)].id
}/trials?numbers=${data.points[0].x}`
window.location.href = link
Copy link
Member

Choose a reason for hiding this comment

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

Could you use useNavigate() to avoid the page refresh?

const navigate = useNavigate()

Suggested change
const link =
URL_PREFIX +
`/studies/${
studies[Math.floor(data.points[0].curveNumber / 2)].id
}/trials?numbers=${data.points[0].x}`
window.location.href = link
navigate(
URL_PREFIX +
`/studies/${
studies[Math.floor(data.points[0].curveNumber / 2)].id
}/trials?numbers=${data.points[0].x}`
)

Comment on lines 45 to 48
const link =
URL_PREFIX +
`/studies/${study.id}/trials?numbers=${plotTextInfo.number}`
window.location.href = link
Copy link
Member

Choose a reason for hiding this comment

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

ditto.

Comment on lines 80 to 92
if (data.points[0].data.name.includes("Infeasible Trial of")) {
const studyInfo: { id: number; name: string }[] = []
studies.forEach((study) => {
studyInfo.push({ id: study.id, name: study.name })
})
const dataPointStudyName = data.points[0].data.name.replace(
"Infeasible Trial of ",
""
)
const targetId = studyInfo.find((s) => s.name === dataPointStudyName)?.id
if (targetId !== undefined) {
studyId = targetId
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It did not work for Infeasible trials and has been corrected.
StudyId is identified from the name string of the point, but if you have a better way, please comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

One solution would be to give each plot a little more information, like a Pareto chart.
If this is a good solution, I will create another PR on this and as soon as that it is merged, I will reflect it in this PR.

@keisuke-umezawa
Copy link
Member

@c-bata
When you have a time, could you check it again?

Copy link

This pull request has not seen any recent activity.

@github-actions github-actions bot added the stale for stale bot label Jan 11, 2024
@keisuke-umezawa keisuke-umezawa added the no-stale Exempt from stale bot label Jan 15, 2024
@github-actions github-actions bot removed the stale for stale bot label Jan 15, 2024
@c-bata c-bata dismissed their stale review February 2, 2024 08:25

Since my requested changes were applied.

@c-bata c-bata removed the no-stale Exempt from stale bot label Feb 2, 2024
@c-bata
Copy link
Member

c-bata commented Feb 2, 2024

@porink0424 Could you review this PR?

Copy link
Collaborator

@porink0424 porink0424 left a comment

Choose a reason for hiding this comment

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

LGTM,
although I found some (tiny) format problems, I am going to make a follow-up PR.

I think this PR itself can be merged.

@c-bata c-bata merged commit fc0d52c into optuna:main Feb 2, 2024
9 checks passed
@porink0424 porink0424 mentioned this pull request Feb 2, 2024
1 task
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.

None yet

4 participants