Remove auto_connect_arg_parser constraint when ArgumentParser.parse_arg() is used before initializing task

This commit is contained in:
allegroai 2020-05-08 21:33:54 +03:00
parent 8b5377ee4f
commit 3de95063ee

View File

@ -439,11 +439,10 @@ class Task(_Task):
parser, parsed_args = get_argparser_last_args() parser, parsed_args = get_argparser_last_args()
task._connect_argparse(parser=parser, parsed_args=parsed_args) task._connect_argparse(parser=parser, parsed_args=parsed_args)
elif argparser_parseargs_called(): elif argparser_parseargs_called():
# parse_args was automatically patched, but auto_connect_arg_parser is False... # actually we have nothing to do, in remote running, the argparser will ignore
raise UsageError("ArgumentParser.parse_args() was automatically connected to this task, " # all non argparser parameters, only caveat if parameter connected with the same name
"although auto_connect_arg_parser is turned off!\n" # as the argparser this will be solved once sections are introduced to parameters
"When turning off auto_connect_arg_parser, call Task.init(...) " pass
"before calling ArgumentParser.parse_args()")
# Make sure we start the logger, it will patch the main logging object and pipe all output # Make sure we start the logger, it will patch the main logging object and pipe all output
# if we are running locally and using development mode worker, we will pipe all stdout to logger. # if we are running locally and using development mode worker, we will pipe all stdout to logger.