Skip to content

Print fully qualified name of experimental function by default#6162

Merged
nabenabe0928 merged 3 commits intooptuna:masterfrom
ktns:fully_qualified_name
Jun 18, 2025
Merged

Print fully qualified name of experimental function by default#6162
nabenabe0928 merged 3 commits intooptuna:masterfrom
ktns:fully_qualified_name

Conversation

@ktns
Copy link
Copy Markdown
Contributor

@ktns ktns commented Jun 17, 2025

Motivation

Currently, warning messages from experimental functions decorated by optuna._experimental.experimental_func seems only include their function name and not include which module they are defined in.

Description of the changes

This PR change the decorator so that the warning messages include module name and include __qualname__ instead of __name__.

@nabenabe0928 nabenabe0928 added the enhancement Change that does not break compatibility and not affect public interfaces, but improves performance. label Jun 17, 2025
@nabenabe0928 nabenabe0928 modified the milestone: v4.5.0 Jun 17, 2025
@nabenabe0928
Copy link
Copy Markdown
Contributor

Thank you, @ktns , for this PR!
Could you, @HideakiImamura , please review this PR?

Copy link
Copy Markdown
Member

@HideakiImamura HideakiImamura 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 PR! Looks very good.

@nabenabe0928
Copy link
Copy Markdown
Contributor

I tried the code below:

import optuna


study = optuna.create_study()
study.set_metric_names(["a"])

and obtained the following log:

[I 2025-06-18 09:06:15,982] A new study created in memory with name: no-name-bc02aa29-9164-4337-81e2-bbc9de2f29dd
/home/shuhei/pfn-work/optuna-dev/optuna/hoge.py:5: ExperimentalWarning: optuna.study.study.Study.set_metric_names is experimental (supported from v3.2.0). The interface can change in the future.
  study.set_metric_names(["a"])

Copy link
Copy Markdown
Contributor

@nabenabe0928 nabenabe0928 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 the PR, LGTM!

@nabenabe0928 nabenabe0928 added this to the v4.5.0 milestone Jun 18, 2025
@nabenabe0928 nabenabe0928 merged commit 04de11c into optuna:master Jun 18, 2025
14 checks passed
@ktns ktns deleted the fully_qualified_name branch June 19, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Change that does not break compatibility and not affect public interfaces, but improves performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants