Unanswered
How Do I Get The Parsed Args Object Of A Task? I Ran A Task, Using The Argparser To Set Its Hyperparams. I Now Get The Task Using Task.Get_Task, And I Want To Instantiate An Args Namespace Which Has The Same Values As When The Task Ran The Parsing Code, A
args_string = ['--{} {}'.format(k, v) for k, v in task.get_parameters_as_dict().get('Args', {}).items()] args_strings = [a.replace("'", '').replace("[", '').replace("]", '').replace(",", '') for a in reduce(lambda l, s: l + s.split(' '), args_string, []) if a]
and then just parser.parse_args(ars_strings)
It's not even very clean, I could have replaced the multiple replace calls with a regex etc. just a quick hack to work around it.
Actually, I found out that if I use execute_remotely I don't even need this, since the parser arguments are apparently reconstructed. so just instantiating the parser and running parser.parse_args() is enough
133 Views
0
Answers
3 years ago
one year ago