singularity-energy / open-grid-emissions

Tools for producing high-quality hourly generation and emissions data for U.S. electric grids
MIT License
67 stars 4 forks source link

Fix logging bug #298

Closed grgmiller closed 1 year ago

grgmiller commented 1 year ago

In data_pipeline.main() we were configuring the root logger to log to results_folder(f"{year}/data_quality_metrics/data_pipeline.log") as one of the first lines of code. However, in the next block of code we remove the results folder if it already exists:

if os.path.exists(results_folder(f"{path_prefix}")):
            shutil.rmtree(results_folder(f"{path_prefix}"))

However, this was raising the following error:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'A:\\GitHub\\open-grid-emissions\\data\\results\\2019/data_quality_metrics\\data_pipeline.log'

This PR moves the logging configuration after the block of code that sets up the directory structure to avoid this error.

I have also tacked on a small update to the CITATION.CFF file for the most recent version.

NOTE: I am proposing that we merge this directly into main instead of dev since this is a bug fix that does not affect any of the outputs. I would merge this into main without doing another versioned release for now.

grgmiller commented 1 year ago

Ok, merging into dev for now.