diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 40845a2a..8340a3eb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: # Run ruff to lint and format - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.14.10 + rev: v0.15.9 hooks: # Run the linter. - id: ruff @@ -27,7 +27,7 @@ repos: # Find common spelling mistakes in comments and docstrings - repo: https://github.com/codespell-project/codespell - rev: v2.4.1 + rev: v2.4.2 hooks: - id: codespell args: ['--ignore-regex="(\b[A-Z]+\b)"', '--ignore-words-list=fom,appartment,bage,ore,setis,tabacco,berfore,vor,pris,WEGE,Wege,Eletricity'] # Ignore capital case words, e.g. country codes @@ -36,7 +36,7 @@ repos: # YAML formatting - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.15.0 + rev: v2.16.0 hooks: - id: pretty-format-yaml exclude: pinned\.yaml$ @@ -44,6 +44,6 @@ repos: # Format Snakemake rule / workflow files - repo: https://github.com/snakemake/snakefmt - rev: v0.11.2 + rev: v1.0.0 hooks: - id: snakefmt diff --git a/Snakefile b/Snakefile index c3a96952..dae6a2a0 100644 --- a/Snakefile +++ b/Snakefile @@ -30,13 +30,13 @@ rule compile_cost_assumptions: manual_input="inputs/manual_input.csv", output: expand("outputs/costs_{year}.csv", year=config["years"]), + log: + pathlib.Path("logs", "compile_cost_assumptions.log"), + conda: + "environment.yaml" threads: 1 resources: mem=500, - conda: - "environment.yaml" - log: - pathlib.Path("logs", "compile_cost_assumptions.log"), script: "scripts/compile_cost_assumptions.py" @@ -54,13 +54,13 @@ rule compile_cost_assumptions_usa: nrel_atb_input_fuel_costs="inputs/US/fuel_costs_usa.csv", output: expand("outputs/US/costs_{year}.csv", year=config["years"]), + log: + pathlib.Path("logs", "compile_cost_assumptions_usa.log"), + conda: + "environment.yaml" threads: 1 resources: mem=500, - conda: - "environment.yaml" - log: - pathlib.Path("logs", "compile_cost_assumptions_usa.log"), script: "scripts/compile_cost_assumptions_usa.py" @@ -82,20 +82,20 @@ rule convert_EWG: EWG="docu/EWG_LUT_100RE_All_Sectors_Global_Report_2019.pdf", output: costs="inputs/EWG_costs.csv", + conda: + "environment.yaml" threads: 1 resources: mem=500, - conda: - "environment.yaml" script: "scripts/convert_pdf_EWG_to_dataframe.py" rule all: + default_target: True input: rules.compile_cost_assumptions.output, rules.compile_cost_assumptions_usa.output, - default_target: True rule purge: diff --git a/scripts/compile_cost_assumptions_usa.py b/scripts/compile_cost_assumptions_usa.py index 97dc53fe..4500cd72 100644 --- a/scripts/compile_cost_assumptions_usa.py +++ b/scripts/compile_cost_assumptions_usa.py @@ -774,49 +774,55 @@ def pre_process_atb_input_file( # Modify the unit of the normalized Fixed O&M to %/yr atb_input_df["units"] = atb_input_df.apply( - lambda x: "%/year" - if x["core_metric_parameter"].casefold() == "fixed o&m" - else x["units"], + lambda x: ( + "%/year" + if x["core_metric_parameter"].casefold() == "fixed o&m" + else x["units"] + ), axis=1, ) # Modify the unit of CF to per unit atb_input_df["units"] = atb_input_df.apply( - lambda x: "per unit" - if x["core_metric_parameter"].casefold() == "cf" - else x["units"], + lambda x: ( + "per unit" if x["core_metric_parameter"].casefold() == "cf" else x["units"] + ), axis=1, ) # Modify the unit of Additional OCC to USD/kW instead of $/kW atb_input_df["units"] = atb_input_df.apply( - lambda x: "USD/kW" - if x["core_metric_parameter"].casefold() == "additional occ" - else x["units"], + lambda x: ( + "USD/kW" + if x["core_metric_parameter"].casefold() == "additional occ" + else x["units"] + ), axis=1, ) # Modify the unit of CAPEX to USD/kW instead of $/kW atb_input_df["units"] = atb_input_df.apply( - lambda x: "USD/kW" - if x["core_metric_parameter"].casefold() == "capex" - else x["units"], + lambda x: ( + "USD/kW" if x["core_metric_parameter"].casefold() == "capex" else x["units"] + ), axis=1, ) # Modify the unit of Variable O&M to USD/MWh instead of $/MWh atb_input_df["units"] = atb_input_df.apply( - lambda x: "USD/MWh" - if x["core_metric_parameter"].casefold() == "variable o&m" - else x["units"], + lambda x: ( + "USD/MWh" + if x["core_metric_parameter"].casefold() == "variable o&m" + else x["units"] + ), axis=1, ) # Modify the unit of Fuel cost O&M to USD/MWh instead of $/MWh atb_input_df["units"] = atb_input_df.apply( - lambda x: "USD/MWh" - if x["core_metric_parameter"].casefold() == "fuel" - else x["units"], + lambda x: ( + "USD/MWh" if x["core_metric_parameter"].casefold() == "fuel" else x["units"] + ), axis=1, )