1- import os
21import subprocess
32import tempfile
43from pathlib import Path
5- from typing import Optional
64
75import typer
86import yaml
7+ from tqdm import tqdm
8+
99from pypsa_eur .cli_helpers import (
1010 check_in_project_root ,
1111 comma_separated_list ,
1212 generate_job_id ,
1313 recursive_merge ,
1414)
1515from pypsa_eur .progress_tracker import ProgressTracker
16- from snakemake .utils import validate
17- from tqdm import tqdm
1816
1917app = typer .Typer (
2018 help = "PyPSA-Eur CLI: Command Line Interface for European Power System Analysis" ,
2422
2523@app .command (name = "run" )
2624def run (
27- name : str = typer .Option (
28- None ,
29- "--name" ,
30- "-n" ,
31- help = "Name for this run (will be used as job ID)." ,
32- ),
33- configfile : Path = typer .Option (
34- None ,
35- "--configfile" ,
36- "-c" ,
37- help = "Path to configuration file (default: config/config.default.yaml)." ,
38- ),
39- verbose : bool = typer .Option (
40- False ,
41- "--verbose" ,
42- "-v" ,
43- help = "Show live Snakemake output during workflow execution." ,
44- ),
45- cores : int = typer .Option (
46- None ,
47- "--cores" ,
48- help = "Number of cores to use for Snakemake. If not specified, all available cores will be used." ,
49- ),
50- snapshots : str = typer .Option (
51- None ,
52- "--snapshots" ,
53- "-s" ,
54- help = "Override snapshots configuration (format: 'start,end' e.g., '2013-01-01,2014-01-01')." ,
55- ),
56- planning_horizons : str = typer .Option (
57- None ,
58- "--planning-horizons" ,
59- help = "Override planning horizons as comma-separated list (e.g., 2030,2040,2050)." ,
60- ),
61- clusters : str = typer .Option (
62- None ,
63- "--clusters" ,
64- help = "Override network clusters as comma-separated list (e.g., 39,128,256)." ,
65- ),
66- opts : str = typer .Option (
67- None ,
68- "--opts" ,
69- help = "Override opts configuration as comma-separated list." ,
70- ),
71- sector_opts : str = typer .Option (
72- None ,
73- "--sector-opts" ,
74- help = "Override sector_opts configuration as comma-separated list." ,
75- ),
76- foresight : str = typer .Option (
77- None ,
78- "--foresight" ,
79- help = "Override foresight configuration (overnight, myopic, or perfect)." ,
80- ),
81- countries : str = typer .Option (
82- None ,
83- "--countries" ,
84- help = "Override countries configuration as comma-separated list (e.g., DE,FR,ES)." ,
85- ),
25+ name : str = typer .Option (
26+ None ,
27+ "--name" ,
28+ "-n" ,
29+ help = "Name for this run (will be used as job ID)." ,
30+ ),
31+ configfile : Path = typer .Option (
32+ None ,
33+ "--configfile" ,
34+ "-c" ,
35+ help = "Path to configuration file (default: config/config.default.yaml)." ,
36+ ),
37+ verbose : bool = typer .Option (
38+ False ,
39+ "--verbose" ,
40+ "-v" ,
41+ help = "Show live Snakemake output during workflow execution." ,
42+ ),
43+ cores : int = typer .Option (
44+ None ,
45+ "--cores" ,
46+ help = "Number of cores to use for Snakemake. If not specified, all available cores will be used." ,
47+ ),
48+ snapshots : str = typer .Option (
49+ None ,
50+ "--snapshots" ,
51+ "-s" ,
52+ help = "Override snapshots configuration (format: 'start,end' e.g., '2013-01-01,2014-01-01')." ,
53+ ),
54+ planning_horizons : str = typer .Option (
55+ None ,
56+ "--planning-horizons" ,
57+ help = "Override planning horizons as comma-separated list (e.g., 2030,2040,2050)." ,
58+ ),
59+ clusters : str = typer .Option (
60+ None ,
61+ "--clusters" ,
62+ help = "Override network clusters as comma-separated list (e.g., 39,128,256)." ,
63+ ),
64+ opts : str = typer .Option (
65+ None ,
66+ "--opts" ,
67+ help = "Override opts configuration as comma-separated list." ,
68+ ),
69+ sector_opts : str = typer .Option (
70+ None ,
71+ "--sector-opts" ,
72+ help = "Override sector_opts configuration as comma-separated list." ,
73+ ),
74+ foresight : str = typer .Option (
75+ None ,
76+ "--foresight" ,
77+ help = "Override foresight configuration (overnight, myopic, or perfect)." ,
78+ ),
79+ countries : str = typer .Option (
80+ None ,
81+ "--countries" ,
82+ help = "Override countries configuration as comma-separated list (e.g., DE,FR,ES)." ,
83+ ),
8684):
8785 """
8886 Run the PyPSA-Eur workflow with specified configuration.
@@ -106,11 +104,9 @@ def run(
106104 "retrieve_ship_raster" : "Retrieving shipping raster data" ,
107105 "retrieve_databundle" : "Retrieving data bundle" ,
108106 "retrieve_egrigcs3_pm_production" : "Retrieving EGRIGCS3 power production data" ,
109-
110107 # Shape and geography building
111108 "build_shapes" : "Building geographical shapes" ,
112109 "build_ship_raster" : "Building shipping density raster" ,
113-
114110 # Network building and preparation
115111 "base_network" : "Building base network structure" ,
116112 "build_osm_network" : "Building network from OpenStreetMap data" ,
@@ -120,15 +116,13 @@ def run(
120116 "cluster_network" : "Clustering network nodes" ,
121117 "add_transmission_projects_and_dlr" : "Adding transmission projects and dynamic line rating" ,
122118 "build_transmission_projects" : "Building transmission projects" ,
123-
124119 # Electricity system components
125120 "build_electricity_demand" : "Building electricity demand time series" ,
126121 "build_electricity_demand_base" : "Building base electricity demand" ,
127122 "build_powerplants" : "Building power plant database" ,
128123 "build_line_rating" : "Building dynamic line ratings" ,
129124 "add_electricity" : "Adding electrical parameters" ,
130125 "prepare_network" : "Preparing network for optimization" ,
131-
132126 # Renewable energy
133127 "build_renewable_profiles" : "Building renewable generation profiles" ,
134128 "determine_availability_matrix" : "Determining renewable availability matrix" ,
@@ -137,13 +131,11 @@ def run(
137131 "build_temperature_profiles" : "Building temperature profiles" ,
138132 "build_cop_profiles" : "Building heat pump COP profiles" ,
139133 "build_solar_thermal_profiles" : "Building solar thermal profiles" ,
140-
141134 # Solving and optimization
142135 "solve_network" : "Solving network optimization" ,
143136 "solve_operations_network" : "Solving operational dispatch" ,
144137 "solve_elec_networks" : "Solving electricity network" ,
145138 "solve_sector_network" : "Solving sector-coupled network" ,
146-
147139 # Sector coupling
148140 "prepare_sector_network" : "Preparing sector-coupled network" ,
149141 "build_industrial_demand" : "Building industrial demand" ,
@@ -153,13 +145,11 @@ def run(
153145 "build_industry_sector" : "Building industry sector model" ,
154146 "build_heating_sector" : "Building heating sector model" ,
155147 "build_transport_sector" : "Building transport sector model" ,
156-
157148 # Post-processing and validation
158149 "make_summary" : "Creating results summary" ,
159150 "plot_network" : "Plotting network" ,
160151 "plot_summary" : "Plotting summary statistics" ,
161152 "validate_network" : "Validating network consistency" ,
162-
163153 # Other rules
164154 "copy_config" : "Copying configuration" ,
165155 "build_cutout" : "Building weather cutout" ,
@@ -221,7 +211,9 @@ def run(
221211 config_data .setdefault ("costs" , {})["year" ] = ph_list [0 ]
222212
223213 if clusters :
224- config_data .setdefault ("scenario" , {})["clusters" ] = comma_separated_list (clusters )
214+ config_data .setdefault ("scenario" , {})["clusters" ] = comma_separated_list (
215+ clusters
216+ )
225217
226218 if opts :
227219 config_data .setdefault ("scenario" , {})["opts" ] = comma_separated_list (opts )
@@ -444,4 +436,4 @@ def callback():
444436
445437
446438if __name__ == "__main__" :
447- app ()
439+ app ()
0 commit comments