2023-03-06 08:27:45 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2023-03-06 17:49:23 +00:00
|
|
|
# SPDX-FileCopyrightText: : 2020-2023 The PyPSA-Eur Authors
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
2023-03-09 11:45:43 +00:00
|
|
|
"""
|
|
|
|
Copy used configuration files and important scripts for archiving.
|
|
|
|
"""
|
|
|
|
|
2023-03-06 15:52:25 +00:00
|
|
|
from pathlib import Path
|
2023-03-06 15:54:35 +00:00
|
|
|
from shutil import copy
|
2023-03-06 08:27:45 +00:00
|
|
|
|
2022-04-12 13:16:05 +00:00
|
|
|
import yaml
|
2019-05-16 07:39:03 +00:00
|
|
|
|
2021-11-24 09:54:39 +00:00
|
|
|
files = {
|
2023-04-21 09:05:18 +00:00
|
|
|
"config/config.yaml": "config.yaml",
|
2021-11-24 09:54:39 +00:00
|
|
|
"Snakefile": "Snakefile",
|
|
|
|
"scripts/solve_network.py": "solve_network.py",
|
|
|
|
"scripts/prepare_sector_network.py": "prepare_sector_network.py",
|
|
|
|
}
|
2019-05-16 07:39:03 +00:00
|
|
|
|
2023-03-06 08:27:45 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
if "snakemake" not in globals():
|
2023-03-06 18:09:45 +00:00
|
|
|
from _helpers import mock_snakemake
|
2021-07-01 18:09:04 +00:00
|
|
|
|
2023-03-06 08:27:45 +00:00
|
|
|
snakemake = mock_snakemake("copy_config")
|
|
|
|
|
2023-04-21 09:05:18 +00:00
|
|
|
basepath = Path(f"results/{snakemake.params.RDIR}config/")
|
2022-04-12 13:16:05 +00:00
|
|
|
|
2021-11-24 09:54:39 +00:00
|
|
|
for f, name in files.items():
|
2023-03-06 15:52:25 +00:00
|
|
|
copy(f, basepath / name)
|
2022-04-12 13:16:05 +00:00
|
|
|
|
2023-03-06 15:52:25 +00:00
|
|
|
with open(basepath / "config.snakemake.yaml", "w") as yaml_file:
|
2022-04-12 13:16:05 +00:00
|
|
|
yaml.dump(
|
|
|
|
snakemake.config,
|
|
|
|
yaml_file,
|
|
|
|
default_flow_style=False,
|
|
|
|
allow_unicode=True,
|
2023-03-06 08:27:45 +00:00
|
|
|
sort_keys=False,
|
|
|
|
)
|