{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"##### Cloud Storage\nimport os\nfrom pathlib import Path\nfrom google.cloud import storage\nstorage_client = storage.Client(project='feedback2')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-10T02:28:11.207234Z","iopub.execute_input":"2022-08-10T02:28:11.207682Z","iopub.status.idle":"2022-08-10T02:28:11.239712Z","shell.execute_reply.started":"2022-08-10T02:28:11.207593Z","shell.execute_reply":"2022-08-10T02:28:11.238874Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def download_to_kaggle(bucket_name, folder_name, seed):\n    \"\"\"Takes the data from your GCS Bucket and puts it into the working directory of your Kaggle notebook\"\"\"\n    destination_directory = Path(f\"/kaggle/working/\")\n    blobs = storage_client.list_blobs(bucket_name)\n    for blob in blobs:\n        if blob.name.startswith(folder_name) and blob.name.split('/')[-1]!=\"\":\n            save_path = destination_directory / Path(blob.name.split('/')[-1].replace(f'_seed{seed}','').replace('_swa',''))\n            save_path.parent.mkdir(parents=True, exist_ok=True)\n            print(save_path)\n            blob.download_to_filename(save_path)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T02:28:11.241523Z","iopub.execute_input":"2022-08-10T02:28:11.242517Z","iopub.status.idle":"2022-08-10T02:28:11.249751Z","shell.execute_reply.started":"2022-08-10T02:28:11.242483Z","shell.execute_reply":"2022-08-10T02:28:11.249065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bucket_name = \"bucket-tikutiku\"\nfolder = \"29_v2_02_deberta-xlarge\"\nmodel_name = 'microsoft/deberta-xlarge'\nseed = 100\n\ndownload_to_kaggle(bucket_name, folder, seed)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T02:28:11.251263Z","iopub.execute_input":"2022-08-10T02:28:11.251578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from transformers import AutoTokenizer, AutoModel\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModel.from_pretrained(model_name)\ntokenizer.save_pretrained(f\"/kaggle/working\")\nmodel.save_pretrained(f\"/kaggle/working\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}