Skip to content

Commit 327111c

Browse files
authored
Merge pull request #61 from OpenDataAlex/process_tracker_python-60
Process tracker python 60
2 parents d1beb52 + a1d9bfb commit 327111c

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

process_tracker/extract_tracker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(
2727
location_name=None,
2828
location_path=None,
2929
status=None,
30+
config_location=None,
3031
):
3132
"""
3233
ExtractTracker is the primary engine for tracking data extracts
@@ -43,8 +44,10 @@ def __init__(
4344
:type location_name: string
4445
:param status: Optional if status does not need to be 'initializing', which is default.
4546
:type status: string
47+
:param config_location: Optional location for the process_tracker configuration file.
48+
:type config_location: string
4649
"""
47-
config = SettingsManager().config
50+
config = SettingsManager(config_location=config_location).config
4851

4952
self.logger = logging.getLogger(__name__)
5053
self.logger.setLevel(config["DEFAULT"]["log_level"])

process_tracker/process_tracker.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ def __init__(
7171
directory.
7272
:type config_location: file path
7373
"""
74-
config = SettingsManager().config
74+
self.config_location = config_location
75+
self.config = SettingsManager(config_location=self.config_location).config
7576

7677
self.logger = logging.getLogger(__name__)
77-
self.logger.setLevel(config["DEFAULT"]["log_level"])
78+
self.logger.setLevel(self.config["DEFAULT"]["log_level"])
7879
self.logger.addHandler(console)
7980

8081
self.data_store = DataStore(config_location=config_location)
@@ -395,11 +396,16 @@ def register_extracts_by_location(self, location_path, location_name=None):
395396
filename=file.key,
396397
location=location,
397398
status="ready",
399+
config_location=self.config_location,
398400
)
399401
else:
400402
for file in os.listdir(location_path):
401403
ExtractTracker(
402-
process_run=self, filename=file, location=location, status="ready"
404+
process_run=self,
405+
filename=file,
406+
location=location,
407+
status="ready",
408+
config_location=self.config_location,
403409
)
404410

405411
def register_new_process_run(self):

process_tracker/utilities/settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self, config_location=None):
2525
self.aws_utils = AwsUtilities()
2626

2727
exists = False
28+
cloud = False
2829

2930
if config_location is None:
3031
home = Path.home()
@@ -62,14 +63,13 @@ def __init__(self, config_location=None):
6263
if self.aws_utils.determine_valid_s3_path(
6364
path=self.config_path
6465
) and self.aws_utils.determine_s3_file_exists(path=self.config_file):
65-
66+
cloud = True
6667
exists = True
6768

6869
if exists:
6970
self.read_config_file()
70-
else:
71-
# How to handle if exists is false and it's s3?
7271

72+
elif not cloud:
7373
self.create_config_file()
7474

7575
def create_config_file(self):

0 commit comments

Comments
 (0)