Unanswered
It Seems Like Clearml Agent Does Not Support Arparse Subparsers, Right?
Yes. Here is some simple code that reproduces the issue:
import argparse
from datetime import datetime
import clearml
def train(args):
print(f"Running training: {args}")
def test(args):
print(f"Running testing: {args}")
def parse_args():
parser = argparse.ArgumentParser()
subparser = parser.add_subparsers(dest="subparser")
train_parser = subparser.add_parser("train")
train_parser.add_argument("project", type=str)
train_parser.add_argument("queue", type=str)
train_parser.add_argument("--epochs", type=int)
test_parser = subparser.add_parser("test")
test_parser.add_argument("model_path", type=str)
test_parser.add_argument("--metric", type=str)
args = parser.parse_args()
return args
if __name__ == "__main__":
args = parse_args()
print(args)
task = clearml.Task.init(args.project, datetime.now().strftime("%Y%m%d-%H%M%S"))
task.execute_remotely(queue_name=args.queue)
if args.subparser == "train":
train(args)
elif args.subparser == "test":
test(args)
else:
raise ValueError(f"Invalid args: {args}")
Locally it prints: Namespace(subparser='train', project='my-clearml-project', queue='worker-queue', epochs=2)
In the remote console: Namespace(subparser="['train', 'my-clearml-project', 'worker-queue', '--epochs', '2']", project='my-clearml-project', queue='worker-queue', epochs=2)
168 Views
0
Answers
one year ago
one year ago