Skip to content

When one parameter contains blank, it should be wrapped with ". #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

memorylorry
Copy link

Hope to let argparse to interpreter dict type

1. I define test_config.yml file as following:

CMD: "python train.py"

HPARAMS:
   lr: [0.01, 0.02]
   momentum: 0.5
   dataset:
     name: 'aerial'
     class: 'dataset.AerialDataset'
     root-dir: '/home/cv/dataset/aerial'
     train:
       dir: 'train'
       batch_size: 10

2. I execute python -m runx.runx test_config.yml -i -n, then command line prints:

python train.py --lr 0.01 --momentum 0.5 --dataset {'name': 'aerial', 'class': 'dataset.AerialDataset', 'root-dir': '/home/cv/dataset/aerial', 'train': {'dir': 'train', 'batch_size': 10}}
python train.py --lr 0.02 --momentum 0.5 --dataset {'name': 'aerial', 'class': 'dataset.AerialDataset', 'root-dir': '/home/cv/dataset/aerial', 'train': {'dir': 'train', 'batch_size': 10}}

You can notice that parameter dataset is a dict type, but it can't be interpreterd by argparse module with eval type. This is because dataset parameter is truncated into {'name':, this style cannot be interpreter by eval function.

3. So I try to transform dict into str. And set eval type of argparse arguments, this would solve this problem. But it need runx composite dict paramter wapped with ". Therefore, I add this feature in this commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant