Skip to content

Commit

Permalink
Reverted commit 31626ba + Removed log statements
Browse files Browse the repository at this point in the history
Commit 31626ba included changes related to vulnerability fixes, hence reverted them.

Had added some log statements related to scalability fixes for model loading.
Removed them and will add in separate PR.
  • Loading branch information
Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed Jan 26, 2024
1 parent 35ea713 commit f54e85f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 2 additions & 8 deletions emission/analysis/classification/inference/labels/inferrers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import copy
import time
import arrow
from uuid import UUID

import emission.analysis.modelling.tour_model_first_only.load_predict as lp
import emission.analysis.modelling.trip_model.run_model as eamur
Expand Down Expand Up @@ -172,19 +171,14 @@ def predict_cluster_confidence_discounting(trip_list, max_confidence=None, first
user_id_list = []
for trip in trip_list:
user_id_list.append(trip['user_id'])
error_message = f"""
Multiple user_ids found for trip_list, expected unique user_id for all trips.
Unique user_ids count = {len(set(user_id_list))}
{set(user_id_list)}
"""
assert user_id_list.count(user_id_list[0]) == len(user_id_list), error_message
assert user_id_list.count(user_id_list[0]) == len(user_id_list), "Multiple user_ids found for trip_list, expected unique user_id for all trips"
# Assertion successful, use unique user_id
user_id = user_id_list[0]

# load model
start_model_load_time = time.process_time()
model = eamur._load_stored_trip_model(user_id, model_type, model_storage)
logging.debug(f"{arrow.now()} Inside predict_cluster_confidence_discounting: Model load time = {time.process_time() - start_model_load_time}")
print(f"{arrow.now()} Inside predict_labels_n: Model load time = {time.process_time() - start_model_load_time}")

labels_n_list = eamur.predict_labels_with_n(trip_list, model)
predictions_list = []
Expand Down
4 changes: 2 additions & 2 deletions emission/analysis/modelling/trip_model/run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def predict_labels_with_n(
"""

predictions_list = []
logging.debug(f"{arrow.now()} Inside predict_labels_n: Predicting...")
print(f"{arrow.now()} Inside predict_labels_n: Predicting...")
start_predict_time = time.process_time()
for trip in trip_list:
if model is None:
Expand All @@ -118,7 +118,7 @@ def predict_labels_with_n(
else:
predictions, n = model.predict(trip)
predictions_list.append((predictions, n))
logging.debug(f"{arrow.now()} Inside predict_labels_n: Predictions complete for trip_list in time = {time.process_time() - start_predict_time}")
print(f"{arrow.now()} Inside predict_labels_n: Predictions complete for trip_list in time = {time.process_time() - start_predict_time}")
return predictions_list


Expand Down

0 comments on commit f54e85f

Please sign in to comment.