From ae4730c0890e26332c1226911f6feae5fdbd83f4 Mon Sep 17 00:00:00 2001 From: Alex Meadows Date: Sat, 22 Jun 2019 16:30:48 -0400 Subject: [PATCH 1/2] process_tracker_python-60 Settings Manager should not try to create config file outright :bug: disabled config file creation when environment is cloud based. Hit bug when importing process_tracker in lambda where the SettingsManager could not write since the directory structure is read only. Will create a build and test. Closes #60 --- process_tracker/utilities/settings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/process_tracker/utilities/settings.py b/process_tracker/utilities/settings.py index d61cc74..0cd3f71 100644 --- a/process_tracker/utilities/settings.py +++ b/process_tracker/utilities/settings.py @@ -25,6 +25,7 @@ def __init__(self, config_location=None): self.aws_utils = AwsUtilities() exists = False + cloud = False if config_location is None: home = Path.home() @@ -62,14 +63,13 @@ def __init__(self, config_location=None): if self.aws_utils.determine_valid_s3_path( path=self.config_path ) and self.aws_utils.determine_s3_file_exists(path=self.config_file): - + cloud = True exists = True if exists: self.read_config_file() - else: - # How to handle if exists is false and it's s3? + elif not cloud: self.create_config_file() def create_config_file(self): From a1d9bfb0cb815dfa2e670bfca9e176fb72bdc9ca Mon Sep 17 00:00:00 2001 From: Alex Meadows Date: Sat, 22 Jun 2019 16:44:54 -0400 Subject: [PATCH 2/2] process_tracker_python-60 Settings Manager should not try to create config file outright :bug: disabled config file creation when environment is cloud based. Hit bug when importing process_tracker in lambda where the SettingsManager could not write since the directory structure is read only. Will create a build and test. Closes #60 --- process_tracker/extract_tracker.py | 5 ++++- process_tracker/process_tracker.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/process_tracker/extract_tracker.py b/process_tracker/extract_tracker.py index 97f8f7e..1b3e7a5 100755 --- a/process_tracker/extract_tracker.py +++ b/process_tracker/extract_tracker.py @@ -27,6 +27,7 @@ def __init__( location_name=None, location_path=None, status=None, + config_location=None, ): """ ExtractTracker is the primary engine for tracking data extracts @@ -43,8 +44,10 @@ def __init__( :type location_name: string :param status: Optional if status does not need to be 'initializing', which is default. :type status: string + :param config_location: Optional location for the process_tracker configuration file. + :type config_location: string """ - config = SettingsManager().config + config = SettingsManager(config_location=config_location).config self.logger = logging.getLogger(__name__) self.logger.setLevel(config["DEFAULT"]["log_level"]) diff --git a/process_tracker/process_tracker.py b/process_tracker/process_tracker.py index 18897a7..bd50926 100755 --- a/process_tracker/process_tracker.py +++ b/process_tracker/process_tracker.py @@ -71,10 +71,11 @@ def __init__( directory. :type config_location: file path """ - config = SettingsManager().config + self.config_location = config_location + self.config = SettingsManager(config_location=self.config_location).config self.logger = logging.getLogger(__name__) - self.logger.setLevel(config["DEFAULT"]["log_level"]) + self.logger.setLevel(self.config["DEFAULT"]["log_level"]) self.logger.addHandler(console) self.data_store = DataStore(config_location=config_location) @@ -395,11 +396,16 @@ def register_extracts_by_location(self, location_path, location_name=None): filename=file.key, location=location, status="ready", + config_location=self.config_location, ) else: for file in os.listdir(location_path): ExtractTracker( - process_run=self, filename=file, location=location, status="ready" + process_run=self, + filename=file, + location=location, + status="ready", + config_location=self.config_location, ) def register_new_process_run(self):