{"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-11T04:38:58.477365Z","iopub.execute_input":"2022-08-11T04:38:58.478588Z","iopub.status.idle":"2022-08-11T04:38:58.512061Z","shell.execute_reply.started":"2022-08-11T04:38:58.478467Z","shell.execute_reply":"2022-08-11T04:38:58.511110Z"},"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-11T04:38:58.513932Z","iopub.execute_input":"2022-08-11T04:38:58.514823Z","iopub.status.idle":"2022-08-11T04:38:58.521746Z","shell.execute_reply.started":"2022-08-11T04:38:58.514785Z","shell.execute_reply":"2022-08-11T04:38:58.520760Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bucket_name = \"bucket-tikutiku\"\nfolder = \"29_vl_01_deberta-v3-large\"\nmodel_name = 'microsoft/deberta-v3-large'\nseed = 100\n\ndownload_to_kaggle(bucket_name, folder, seed)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T04:38:58.522930Z","iopub.execute_input":"2022-08-11T04:38:58.523910Z"},"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":[]}]}