Commit 91322ba4 authored by aakash.bedi's avatar aakash.bedi

updated destructors

parent b16a85d1
Pipeline #59985 failed with stage
...@@ -19,6 +19,31 @@ class AiModelling: ...@@ -19,6 +19,31 @@ class AiModelling:
for inv_id in list(self.df_raw_tags['inv_id'].unique()): for inv_id in list(self.df_raw_tags['inv_id'].unique()):
df = self.df_raw_tags[self.df_raw_tags['inv_id'] == inv_id] df = self.df_raw_tags[self.df_raw_tags['inv_id'] == inv_id]
for mppt_id in list(self.df_raw_tags['mppt_id'].unique()): for mppt_id in list(self.df_raw_tags['mppt_id'].unique()):
print(f'memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}')
data_modelling = DataModelling(start_timestamp=self.start_timestamp,
end_timestamp=self.end_timestamp,
df_coefficients=self.df_coefficients)
data_modelling.get_data(inv_id=inv_id, mppt_id=mppt_id, df=df)
del data_modelling
except Exception as e:
logger.exception(f'Exception - {e}')
def __del__(self):
try:
print('destructor called, AiModelling die!')
except Exception as e:
logger.exception(f'Exception - {e}')
class DataModelling:
def __init__(self, start_timestamp, end_timestamp, df_coefficients):
self.start_timestamp = start_timestamp
self.end_timestamp = end_timestamp
self.df_coefficients = df_coefficients
def get_data(self, inv_id, mppt_id, df):
try:
print(f'1st memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}') print(f'1st memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}')
gc.collect() gc.collect()
tracemalloc.reset_peak() tracemalloc.reset_peak()
...@@ -87,6 +112,6 @@ class AiModelling: ...@@ -87,6 +112,6 @@ class AiModelling:
def __del__(self): def __del__(self):
try: try:
print('destructor called, die!') print('destructor called, DataModelling die!')
except Exception as e: except Exception as e:
logger.exception(f'Exception - {e}') logger.exception(f'Exception - {e}')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment