Skip to content

Commit

Permalink
Fix snakemake workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed Nov 4, 2024
1 parent 2dca736 commit f09c6ca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions workflow.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from pathlib import Path
from pyam import IamDataFrame
import pyam
from nomenclature import DataStructureDefinition, RegionProcessor, process
import logging


here = Path(__file__).absolute().parent


logger = logging.getLogger(__name__)

file_handler = logging.FileHandler(snakemake.log[0], mode="a")
Expand All @@ -20,14 +18,16 @@
logging.getLogger(logger_name).addHandler(file_handler)


def main(df: IamDataFrame) -> IamDataFrame:
def main(df: pyam.IamDataFrame) -> pyam.IamDataFrame:
"""Project/instance-specific workflow for scenario processing"""

# Run the validation and region-processing
dsd = DataStructureDefinition(here / "definitions")
processor = RegionProcessor.from_directory(path=here / "mappings", dsd=dsd)
return process(df, dsd, processor=processor)


logger.info(f"Starting processing for {snakemake.input[0]}")
main(pyam.IamDataFrame(snakemake.input[0])).to_excel(snakemake.output[0])
logger.info(f"Successfully finished processing for {snakemake.input[0]}")

0 comments on commit f09c6ca

Please sign in to comment.