{"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":"# # This Python 3 environment comes with many helpful analytics libraries installed\n# # It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# # For example, here's several helpful packages to load\n\n# import numpy as np # linear algebra\n# import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# # Input data files are available in the read-only \"../input/\" directory\n# # For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\n# import os\n# for dirname, _, filenames in os.walk('/kaggle/input'):\n#     for filename in filenames:\n#         print(os.path.join(dirname, filename))\n\n# # You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# # You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport numpy as np\nfrom PIL import Image\nImage.MAX_IMAGE_PIXELS = None\n\nprint(os.stat('../input/mayo-clinic-strip-ai/train/006388_0.tif').st_size)\n\nprint('stuck')\nim = Image.open('../input/mayo-clinic-strip-ai/train/006388_0.tif')\nprint('unstuck')\nim = np.array(im)\nprint('again')\nim.shape()\n\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# from kaggle_secrets import UserSecretsClient\n# user_secrets = UserSecretsClient()\n# aws_id = user_secrets.get_secret(\"aws_access_key_id\")\n# aws_key = user_secrets.get_secret(\"aws_secret_access_key\")\n# aws_region = user_secrets.get_secret(\"aws_region\")","metadata":{"execution":{"iopub.status.busy":"2022-07-17T23:27:50.880093Z","iopub.execute_input":"2022-07-17T23:27:50.88067Z","iopub.status.idle":"2022-07-17T23:27:51.6241Z","shell.execute_reply.started":"2022-07-17T23:27:50.880611Z","shell.execute_reply":"2022-07-17T23:27:51.622555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import boto3\nimport uuid\nimport os\n\ns3 = boto3.resource(\n    's3',\n    aws_access_key_id=aws_id,\n    aws_secret_access_key=aws_key,\n)\n\ns3_client = boto3.client(\n    's3',\n    aws_access_key_id=aws_id,\n    aws_secret_access_key=aws_key,\n)\nbucket_name = ''.join(['biopsydata', str(uuid.uuid4())])\nprint('here1')\nbucket_response = s3_client.create_bucket(Bucket=bucket_name)\nprint('here2')\nresponse = s3_client.list_buckets()\nprint('here3')\n\n# Output the bucket names\n#print('Existing buckets:')\n#for bucket in response['Buckets']:\n#    print(f'  {bucket[\"Name\"]}')\n\n\nfor dirname, _, filenames in os.walk('../input/mayo-clinic-strip-ai/train'):\n    print('here4')\n    for filename in filenames:\n        print('here5')\n#        print(os.path.join(dirname, filename))\n        file_name = os.path.join(dirname, filename)\n        response = s3_client.upload_file(file_name, bucket_name, filename)\n\n# Let us get some feedback: the list of the objects of our Bucket is very verbose and we can\n# check that everything is OK\n\ns3_client.list_objects_v2(Bucket=bucket_name)","metadata":{"execution":{"iopub.status.busy":"2022-07-17T23:37:36.549335Z","iopub.execute_input":"2022-07-17T23:37:36.550014Z","iopub.status.idle":"2022-07-18T00:31:58.424795Z","shell.execute_reply.started":"2022-07-17T23:37:36.549969Z","shell.execute_reply":"2022-07-18T00:31:58.423722Z"},"trusted":true},"execution_count":null,"outputs":[]}]}