Skip to content

[Enhancement] tuner.search_space_summary() should return string object instead implicitly of printing to stdout. #1033

@GhostDog98

Description

@GhostDog98

Is your feature request related to a problem? Please describe.
Currently, if i would like to get search_space_summary into a variable, instead of printing to stdout, i need to do the following hack:

old_stdout = sys.stdout # for later
sys.stdout = io.StringIO() # capture stdout
tuner.search_space_summary()  # Print summary of search space to stdout
captured_output = sys.stdout.getvalue() # get the saved value...
sys.stdout = old_stdout # restore old stdout

This seems overly complex, and it is unintuitive behaviour that calling search_space_summary implicitly prints.
Additionally, in my opinion, it breaks PEP20 rule 2; that Explicit is better than implicit.
Describe the solution you'd like
I propose that instead of:
image

We essentially have:
image

Describe alternatives you've considered
Rename the function to print_seach_space_summary() to make it explicit to the programmer that this prints directly to STDOUT.
This, however, would still leave no "clean" way to get the search space summary programatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions