{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "95977565",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages/pandas/core/computation/expressions.py:21: UserWarning: Pandas requires version '2.8.0' or newer of 'numexpr' (version '2.7.3' currently installed).\n",
      "  from pandas.core.computation.check import NUMEXPR_INSTALLED\n"
     ]
    }
   ],
   "source": [
    "import boto3\n",
    "import pickle\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ec30e2b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "test = [1,2,3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "1d0b01c8",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block after 'with' statement on line 4 (3261830801.py, line 5)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  Cell \u001b[0;32mIn[15], line 5\u001b[0;36m\u001b[0m\n\u001b[0;31m    pickle.dump(test, file)\u001b[0m\n\u001b[0m    ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m expected an indented block after 'with' statement on line 4\n"
     ]
    }
   ],
   "source": [
    "# Save the model to disk\n",
    "pkl_filename = 'test'\n",
    "\n",
    "with open(pkl_filename, 'wb') as file:\n",
    "    pickle.dump(test, file)\n",
    "\n",
    "s3_resource = boto3.resource('s3')\n",
    "bucket = 'dev-cucumbers'\n",
    "key = 'eimpara/MAZE/test.pkl'\n",
    "    \n",
    "    # Read the pickled file as bytes\n",
    "with open(pkl_filename, 'rb') as f:\n",
    "    pickle_bytes_obj = f.read()\n",
    "\n",
    "    # Upload the pickled file to S3\n",
    "s3_resource.Bucket(bucket).put_object(Key=key, Body=pickle_bytes_obj)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "83dcc459",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "conda_python3",
   "language": "python",
   "name": "conda_python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
