Backup config files before solve_network rather than after

For debugging cases where solving failed.
This commit is contained in:
Tom Brown 2019-07-20 10:55:23 +02:00
parent 232425ac61
commit 32af25df62
2 changed files with 7 additions and 6 deletions

View File

@ -208,7 +208,9 @@ rule prepare_sector_network:
rule solve_network:
input: config['results_dir'] + config['run'] + "/prenetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}.nc"
input:
network=config['results_dir'] + config['run'] + "/prenetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}.nc",
config=config['summary_dir'] + '/' + config['run'] + '/configs/config.yaml'
output: config['results_dir'] + config['run'] + "/postnetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}.nc"
shadow: "shallow"
log:
@ -235,7 +237,7 @@ rule plot_network:
rule copy_config:
input:
networks=expand(config['results_dir'] + config['run'] + "/postnetworks/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}.nc",
networks=expand(config['results_dir'] + config['run'] + "/prenetworks/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}.nc",
**config['scenario'])
output:
config=config['summary_dir'] + '/' + config['run'] + '/configs/config.yaml'
@ -250,8 +252,7 @@ rule make_summary:
networks=expand(config['results_dir'] + config['run'] + "/postnetworks/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}.nc",
**config['scenario']),
plots=expand(config['results_dir'] + config['run'] + "/maps/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}-costs-all.pdf",
**config['scenario']),
config=config['summary_dir'] + '/' + config['run'] + '/configs/config.yaml'
**config['scenario'])
#heat_demand_name='data/heating/daily_heat_demand.h5'
output:
nodal_costs=config['summary_dir'] + '/' + config['run'] + '/csvs/nodal_costs.csv',

View File

@ -352,7 +352,7 @@ if __name__ == "__main__":
from vresutils.snakemake import MockSnakemake, Dict
snakemake = MockSnakemake(
wildcards=dict(network='elec', simpl='', clusters='45', lv='1.25', opts='Co2L-3H-T-H'),
input=["networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc"],
input=dict(network="networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc"),
output=["results/networks/s{simpl}_{clusters}_lv{lv}_{opts}-test.nc"],
log=dict(gurobi="logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_gurobi-test.log",
python="logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_python-test.log")
@ -367,7 +367,7 @@ if __name__ == "__main__":
level=snakemake.config['logging_level'])
with memory_logger(filename=getattr(snakemake.log, 'memory', None), interval=30.) as mem:
n = pypsa.Network(snakemake.input[0],
n = pypsa.Network(snakemake.input.network,
override_component_attrs=override_component_attrs)
n = prepare_network(n)