Skip to content

Commit

Permalink
Fix directory creation for cache folder
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMcInnis committed Sep 10, 2020
1 parent b9af5c2 commit c228fab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions jobfunnel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def main():

# Build config manager
funnel_cfg = get_config_manager(cfg_dict)
funnel_cfg.create_dirs()

# Init
job_funnel = JobFunnel(funnel_cfg)
Expand Down
3 changes: 1 addition & 2 deletions jobfunnel/backend/jobfunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ def __init__(self, config: JobFunnelConfigManager) -> None:
Args:
config (JobFunnelConfigManager): config object containing paths etc.
"""
config.validate() # NOTE: this ensures logger gets a good path
super().__init__(level=config.log_level, file_path=config.log_file)
self.config = config
self.config.create_dirs()
self.config.validate()
self.__date_string = date.today().strftime("%Y-%m-%d")
self.master_jobs_dict = {} # type: Dict[str, Job]

Expand Down
9 changes: 5 additions & 4 deletions jobfunnel/config/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ def create_dirs(self) -> None:
"""Create the directories for attributes which refer to files / folders
NOTE: should be called before we validate()
"""
for path_attr in [self.master_csv_file, self.user_block_list_file,
self.duplicates_list_file, self.cache_folder,
self.log_file]:
output_dir = os.path.dirname(os.path.abspath(path_attr))
for file_path in [self.master_csv_file, self.user_block_list_file,
self.duplicates_list_file, self.log_file]:
output_dir = os.path.dirname(os.path.abspath(file_path))
if not os.path.exists(output_dir):
os.makedirs(output_dir)
if not os.path.exists(self.cache_folder):
os.makedirs(self.cache_folder)

def validate(self) -> None:
"""Validate the config object i.e. paths exit
Expand Down

0 comments on commit c228fab

Please sign in to comment.