Reputation: 411
I have a file I want to import into a Sagemaker Jupyter notebook python 3 instance for use. The exact code would be 'import lstm.' I can store the file in s3 (which would probably be ideal) or locally, whichever you prefer. I have been searching the internet for a while and have been unable to find a solution to this. I am actually just trying to run/understand this code from Suraj Raval's youtube channel: https://github.com/llSourcell/Bitcoin_Trading_Bot. The 'import lstm' line is failing when I run, and I am trying to figure out how to make this work.
I have tried: from s3://... import lstm. failed I have tried some boto3 methods and wasn't able to get it to work.
import time
import threading
import lstm, etl, json. ##this line
import numpy as np
import pandas as pd
import h5py
import matplotlib.pyplot as plt
configs = json.loads(open('configs.json').read())
tstart = time.time()
I would just like to be able to import the lstm file and all the others into a Jupyter notebook instance.
Upvotes: 3
Views: 3059
Reputation: 1213
I think you should be cloning the Github repo in SageMaker instance and not importing the files from S3. I was able to reproduce the Bitcoin Trading Bot notebook from SageMaker by cloning it. You can follow the below steps
cd ~/SageMaker
git clone https://github.com/llSourcell/Bitcoin_Trading_Bot.git
cd Bitcoin_Trading_Bot
Bitcoin LSTM Prediction.ipynb
and select the Tensorflow Kernel to run the notebook.To add files from your local machine to SageMaker Notebook instance, you can use file upload functionality in JupyterLab
To add files from S3 to SageMaker Notebook instance, use AWS CLI or Python SDK to upload/download files.
For example, to download lstm.py
file from S3 to SageMaker using AWS CLI
aws s3 cp s3://mybucket/bot/src/lstm.py .
Using boto3
API
import boto3
s3 = boto3.resource('s3')
s3.meta.client.download_file('mybucket', 'bot/src/lstm.py', './lstm.py')
Upvotes: 4