use default config as base configuration

This commit is contained in:
Fabian Neumann 2024-02-12 12:10:05 +01:00
parent e8c8d72b3f
commit fe143ff8fe
6 changed files with 21 additions and 19 deletions

View File

@ -2,8 +2,8 @@
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
from os.path import normpath, exists from os.path import normpath
from shutil import copyfile, move, rmtree from shutil import move, rmtree
from snakemake.remote.HTTP import RemoteProvider as HTTPRemoteProvider from snakemake.remote.HTTP import RemoteProvider as HTTPRemoteProvider
@ -13,12 +13,7 @@ from snakemake.utils import min_version
min_version("7.7") min_version("7.7")
conf_file = os.path.join(workflow.current_basedir, "config/config.yaml") configfile: "config/config.default.yaml"
conf_default_file = os.path.join(workflow.current_basedir, "config/config.default.yaml")
if not exists(conf_file) and exists(conf_default_file):
copyfile(conf_default_file, conf_file)
configfile: "config/config.yaml" configfile: "config/config.yaml"

7
config/config.yaml Normal file
View File

@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: : 2024 The PyPSA-Eur Authors
#
# SPDX-License-Identifier: CC0-1.0
# add your own configuration overrides here, for instance
# enable:
# retrieve: false

View File

@ -9,7 +9,7 @@
Configuration Configuration
########################################## ##########################################
PyPSA-Eur has several configuration options which are documented in this section and are collected in a ``config/config.yaml`` file located in the root directory. Users should copy the provided default configuration (``config/config.default.yaml``) and amend their own modifications and assumptions in the user-specific configuration file (``config/config.yaml``); confer installation instructions at :ref:`defaultconfig`. PyPSA-Eur has several configuration options which are documented in this section and are collected in a ``config/config.yaml`` file. This file defines deviations from the default configuration (``config/config.default.yaml``); confer installation instructions at :ref:`defaultconfig`.
.. _toplevel_cf: .. _toplevel_cf:

View File

@ -118,11 +118,10 @@ Nevertheless, you can still use open-source solvers for smaller problems.
Handling Configuration Files Handling Configuration Files
============================ ============================
PyPSA-Eur has several configuration options that must be specified in a PyPSA-Eur has several configuration options that users can specify in a
``config/config.yaml`` file located in the root directory. An example configuration ``config/config.yaml`` file. The default configuration
``config/config.default.yaml`` is maintained in the repository, which will be used to ``config/config.default.yaml`` is maintained in the repository. More details on
automatically create your customisable ``config/config.yaml`` on first use. More the configuration options are in :ref:`config`.
details on the configuration options are in :ref:`config`.
You can also use ``snakemake`` to specify another file, e.g. You can also use ``snakemake`` to specify another file, e.g.
``config/config.mymodifications.yaml``, to update the settings of the ``config/config.yaml``. ``config/config.mymodifications.yaml``, to update the settings of the ``config/config.yaml``.
@ -131,7 +130,3 @@ You can also use ``snakemake`` to specify another file, e.g.
.../pypsa-eur % snakemake -call --configfile config/config.mymodifications.yaml .../pypsa-eur % snakemake -call --configfile config/config.mymodifications.yaml
.. warning::
Users are advised to regularly check their own ``config/config.yaml`` against changes
in the ``config/config.default.yaml`` when pulling a new version from the remote
repository.

View File

@ -74,7 +74,7 @@ what data to retrieve and what files to produce. Details are explained in
:ref:`wildcards` and :ref:`scenario`. :ref:`wildcards` and :ref:`scenario`.
The model also has several further configuration options collected in the The model also has several further configuration options collected in the
``config/config.yaml`` file located in the root directory, which that are not part of ``config/config.default.yaml`` file located in the root directory, which that are not part of
the scenarios. Options are explained in :ref:`config`. the scenarios. Options are explained in :ref:`config`.
Folder Structure Folder Structure

View File

@ -10,6 +10,11 @@ Release Notes
Upcoming Release Upcoming Release
================ ================
* The default configuration ``config/config.default.yaml`` is now automatically
used as a base configuration file and no longer copied to
``config/config.yaml`` on first use. The file ``config/config.yaml`` should be
used to define deviations from the default configuration.
* Merged two OPSD time series data versions into such that the option ``load: * Merged two OPSD time series data versions into such that the option ``load:
power_statistics:`` becomes superfluous and was hence removed. power_statistics:`` becomes superfluous and was hence removed.