Skip to content

Commit a072861

Browse files
authored
Merge pull request #163 from OpenDataAlex/process_tracker_python-150
process_tracker_python-150 Change process_run_id to process_tracking_id
2 parents 6fe5e2d + 7c9b807 commit a072861

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

process_tracker/process_tracker.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(
7373
config_location=None,
7474
dataset_types=None,
7575
schedule_frequency=None,
76-
process_run_id=None,
76+
process_tracking_id=None,
7777
):
7878
"""
7979
ProcessTracker is the primary engine for tracking data integration processes.
@@ -104,9 +104,9 @@ def __init__(
104104
:type dataset_types: list
105105
:param schedule_frequency: The general scheduling frequency for the process (i.e. hourly)
106106
:type schedule_frequency: string
107-
:param process_run_id: If trying to access an already running process, provide the process run's id.
107+
:param process_tracking_id: If trying to access an already running process, provide the process run's id.
108108
Object will be built for that specific process run.
109-
:type process_run_id: int
109+
:type process_tracking_id: int
110110
"""
111111
self.config_location = config_location
112112
self.config = SettingsManager(config_location=self.config_location)
@@ -128,11 +128,13 @@ def __init__(
128128
self.process_status_failed = self.process_status_types["failed"]
129129
self.process_status_hold = self.process_status_types["on hold"]
130130

131-
if process_run_id is not None:
131+
if process_tracking_id is not None:
132132
self.logger.info("Process run id provided. Checking if exists.")
133133

134134
process_run = self.data_store.get_or_create_item(
135-
model=ProcessTracking, process_tracking_id=process_run_id, create=False
135+
model=ProcessTracking,
136+
process_tracking_id=process_tracking_id,
137+
create=False,
136138
)
137139

138140
if process_run is not None:
@@ -145,18 +147,20 @@ def __init__(
145147

146148
self.dataset_types = process_run.process.dataset_types
147149
self.sources = self.determine_process_sources(
148-
process_run_id=process_run_id
150+
process_run_id=process_tracking_id
149151
)
150152
self.targets = self.determine_process_targets(
151-
process_run_id=process_run_id
153+
process_run_id=process_tracking_id
152154
)
153155

154156
self.process_name = process_run.process.process_name
155157
self.process_tracking_run = process_run
156158
self.process_run_name = process_run.process_run_name
157159

158160
else:
159-
error_msg = "Process run not found based on id %s." % process_run_id
161+
error_msg = (
162+
"Process run not found based on id %s." % process_tracking_id
163+
)
160164
self.logger.error(error_msg)
161165
raise Exception(error_msg)
162166
else:
@@ -325,7 +329,7 @@ def determine_hold_status(self, last_run_status, last_run_id):
325329
Based on the setting 'max_concurrent_failures', count the number of failures for that number of process runs.
326330
If the counts match, process will remain on hold. If last run is 'on_hold' process will remain on hold.
327331
:param last_run_status: The status of the previous run
328-
:param last_run_id: The process_run_id of the previous run
332+
:param last_run_id: The process_tracking_id of the previous run
329333
:return:
330334
"""
331335
self.logger.debug("Determining if process should be put on or remain on hold.")
@@ -362,7 +366,7 @@ def determine_hold_status(self, last_run_status, last_run_id):
362366

363367
def determine_process_sources(self, process_run_id):
364368
"""
365-
Based on the process_run_id, find the given process' sources - either at the attribute, object, or source level
369+
Based on the process_tracking_id, find the given process' sources - either at the attribute, object, or source level
366370
:param process_run_id: Process run identifier
367371
:type process_run_id: int
368372
:return: Array of source objects at lowest granularity.
@@ -425,7 +429,7 @@ def determine_process_sources(self, process_run_id):
425429

426430
def determine_process_targets(self, process_run_id):
427431
"""
428-
Based on the process_run_id, find the given process' targets - either at the attribute, object, or source level
432+
Based on the process_tracking_id, find the given process' targets - either at the attribute, object, or source level
429433
:param process_run_id: Process run identifier
430434
:type process_run_id: int
431435
:return: Array of source objects used as target for the process at lowest granularity.

tests/test_process_tracker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,7 @@ def test_process_tracker_with_process_run_id(self):
21502150
"""
21512151
process_run_id = self.process_tracker.process_tracking_run.process_tracking_id
21522152

2153-
new_process_tracker = ProcessTracker(process_run_id=process_run_id)
2153+
new_process_tracker = ProcessTracker(process_tracking_id=process_run_id)
21542154

21552155
expected_process_name_result = self.process_tracker.process_name
21562156
given_process_name_result = new_process_tracker.process_name
@@ -2193,7 +2193,7 @@ def test_determine_process_sources(self):
21932193
"""
21942194
process_run_id = self.process_tracker.process_tracking_run.process_tracking_id
21952195

2196-
new_process_tracker = ProcessTracker(process_run_id=process_run_id)
2196+
new_process_tracker = ProcessTracker(process_tracking_id=process_run_id)
21972197

21982198
given_sources = new_process_tracker.sources
21992199
expected_sources = self.process_tracker.sources
@@ -2208,7 +2208,7 @@ def test_determine_process_targets(self):
22082208
"""
22092209
process_run_id = self.process_tracker.process_tracking_run.process_tracking_id
22102210

2211-
new_process_tracker = ProcessTracker(process_run_id=process_run_id)
2211+
new_process_tracker = ProcessTracker(process_tracking_id=process_run_id)
22122212

22132213
given_targets = new_process_tracker.targets
22142214
expected_targets = self.process_tracker.targets

0 commit comments

Comments
 (0)