11import pandas as pd
22import asyncio
33import aiobotocore
4- from botocore import UNSIGNED
5- from botocore .config import Config
64import json
5+ import time
76
87from abc import ABC , abstractmethod
98
@@ -17,6 +16,7 @@ def __init__(self,
1716 aws_region ):
1817 self ._lambda_function_name = lambda_function_name
1918 self ._aws_region = aws_region
19+ self ._response_time_lambda = None
2020 self .aws_lambda_detailed_metrics = pd .DataFrame (columns = ['learner' , 'i_rep' , 'i_fold' ,
2121 'RequestId' , 'Duration' , 'Billed Duration' ,
2222 'Memory Size' , 'Max Memory Used' , 'Init Duration' ,
@@ -43,6 +43,7 @@ def aws_lambda_metrics(self):
4343 metrics ['Memory Size (MB; last request)' ] = df ['Memory Size' ].iloc [- 1 ]
4444 metrics ['Max Memory Used (MB)' ] = df ['Max Memory Used' ].max ()
4545 metrics ['Avg Max Memory Used (MB)' ] = df ['Max Memory Used' ].mean ()
46+ metrics ['Response Time' ] = self ._response_time_lambda
4647 return metrics
4748
4849 @abstractmethod
@@ -85,7 +86,10 @@ def fit_aws_lambda(self, n_lambdas_cv='n_folds * n_rep', seed=None, keep_scores=
8586
8687 def invoke_lambdas (self , payloads , smpls , params_names , n_obs , n_rep , n_jobs_cv ):
8788 loop = asyncio .get_event_loop ()
89+ start_time = time .time ()
8890 results = loop .run_until_complete (self .__invoke_aws_lambdas (payloads ))
91+ end_time = time .time ()
92+ self ._response_time_lambda = end_time - start_time
8993 preds , requests = _extract_preds (results , smpls , params_names ,
9094 n_obs , n_rep , n_jobs_cv )
9195 df_lambda_metrics = _extract_lambda_metrics (results )
0 commit comments