I'm Working on transformers .
I have a python script there, that takes arguments as input via argparse.
Here is part of it:
parser = argparse.ArgumentParser()
parser.add_argument("--model_type", default=None, type=str, required=True,
help="Model type selected in the list: " + ", ".join(MODEL_CLASSES.keys()))
parser.add_argument("--model_name_or_path", default=None, type=str, required=True,
help="Path to pre-trained model or shortcut name selected in the list: " + ", ".join(ALL_MODELS))
I want to be able to call the script iteratively with different arguments. I can call the script with %run or !python <bash command>, but can I cannot pass variables to it be interpreted as arguments, because it treats the variables as the actual string value:
%run examples/run_lm_finetuning.py --gradient_accumulation_steps=1 --output_dir='output_medium' --model_type='gpt2' \
--model_name_or_path=model_load --do_train --train_data_file='/root/sharedfolder/omri/data/pieces/backup/{}'.format(file)\
--overwrite_output_dir --per_gpu_train_batch_size=1 --per_gpu_eval_batch_size=1 --save_total_limit=5
Returns:
OSError: Model name 'model_load' was not found in
model name list (gpt2, gpt2-medium, gpt2-large, gpt2-xl, distilgpt2).
We assumed 'model_load' was a path or url to a configuration file named
config.json or a directory containing such a file but couldn't find any
such file at this path or url.