diff --git a/bin/purge_user_timeseries.py b/bin/purge_user_timeseries.py index 8c51aad42..d95a402ef 100644 --- a/bin/purge_user_timeseries.py +++ b/bin/purge_user_timeseries.py @@ -109,8 +109,8 @@ def purgeUserTimeseries(user_uuid, user_email=None, dir_name=DEFAULT_DIR_NAME, u export_file_name = dir_name + "/archive_%s_%s_%s" % (user_id, time_query.startTs, time_query.endTs) - start_ts_datetime = datetime.datetime.fromtimestamp(time_query.startTs).strftime('%Y-%m-%d %H:%M:%S') - end_ts_datetime = datetime.datetime.fromtimestamp(time_query.endTs).strftime('%Y-%m-%d %H:%M:%S') + start_ts_datetime = datetime.fromtimestamp(time_query.startTs).strftime('%Y-%m-%d %H:%M:%S') + end_ts_datetime = datetime.fromtimestamp(time_query.endTs).strftime('%Y-%m-%d %H:%M:%S') print("Start Time: ", start_ts_datetime) print("Start Ts: ", time_query.startTs) print("End Time: ", end_ts_datetime) @@ -143,7 +143,7 @@ def purgeUserTimeseries(user_uuid, user_email=None, dir_name=DEFAULT_DIR_NAME, u print(f"Key query: {key}") print("{} deleted entries from {} to {}".format(result.deleted_count, start_ts_datetime, end_ts_datetime)) - return file_name + return export_file_name if __name__ == '__main__': diff --git a/emission/analysis/classification/inference/labels/inferrers.py b/emission/analysis/classification/inference/labels/inferrers.py index 2c3f52f2c..04a59cdd9 100644 --- a/emission/analysis/classification/inference/labels/inferrers.py +++ b/emission/analysis/classification/inference/labels/inferrers.py @@ -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 @@ -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 = [] diff --git a/emission/analysis/modelling/trip_model/run_model.py b/emission/analysis/modelling/trip_model/run_model.py index 9bd59326a..7356aa597 100644 --- a/emission/analysis/modelling/trip_model/run_model.py +++ b/emission/analysis/modelling/trip_model/run_model.py @@ -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: @@ -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 diff --git a/emission/tests/exportTests/TestExportModule.py b/emission/tests/exportTests/TestExportModule.py index f4ce7ed80..93e10c136 100644 --- a/emission/tests/exportTests/TestExportModule.py +++ b/emission/tests/exportTests/TestExportModule.py @@ -33,7 +33,7 @@ def testExportModule(self): self.assertTrue(pl.Path(file_name).is_file()) with gzip.open(file_name, 'r') as ef: exported_data = json.loads(ef.read().decode('utf-8')) - + confirmed_trips_exported = [] for t in exported_data: if t['metadata']['key'] == "analysis/confirmed_trip":