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 Study.study_name #157
Add Study.study_name #157
Conversation
pfnopt/cli.py
Outdated
@@ -44,14 +44,16 @@ def get_parser(self, prog_name): | |||
# type: (str) -> ArgumentParser | |||
|
|||
parser = super(CreateStudy, self).get_parser(prog_name) | |||
parser.add_argument('--study_name', default=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep consistency, please use -
instead of _
for argument name.
There was a problem hiding this 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 comment. --study_name
was replaced with --study-name
to keep the consistency with other arguments.
pfnopt/cli.py
Outdated
@@ -145,6 +148,8 @@ def get_parser(self, prog_name): | |||
'number is set to CPU counts.') | |||
parser.add_argument('--study', help='Study UUID.') | |||
parser.add_argument('--create-study', action='store_true', help='Create a new study.') | |||
parser.add_argument('--study_name', default=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also fixed this one. Thanks.
pfnopt/storages/in_memory.py
Outdated
def get_study_id_from_name(self, study_name): | ||
# type: (str) -> int | ||
|
||
if study_name is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that study_name
is typed as str
as well as this method is not exposed to users, I don't think None
handling is necessary here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. This none-value checking was removed. Thank you for your comment.
|
||
# Test not existing study. | ||
with pytest.raises(ValueError): | ||
storage.get_study_id_from_name('dummy-uuid') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it does not affect test logic itself, dummy-uuid
has better be replaced with dummy-name
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dummy-uuid
was replaced with dummy-name
. Thank you!
@@ -96,6 +111,29 @@ def test_get_study_id_from_uuid_and_get_study_uuid_from_id(storage_init_func): | |||
assert storage.get_study_id_from_uuid(summary.study_uuid) == summary.study_id | |||
|
|||
|
|||
@parametrize_storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StorageSupplier
is our current strategic way to parametrize storage. (I think we can address it in another PR.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote this test with StorageSupplier
. Now, I'm sure that it provide better way to control backend storages than @parametrize_storage
. Thank you for your suggestion.
study_name = 'sample_study_name' | ||
# Test existing study. | ||
study_id = storage.create_new_study_id(study_name) | ||
summary = storage.get_all_study_summaries()[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once StorageSupplier
is introduced, the number of summaries returned by storage.get_all_study_summaries()
is not necessarily 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for you advice. According to tests in test_study.py
, I used Study
created by pfnopt.create_study
instances instead of StudySummary
.
|
||
# TODO(Yanase): Use Replace StorageSupplier instead of @parametrize_storage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand English here. Do you want to replace StorageSupplier
by parametrize_storage
, or do you want to replace parametrize_storage
by StorageSupplier
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry for bothering you due to my poor English sentence. I want to say parametrize_storage
should be replaced by StorageSupplier
. I fixed the comment.
A concern that I want to discuss: |
As you mentioned, behavior of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
study_name
toStudy
class.study_name
can be specified bycreate-study
subcommand of CLI orpfnopt.create_study
function.