Merge branch 'develop' into hyperopt-jobs

This commit is contained in:
hroff-1902
2019-04-24 10:31:03 +03:00
committed by GitHub
3 changed files with 28 additions and 3 deletions

View File

@@ -317,6 +317,14 @@ class Arguments(object):
type=int,
metavar='JOBS',
)
parser.add_argument(
'--random-state',
help='Set random state to some positive integer for reproducible hyperopt results.',
dest='hyperopt_random_state',
default=None,
type=Arguments.check_int_positive,
metavar='INT',
)
def _build_subcommands(self) -> None:
"""
@@ -387,6 +395,18 @@ class Arguments(object):
return TimeRange(stype[0], stype[1], start, stop)
raise Exception('Incorrect syntax for timerange "%s"' % text)
@staticmethod
def check_int_positive(value) -> int:
try:
uint = int(value)
if uint <= 0:
raise ValueError
except ValueError:
raise argparse.ArgumentTypeError(
f"{value} is invalid for this parameter, should be a positive integer value"
)
return uint
def scripts_options(self) -> None:
"""
Parses given arguments for scripts.