Skip to content

Add docstring to BaseStorage method interfaces.#1175

Merged
hvy merged 12 commits intooptuna:masterfrom
ytsmiling:add-storage-method-doc
May 19, 2020
Merged

Add docstring to BaseStorage method interfaces.#1175
hvy merged 12 commits intooptuna:masterfrom
ytsmiling:add-storage-method-doc

Conversation

@ytsmiling
Copy link
Copy Markdown
Member

Motivation

Storage class implementations for each backend handles error in a different manner. Additionally, undocumented return values force users to read implementations of each method. This PR addresses these issues as a step in #1170. Any inconsistent behaviors with this docstring will be fixed in subsequent PRs.

Description of the changes

Add docstrings to methods in BaseStorage class.

@ytsmiling
Copy link
Copy Markdown
Member Author

ytsmiling commented Apr 30, 2020

Current doc and implementation conflicts with #1174 and allows to change the attributes of WAITING trials, which should be fixed.
#1174 does not add the restriction.

# type: (int, TrialState) -> bool
def set_trial_state(self, trial_id: int, state: TrialState) -> bool:

"""Update a state of a specified trial.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think we should allow the "RUNNING → WAITING" state change. (Both this doc and current implementation allows it now.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This PR won't address this issue.

@hvy hvy added document Documentation related. optuna.storages Related to the `optuna.storages` submodule. This is automatically labeled by github-actions. labels May 1, 2020
@sile sile self-assigned this May 7, 2020
@sile sile added this to the v1.5.0 milestone May 13, 2020
ytsmiling and others added 3 commits May 13, 2020 15:48
Co-authored-by: Takeru Ohta <phjgt308@gmail.com>
Co-authored-by: Takeru Ohta <phjgt308@gmail.com>
Copy link
Copy Markdown
Member

@sile sile left a comment

Choose a reason for hiding this comment

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

LGTM!

@toshihikoyanase toshihikoyanase mentioned this pull request May 15, 2020
2 tasks
Copy link
Copy Markdown
Member

@hvy hvy 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 making this clearly documented once for all. The documented behavior LGTM. I left comments on the style and minor things. I'd personally like to change some English phrases but those are minor and sort of repeat themselves so I could follow it up in a different PR if that's fine with you.

Returns:
Study ID, which is an unique id among studies, of the created study.

Raises:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Greatly improves documentation👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We (or at least I) haven't really paid much attention to documenting exceptions, but we definitely should.

@ytsmiling
Copy link
Copy Markdown
Member Author

@hvy Thank you for your review. I appreciate your follow-up PR suggestion, and I'd like to see it.

@ytsmiling ytsmiling requested a review from hvy May 18, 2020 00:54
Copy link
Copy Markdown
Member

@hvy hvy left a comment

Choose a reason for hiding this comment

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

Some tiny details.

Edit: Not sure why my review comments were separated to before and after this comment, but please also see #1175 (review)

Co-authored-by: Hiroyuki Vincent Yamazaki <hiroyuki.vincent.yamazaki@gmail.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Merging #1175 into master will increase coverage by 0.76%.
The diff coverage is 62.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1175      +/-   ##
==========================================
+ Coverage   91.04%   91.80%   +0.76%     
==========================================
  Files         142      149       +7     
  Lines       12255    13072     +817     
==========================================
+ Hits        11157    12001     +844     
+ Misses       1098     1071      -27     
Impacted Files Coverage Δ
optuna/storages/base.py 68.22% <62.12%> (+11.90%) ⬆️
optuna/testing/storage.py 80.00% <0.00%> (-2.86%) ⬇️
tests/storages_tests/rdb_tests/test_storage.py 95.49% <0.00%> (-1.58%) ⬇️
tests/pruners_tests/test_hyperband.py 97.39% <0.00%> (-0.61%) ⬇️
optuna/storages/rdb/models.py 95.19% <0.00%> (-0.44%) ⬇️
optuna/storages/rdb/storage.py 96.06% <0.00%> (-0.16%) ⬇️
optuna/storages/in_memory.py 97.71% <0.00%> (-0.15%) ⬇️
tests/test_study.py 98.15% <0.00%> (-0.12%) ⬇️
optuna/samplers/tpe/sampler.py 88.21% <0.00%> (-0.10%) ⬇️
optuna/distributions.py 93.75% <0.00%> (-0.09%) ⬇️
... and 41 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0589b2b...ab77eb4. Read the comment docs.

Copy link
Copy Markdown
Member

@hvy hvy 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 addressing, LGTM!

@hvy hvy merged commit 9b3eccf into optuna:master May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

document Documentation related. optuna.storages Related to the `optuna.storages` submodule. This is automatically labeled by github-actions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants