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

Resolve plotly.py dependency issue #773

Merged
merged 2 commits into from
Jan 26, 2024
Merged

Conversation

knshnb
Copy link
Member

@knshnb knshnb commented Jan 26, 2024

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

Follow-up of #764

What does this implement/fix? Explain your changes.

  • Add plotly to the optional dependency
  • Fall back to plotly.js when plotly.py is not available

@knshnb knshnb changed the title Plotlypy dependency Resolve plotly.py dependency issue Jan 26, 2024
@knshnb knshnb marked this pull request as ready for review January 26, 2024 08:52
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.

Looks good to me. I left one suggestion though.

Comment on lines +29 to +38
const plotlypyIsAvailable = useRecoilValue<boolean>(plotlypyIsAvailableState)
if (query.get("plotlypy_rendering") === "true") {
return <ContourBackend study={study} />
if (plotlypyIsAvailable) {
return <ContourBackend study={study} />
} else {
console.warn(
"Use frontend rendering because plotlypy is specified but not available."
)
return <ContourFrontend study={study} />
}
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps, we could define the following wrapper function in state.ts:

export const usePlotlypyIsAvailable = (): boolean => {
  const query = useQuery()
  const plotlypyIsAvailable = useRecoilValue<boolean>(plotlypyIsAvailableState)

  if (query.get("plotlypy_rendering") === "true") {
    if (plotlyPyIsAvailable) {
      return true
    }
    console.warn(...)
  }
  return false
}

Copy link
Member

Choose a reason for hiding this comment

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

Furthermore, we could use notistack to show a warning message to users like below:

enqueueSnackbar(`Failed to fetch study list.`, {
variant: "error",
})

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I will introduce this function when I implement backend rendering of other graphs 👍

@knshnb
Copy link
Member Author

knshnb commented Jan 26, 2024

Thanks for the review! I worked on #773 (comment) by another PR: #778. Let me merge this now.

@knshnb knshnb merged commit 460ca24 into optuna:main Jan 26, 2024
16 checks passed
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

2 participants