Running run_lm_finetuning.py within python
## Setup
* Model: roberta-base
* Language: english
* OS: Ubuntu 18.04.3
* Python version: 3.7.3
* PyTorch version: 1.3.1+cpu
* PyTorch Transformers version (or branch): 2.2.0
* Using GPU ? No
* Distributed of parallel setup ? No
* Script inputs:
```
python run_lm_finetuning.py \
--output_dir=$OUTPUT_DIR \
--model_type=roberta \
--model_name_or_path=roberta_base \
--do_train \
--train_data_file=$TRAIN_FILE \
--do_eval \
--eval_data_file=$TEST_FILE \
--mlm \
--no_cuda
```
## ❓ Questions & Help
Is there a way to run the above within python? Said differently, if I want to call `run_lm_finetuning.py` from within one of my own python scripts using the above configurations, how would I best go about doing that?

Thanks in advance!
You have two choices:
- transform the code into `run_lm_finetuning.py` as Python functions and use them (I think it's **the most elegant solution**). In order to do that, you've to convert the `main` method with `argparse` arguments to a method without `argparse` and after that you can use the script as given
- call `run_lm_finetuning.py` from your Python script with e.g. [subprocess](https://docs.python.org/3.6/library/subprocess.html)

> ## Setup
> * Model: roberta-base
> * Language: english
> * OS: Ubuntu 18.04.3
> * Python version: 3.7.3
> * PyTorch version: 1.3.1+cpu
> * PyTorch Transformers version (or branch): 2.2.0
> * Using GPU ? No
> * Distributed of parallel setup ? No
> * Script inputs:
> 
> ```
> python run_lm_finetuning.py \
> --output_dir=$OUTPUT_DIR \
> --model_type=roberta \
> --model_name_or_path=roberta_base \
> --do_train \
> --train_data_file=$TRAIN_FILE \
> --do_eval \
> --eval_data_file=$TEST_FILE \
> --mlm \
> --no_cuda
> ```
> 
> ##  Questions & Help
> Is there a way to run the above within python? Said differently, if I want to call `run_lm_finetuning.py` from within one of my own python scripts using the above configurations, how would I best go about doing that?
> 
> Thanks in advance!<|||||>@TheEdoardo93 roger that. Thanks!