maybe bug? If you have any file using argparse in this template
tlwzzy opened this issue · comments
Hi, Thanks for your great work first. I'm using this template for several research by myself now.
Now I have a question. In src/utils I touch a python file pooling.py, and it uses argparse. In src/utils/init.py, I imported it.
Ok, now if I python src/train.py, It's a allright.
Buf if I try to do something like
D:\data\src>python train.py model.resize=7
usage: train.py [-h] [--csv_path CSV_PATH]
train.py: error: unrecognized arguments: model.resize=7
if i comment the argparse code, all things done right.Like
# parser = argparse.ArgumentParser(description='preprocess for csv2globalvector')
# parser.add_argument('--csv_path', type=str, default=/MLPTrainingData', help='csv files path')
# args = parser.parse_args()
Now I have question:
In the pipeline of training, model, or data, do not use this pooling.py at all. Why it can still influence python src/train.py?
So Is it a bug? If not, shoule we hint not using argparse Anywhere?
OK I make a further test, seems it won't effect if I don't import it from src/utils/init.py, maybe that's because this template auto import src/utils/init.py's functions?
Yes, train.py
contains from src import utils
.
If your src/utils/__init__.py
contains argparse lines then they will be automatically executed on importing.
You could specify precisely what is imported from files in utils folder, although I would recommend to just avoid having argparse in utils at all.
Yes,
train.py
containsfrom src import utils
.If your
src/utils/__init__.py
contains argparse lines then they will be automatically executed on importing.You could specify precisely what is imported from files in utils folder, although I would recommend to just avoid having argparse in utils at all.
Thanks for answer. So it isn't a bug, we shoule avoid using argparse (at least NOT IMPORT it) in this template.
I wouldn't say not to use it. Just don't use it alongside hydra becuase it already manages command line overrides.