Skip to content
This repository was archived by the owner on Mar 13, 2020. It is now read-only.

Commit 95d3ff8

Browse files
committed
SP-149 - when logging execution and execution-model, ensure that all available details are logged.
1 parent df984d3 commit 95d3ff8

File tree

3 files changed

+62
-23
lines changed

3 files changed

+62
-23
lines changed

rdl/data_load_tracking/DataLoadTrackerRepository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def complete_execution(self, execution_id, total_number_of_models,
5353
current_execution.rows_processed = total_rows_processed
5454
current_execution.batches_processed = total_batches_processed
5555
session.commit()
56-
self.logger.info(current_execution)
56+
self.logger.info(f'Completed {current_execution}')
5757
session.close()
5858
return total_rows_processed
5959

rdl/entities/execution_entity.py

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,35 @@ class ExecutionEntity(Base):
2323
models_processed = Column(Integer, nullable=True)
2424

2525
def __str__(self):
26-
if self.status == Constants.ExecutionStatus.STARTED:
27-
return f"Started Execution ID: {self.execution_id} at {self.started_on}"
28-
29-
total_execution_seconds = self.execution_time_s
30-
execution_hours = total_execution_seconds // 3600
31-
execution_minutes = (total_execution_seconds // 60) % 60
32-
execution_seconds = total_execution_seconds % 60
33-
34-
return f"Completed Execution ID: {self.execution_id}" \
35-
f"; Models Processed: {self.models_processed:,}" \
36-
f"; Rows Processed: {self.rows_processed:,}" \
37-
f"; Execution Time: {execution_hours}h {execution_minutes}m {execution_seconds}s" \
38-
f"; Average rows processed per second: {(self.rows_processed//max(total_execution_seconds, 1)):,}."
26+
execution_time_str = None
27+
rows_per_second = None
28+
29+
if self.execution_time_s:
30+
total_execution_seconds = self.execution_time_s
31+
32+
execution_hours = total_execution_seconds // 3600
33+
execution_minutes = (total_execution_seconds // 60) % 60
34+
execution_seconds = total_execution_seconds % 60
35+
execution_time_str = f'{execution_hours}h {execution_minutes}m {execution_seconds}s'
36+
37+
if self.rows_processed:
38+
rows_per_second = (self.rows_processed//max(total_execution_seconds, 1))
39+
40+
return 'Execution ID: {exec_id}; ' \
41+
'Status: {status}; ' \
42+
'Started on: {started}; ' \
43+
'Completed on: {completed}; ' \
44+
'Execution time: {exec_time}; ' \
45+
'Models processed: {models}; ' \
46+
'Batches processed: {batches};' \
47+
'Rows processed: {rows}; ' \
48+
'Average rows processed per second: {rows_per_second};'.format(
49+
exec_id=self.execution_id,
50+
status=self.status,
51+
started=self.started_on.isoformat(),
52+
completed=self.completed_on.isoformat() if self.completed_on else '',
53+
exec_time=execution_time_str if self.execution_time_str else '',
54+
models=f'{self.models_processed:,}' if self.models_processed else '',
55+
batches=f'{self.batches_processed:,}' if self.batches_processed else '',
56+
rows=f'{self.rows_processed:,}' if self.rows_processed else '',
57+
rows_per_second=f'{rows_per_second:,}' if rows_per_second else '')

rdl/entities/execution_model_entity.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,32 @@ class ExecutionModelEntity(Base):
3636
failure_reason = Column(String(1000), nullable=True)
3737

3838
def __str__(self):
39-
load_type = 'FULL' if self.is_full_refresh else f"INCREMENTAL from " \
40-
f"version '{self.last_sync_version}' " \
41-
f"to '{self.sync_version}'"
42-
43-
execution_tims_s = max(self.execution_time_ms // 1000, 1)
44-
rows_per_second = self.rows_processed / execution_tims_s
45-
return f"Rows: {self.rows_processed}, " \
46-
f"Load type: {load_type}, " \
47-
f"Total Execution Time: {execution_tims_s}s @ {rows_per_second:.2f} rows per second "
39+
load_type = f'FULL ({self.full_refresh_reason})' if self.is_full_refresh else \
40+
f"INCREMENTAL from version '{self.last_sync_version}' to '{self.sync_version}'"
41+
execution_time_s = None
42+
rows_per_second = None
43+
44+
if self.execution_time_ms:
45+
execution_time_s = max(self.execution_time_ms // 1000, 1)
46+
47+
if self.rows_processed:
48+
rows_per_second = self.rows_processed / execution_time_s
49+
50+
return 'Model: {model}; ' \
51+
'Load type: {load_type}; ' \
52+
'Status: {status}; ' \
53+
'Started on: {started}; ' \
54+
'Completed on: {completed}; ' \
55+
'Execution time: {exec_time}; ' \
56+
'Batches processed: {batches}; ' \
57+
'Rows processed: {rows}; ' \
58+
'Average rows processed per second: {rows_per_second};'.format(
59+
model=self.model_name,
60+
load_type=load_type,
61+
status=self.status,
62+
started=self.started_on.isoformat(),
63+
completed=self.completed_on.isoformat() if self.completed_on else '',
64+
exec_time=f'{execution_time_s}s' if execution_time_s else '',
65+
batches=f'{self.batches_processed:,}' if self.batches_processed else '',
66+
rows=f'{self.rows_processed:,}' if self.rows_processed else '',
67+
rows_per_second=f'{rows_per_second:,}' if rows_per_second else '')

0 commit comments

Comments
 (0)