Im doing a machine learning project in google colab. Each time an instance is started, I want to run these commands:
! mkdir ~/.kaggle # make directory ".kaggle"
! cp kaggle.json ~/.kaggle/ # copy the json file into the directory
! chmod 600 ~/.kaggle/kaggle.json # allocate required permission for the file
! kaggle datasets download -d alessiocorrado99/animals10 # download animal set
! unzip animals10.zip
These commands download and extract a dataset I need. However, it only needs to be ran the first run through only. When clicking "Run All" after the initial download of the dataset, it requires user input to decide whether to replace the files or not. I also don't want to keep downloading from kaggle and use resources unnecesarily.
My current approach is to run the script once then comment out the initialization script, but this takes time and effort.
How can I automate this process so a certain cell only runs on the first run of the runtime?