Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added pre-commit hooks #647

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/asottile/pyupgrade
rev: v3.9.0
hooks:
- id: pyupgrade
42 changes: 31 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ energy storages. Grid expansion measures are not part of this tool and will be
instead part of 'eGo' https://github.com/openego/eGo

.. warning::
From now on eTraGo depends on a sector coupled data-model. This is not published on
From now on eTraGo depends on a sector coupled data-model. This is not published on
the oedb yet, the data has to be created using
`eGon-data <https://github.com/openego/eGon-data>`_.
Not all functions and features are compatible to the sector coupled model yet.
When you want to use eTraGo for optimizations, please use the latest release 0.8.0.

When you want to use eTraGo for optimizations, please use the latest release 0.8.0.


Installation
Expand All @@ -46,7 +46,7 @@ command in order to install eTraGo..

.. code-block:: bash

$ pip3 install eTraGo
$ python -m pip install eTraGo

Installation for Developers
===========================
Expand All @@ -58,32 +58,52 @@ Clone the source code from github:
$ git clone https://github.com/openego/eTraGo

You can checkout to the dev branch and create new feature branches.
For the correct work-flow, please mind the
For the correct work-flow, please mind the
`Dreissen Branching Model <https://nvie.com/posts/a-successful-git-branching-model/>`_

Use the pip -e to install eTraGo directly from the cloned repository:
Use the pip -e to install eTraGo directly from the cloned repository preferably into a
virtual environment:

.. code-block::

$ python -m pip install -e /path/to/eTraGo/

For development purposes make sure to also install the development dependencies by
running:

.. code-block::

$ python -m pip install -e /path/to/eTraGo/[dev]

And setting up the pre-commit hooks:

.. code-block::

$ pre-commit install

If you prefer an anaconda environment feel free to use the supplied YML:

.. code-block::

$ pip3 install -e /path/to/eTraGo/
$ conda env create -f d_py39_eTraGo.yml

When you want to draw geographical features in the background of network plots,
please install cartopy:

.. code-block::

$ pip3 install cartopy
$ python -m pip install cartopy

If you run into problems when using cartopy, try to install shapely without binaries:

.. code-block::

$ pip3 install shapely --no-binary shapely
$ python -m pip install shapely --no-binary shapely

Using a virtual environment
===========================

Before installing eTraGo,
Before installing eTraGo,
you create a virtual environment (where you like it) and activate it:

.. code-block:: bash
Expand All @@ -92,7 +112,7 @@ you create a virtual environment (where you like it) and activate it:
$ source venv/bin/activate
$ cd venv

Inside your activated virtual environment you can
Inside your activated virtual environment you can
install eTraGo with the pip command, as previously explained.


Expand Down
19 changes: 19 additions & 0 deletions d_py39_eTraGo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: d_py39_eTraGo
channels:
- conda-forge
- defaults
dependencies:
- python >= 3.8, < 3.10
- pip
- conda-forge::contextily
- conda-forge::jupyterlab
- conda-forge::fiona
- conda-forge::pandas
- conda-forge::geopandas
- conda-forge::pyproj
- conda-forge::shapely
- conda-forge::rasterio
- conda-forge::geoalchemy2
- conda-forge::pypsa == 0.20.1
- pip:
- -e .[dev]
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


def read(*names, **kwargs):
with io.open(
with open(
join(dirname(__file__), *names),
encoding=kwargs.get("encoding", "utf8"),
) as fh:
Expand Down Expand Up @@ -68,6 +68,7 @@ def read(*names, **kwargs):
"tsam",
],
extras_require={
"dev": ["black", "isort", "jupyterlab", "pre-commit", "pyupgrade"],
"docs": ["sphinx >= 1.4", "sphinx_rtd_theme"],
"gurobipy": ["gurobipy"],
"cartopy": ["cartopy", "requests"],
Expand Down