Added tests and updated doc
This commit is contained in:
parent
7606d814fa
commit
91db75a707
@ -450,6 +450,9 @@ optional arguments:
|
|||||||
useful if you are redirecting output to a file.
|
useful if you are redirecting output to a file.
|
||||||
--print-json Print best result detailization in JSON format.
|
--print-json Print best result detailization in JSON format.
|
||||||
--no-details Do not print best epoch details.
|
--no-details Do not print best epoch details.
|
||||||
|
--export-csv FILE Export to CSV-File. Put + in front of filename to
|
||||||
|
overwrite. This will disable table print. Example:
|
||||||
|
--export-csv +hyperopt.csv
|
||||||
|
|
||||||
Common arguments:
|
Common arguments:
|
||||||
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
|
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
|
||||||
|
@ -224,7 +224,8 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
"export_csv": Arg(
|
"export_csv": Arg(
|
||||||
'--export-csv',
|
'--export-csv',
|
||||||
help='Export to CSV-File. Put + in front of filename to overwrite.'
|
help='Export to CSV-File. Put + in front of filename to overwrite.'
|
||||||
'Example: --export-csv +hyperopt.csv',
|
' This will disable table print.'
|
||||||
|
' Example: --export-csv +hyperopt.csv',
|
||||||
metavar='FILE',
|
metavar='FILE',
|
||||||
),
|
),
|
||||||
"hyperopt_jobs": Arg(
|
"hyperopt_jobs": Arg(
|
||||||
|
@ -50,17 +50,18 @@ def start_hyperopt_list(args: Dict[str, Any]) -> None:
|
|||||||
if print_colorized:
|
if print_colorized:
|
||||||
colorama_init(autoreset=True)
|
colorama_init(autoreset=True)
|
||||||
|
|
||||||
try:
|
if not export_csv:
|
||||||
Hyperopt.print_result_table(config, trials, total_epochs,
|
try:
|
||||||
not filteroptions['only_best'], print_colorized, 0)
|
Hyperopt.print_result_table(config, trials, total_epochs,
|
||||||
except KeyboardInterrupt:
|
not filteroptions['only_best'], print_colorized, 0)
|
||||||
print('User interrupted..')
|
except KeyboardInterrupt:
|
||||||
|
print('User interrupted..')
|
||||||
|
|
||||||
if trials and not no_details:
|
if trials and not no_details:
|
||||||
sorted_trials = sorted(trials, key=itemgetter('loss'))
|
sorted_trials = sorted(trials, key=itemgetter('loss'))
|
||||||
results = sorted_trials[0]
|
results = sorted_trials[0]
|
||||||
Hyperopt.print_epoch_details(results, total_epochs, print_json, no_header)
|
Hyperopt.print_epoch_details(results, total_epochs, print_json, no_header)
|
||||||
print(export_csv)
|
|
||||||
if trials and export_csv:
|
if trials and export_csv:
|
||||||
overwrite_csv = False
|
overwrite_csv = False
|
||||||
if export_csv[0] == '+':
|
if export_csv[0] == '+':
|
||||||
|
@ -902,7 +902,21 @@ def test_hyperopt_list(mocker, capsys, hyperopt_results):
|
|||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 7/12", " 8/12"
|
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 7/12", " 8/12"
|
||||||
" 9/12", " 10/12", " 11/12", " 12/12"])
|
" 9/12", " 10/12", " 11/12", " 12/12"])
|
||||||
|
args = [
|
||||||
|
"hyperopt-list",
|
||||||
|
"--no-details",
|
||||||
|
"--export-csv", "+test_file.csv"
|
||||||
|
]
|
||||||
|
pargs = get_args(args)
|
||||||
|
pargs['config'] = None
|
||||||
|
start_hyperopt_list(pargs)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
assert all(x in captured.out
|
||||||
|
for x in ["CSV-File created!"])
|
||||||
|
f = Path("test_file.csv")
|
||||||
|
assert 'Best,1,2,-1.25%,-0.00125625,,-2.51,"3,930.0 m",0.43662' in f.read_text()
|
||||||
|
assert f.is_file()
|
||||||
|
f.unlink()
|
||||||
|
|
||||||
def test_hyperopt_show(mocker, capsys, hyperopt_results):
|
def test_hyperopt_show(mocker, capsys, hyperopt_results):
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
|
Loading…
Reference in New Issue
Block a user