Found the issue: my bad practice for import 😛
You need to import clearml before doing argument parser. Bad way:
import argparse
def handleArgs():
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config-file', type=str, default='train_config.yaml',
help='train config file')
parser.add_argument('--device', type=int, default=0,
help='cuda device index to run the training')
args = parser.parse_args()
return args
if __name__ == "__main__":
args=handleArgs()
from clearml import Task
task = Task.init(project_name='bugs', task_name='argparse',reuse_last_task_id=False)
print("Done.")
Should be:
import argparse
from clearml import Task
def handleArgs():
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config-file', type=str, default='train_config.yaml',
help='train config file')
parser.add_argument('--device', type=int, default=0,
help='cuda device index to run the training')
args = parser.parse_args()
return args
if __name__ == "__main__":
args=handleArgs()
task = Task.init(project_name='bugs', task_name='argparse',reuse_last_task_id=False)
print("Done.")
I also have the same issue. Default argument are fine but all supplied argument in command line become duplicated !
my code looks like this :
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config-file', type=str, default='train_config.yaml',
help='train config file')
parser.add_argument('-t', '--train-times', type=int, default=1,
help='train the same model several times')
parser.add_argument('--dataset_dir', help='path to folder containing the preped dataset.', required=True)
parser.add_argument('--backup', action='store_true', help='store the config file')
parser.add_argument('--device', type=int, default=0,
help='cuda device index to run the training')
task.connect(parser)
args = parser.parse_args()
@<1576381444509405184:profile|ManiacalLizard2> ,that’s interesting. So you actually need the imports to be in a certain order. That’s definitely new and a bit of an anti-pattern as it goes against recommended import statement order (built-in packages imported first) but if it works, that’s good news at least. I’ll try that as well. Thanks!
Hi @<1533620191232004096:profile|NuttyLobster9> , can you please elaborate on what you were expecting to get? Can you provide a self contained snippet that reproduces this?
like for dataset_dir
I would expect a single path, not an array of 2 paths duplicated
Solved @<1533620191232004096:profile|NuttyLobster9> . In my case:
I need to from clearml import Task
very early in the code (like first line), before importing argparse
And not calling task.connect(parser)
Hi @<1523701070390366208:profile|CostlyOstrich36> , I would expect the loss_func
parameter to be FocalLoss
instead of ['FocalLoss', 'FocalLoss', 'FocalLoss', 'FocalLoss']
(and same for the validation_split_name
parameter. I will try to put together an example, though it might take a little time before I can do it.