Skip to content

Accept nan in trial.report#3348

Merged
himkt merged 15 commits intooptuna:masterfrom
belldandyxtq:nan_report
Apr 19, 2022
Merged

Accept nan in trial.report#3348
himkt merged 15 commits intooptuna:masterfrom
belldandyxtq:nan_report

Conversation

@belldandyxtq
Copy link
Copy Markdown
Contributor

Motivation

This is a part of #3205 to support nan in trial.report. As shown in the issue, trial.report fails when the backend is MySQL, since MySQL cannot store nan.

Description of the changes

  1. This PR changes the nan to None to store in the backend.
  2. Add tests for nan in report.

@github-actions github-actions bot added the optuna.storages Related to the `optuna.storages` submodule. This is automatically labeled by github-actions. label Feb 27, 2022
@HideakiImamura HideakiImamura added the sprint-20220227 PR from the online sprint event Feb 27, 2022. label Feb 27, 2022
@belldandyxtq
Copy link
Copy Markdown
Contributor Author

Should we change None back to nan in get?

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 27, 2022

Codecov Report

Merging #3348 (04f4b36) into master (9cc67f5) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3348      +/-   ##
==========================================
- Coverage   91.53%   91.53%   -0.01%     
==========================================
  Files         158      158              
  Lines       12184    12193       +9     
==========================================
+ Hits        11153    11161       +8     
- Misses       1031     1032       +1     
Impacted Files Coverage Δ
optuna/storages/_rdb/models.py 98.79% <100.00%> (ø)
optuna/storages/_rdb/storage.py 95.41% <100.00%> (-0.10%) ⬇️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@HideakiImamura HideakiImamura self-assigned this Feb 28, 2022
@hvy hvy assigned himkt Mar 1, 2022
@hvy
Copy link
Copy Markdown
Member

hvy commented Mar 1, 2022

Thanks for the PR.
@himkt , let me know if you're busy, but could you otherwise review this change?

@HideakiImamura HideakiImamura mentioned this pull request Mar 3, 2022
3 tasks
@HideakiImamura
Copy link
Copy Markdown
Member

@belldandyxtq Please apply the formats.sh to pass the CI.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has not seen any recent activity.

@github-actions github-actions bot added the stale Exempt from stale bot labeling. label Mar 28, 2022
@himkt
Copy link
Copy Markdown
Member

himkt commented Apr 12, 2022

note: we need to write a migration script.

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 mob review! LGTM.

[TODO] We need to add a migration script. I must be done until the next release, but it should be ASAP.

@github-actions github-actions bot removed the stale Exempt from stale bot labeling. label Apr 12, 2022
@HideakiImamura HideakiImamura added the compatibility Change that breaks compatibility. label Apr 13, 2022
@HideakiImamura HideakiImamura added the v3 Issue/PR for Optuna version 3. label Apr 13, 2022
@HideakiImamura
Copy link
Copy Markdown
Member

I fixed the conflict.

@himkt Please merge this PR after your approval.

Copy link
Copy Markdown
Member

@himkt himkt left a comment

Choose a reason for hiding this comment

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

LGTM.

Note that after this PR being merged, trial.report(step=x, value=float("nan")) does not raise an exception without writing an intermediate entry until a storage migration. The current behavior is that stops an optimization with raising an exception. Users who stops the optimization using trial.report + value=nan may observe this behavior change (but we think no one rely on this behavior, since pruners consider trials to be pruned when nan exists in intermediates).

@himkt himkt added this to the v3.0.0-b1 milestone Apr 19, 2022
@himkt himkt merged commit 638bdef into optuna:master Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility Change that breaks compatibility. optuna.storages Related to the `optuna.storages` submodule. This is automatically labeled by github-actions. sprint-20220227 PR from the online sprint event Feb 27, 2022. v3 Issue/PR for Optuna version 3.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants