Skip to content
14 changes: 6 additions & 8 deletions ec2deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
parser.add_argument('enable_cors')
args = parser.parse_args()

#comment occurences of AWS_SESSION_TOKEN and session_token
#if you are not using an AWS Educate Account
# comment occurences of AWS_SESSION_TOKEN and session_token
# if you are not using an AWS Educate Account

session = boto3.Session()
access_key = session.get_credentials().access_key
secret_key = session.get_credentials().secret_key
session_token = session.get_credentials().token
ec2 = session.resource('ec2')

start_up_script="""#!/usr/bin/env bash
start_up_script = """#!/usr/bin/env bash
export AWS_ACCESS_KEY_ID='{access_key}'
export AWS_SECRET_ACCESS_KEY='{secret_key}'
export AWS_SESSION_TOKEN='{session_token}'
Expand Down Expand Up @@ -54,7 +54,7 @@

print('Instance {} was started. Waiting for output ...'.format(i.instance_id))

prev_output=''
prev_output = ''
while True:
time.sleep(10)
o = i.console_output()
Expand All @@ -63,16 +63,14 @@
if output != prev_output:
print('...\n'*3)
print(output)
prev_output=output
prev_output = output
if i.state['Name'] == 'terminated':
break

success_string='Stack {} was successfully deployed'.format(args.stack_name)
success_string = 'Stack {} was successfully deployed'.format(args.stack_name)

print(('#'*60+'\n')*3)
if success_string in prev_output:
print(success_string)
else:
print('There were some problems. See above output for more details')


2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ <h3 class="text-center">Test Results
console.log(userInfo.duration, "seconds of execution time.")
console.log(userInfo,"userInfo")
document.getElementById("responseJSON").value = JSON.stringify(userInfo.ipynb);
document.getElementById("resultJSON").value = JSON.stringify(userInfo.result);
document.getElementById("resultJSON").value = JSON.stringify(userInfo.results,null,'\t');

// pass data to component via problem global object
window.problem = userInfo.ipynb;
Expand Down
15 changes: 7 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

os.environ['PYTHONPATH'] = os.environ['PYTHONPATH'] + ":" + CURRENT_DIR + ":" + BUILD_DIR + ":" + OVERLAY_DIR




import logging
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
Expand Down Expand Up @@ -56,7 +53,6 @@ def save_files_to_temp_dir(files):

def execute_notebook(source):
"""

:param source: Jupyter Notebook
:return: Result of the notebook invocation
"""
Expand Down Expand Up @@ -115,19 +111,22 @@ def handler(event, context):
attached_files = request_body['files'] if 'files' in request_body else {}
save_files_to_temp_dir(attached_files)



start = timer()
result = execute_notebook(json.dumps(notebook_source))
result = json.loads(result)

exec_result = return_result_json()

print(exec_result)
print(type(exec_result))
if(exec_result and isinstance(exec_result, str)):
exec_result_loaded = json.loads(exec_result)
else:
exec_result_loaded = exec_result
end = timer()
duration = end - start
response = {
"statusCode": 200,
"body": json.dumps({"duration": duration,"ipynb": result, "result": exec_result}),
"body": json.dumps({"duration": duration,"ipynb": result, "result": exec_result, "results":exec_result_loaded}),
"headers": {
'Content-Type': 'application/json',
}
Expand Down
Binary file modified requirements.txt
Binary file not shown.