Skip to content

Commit

Permalink
Add pre-commit hooks and fix their issues (#387)
Browse files Browse the repository at this point in the history
* add pixi.toml file

* remove pixi part from pyproject.toml

* revert changes to pyproject.ml

* add pre-commit hooks and fix all issues

* fix import mistake
  • Loading branch information
savente93 authored Oct 3, 2024
1 parent 856f98d commit f6932b3
Show file tree
Hide file tree
Showing 81 changed files with 1,293 additions and 743 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bug Report
description: Report incorrect behavior
description: Report incorrect behavior
labels: [bug, needs refinement]

body:
Expand Down Expand Up @@ -43,7 +43,7 @@ body:
id: task-list
attributes:
description: >
Please provide a list of tasks that need to be completed before this issue can be closed.
Please provide a list of tasks that need to be completed before this issue can be closed.
label: Task list
validations:
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ body:
id: task-list
attributes:
description: >
Please provide a list of tasks that need to be completed before this issue can be closed.
Please provide a list of tasks that need to be completed before this issue can be closed.
label: Task list
validations:
required: true
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with uploading to pypi automatically
# https://packaging.python.org/tutorials/packaging-projects/
#
#
# Before running this workflow in your repository, you will need to set up Secrets in your repository settings:
# - Log in to your (test)PyPI account, go to your account -> your_project -> Publishing
# - Fill in the required fields
Expand Down Expand Up @@ -36,13 +36,13 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@v2
name: Setup Miniconda
with:
auto-update-conda: true
python-version: ${{ env.PYTHON_VERSION }}

- name: Install GDAL
shell: bash -l {0}
run: conda install -c conda-forge gdal
Expand All @@ -51,7 +51,7 @@ jobs:
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install .
python -m pip install build
- name: Build package
Expand Down Expand Up @@ -80,13 +80,13 @@ jobs:
run: |
ls -ltrh
ls -ltrh dist
- uses: conda-incubator/setup-miniconda@v2
name: Setup Miniconda
with:
auto-update-conda: true
python-version: ${{ env.PYTHON_VERSION }}

- name: Install GDAL
shell: bash -l {0}
run: conda install -c conda-forge gdal
Expand All @@ -95,7 +95,7 @@ jobs:
run: |
python -m pip install dist/*.whl
python -c "import ${{ env.PACKAGE_NAME }}; print(${{ env.PACKAGE_NAME }}.__version__)"
upload-to-test-pypi:
environment: release
Expand Down
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: debug-statements
- id: mixed-line-ending
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ HydroMT-FIAT: HydroMT plugin for Delft-FIAT

HydroMT_ is a python package, developed by Deltares, to build and analyze hydro models.
It provides a generic model api with attributes to access the model schematization,
(dynamic) forcing data, results and states. This plugin provides an implementation
(dynamic) forcing data, results and states. This plugin provides an implementation
for the Delft-FIAT_ model.


Expand All @@ -40,7 +40,7 @@ for the Delft-FIAT_ model.
.. .. code-block:: console
.. pip install hydromt_fiat
.. pip install hydromt_fiat
Installation as a User
------------
Expand All @@ -54,32 +54,32 @@ To create a new environment follow the steps below.
1. Create a new environment:

.. code-block:: console
conda create -n hydromt_fiat python=3.11.*
2. Activate the environment:

.. code-block:: console
conda activate hydromt_fiat
3. Install conda-forge gdal.

.. code-block:: console
conda install -c conda-forge gdal
4. Install Hydromt-FIAT from Github. After creating the new environment, you need to install all dependencies from the Deltares Github repository. You can use **pip install** to do so:

.. code-block:: console
pip install git+https://github.com/Deltares/hydromt_fiat.git
Existing environment
If you want to install FIAT into an existing environment, simply activate the desired environment and run:

.. code-block:: console
pip install git+https://github.com/Deltares/hydromt_fiat.git
Expand Down
1 change: 0 additions & 1 deletion binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ dependencies:
- pip:
- us
- census

2 changes: 1 addition & 1 deletion binder/postBuild
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

set -ex
flit install --dep production
flit install --dep production
2 changes: 1 addition & 1 deletion docs/_static/fiat_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/api/api_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ General methods

fiat.FiatModel.set_geoms
fiat.FiatModel.read_geoms
fiat.FiatModel.write_geoms
fiat.FiatModel.write_geoms
4 changes: 2 additions & 2 deletions docs/data/data_sources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
======================
Data Sources
======================
With the HydroMT-FIAT package you can easily access exposure and vulnerability data from different sources.
With the HydroMT-FIAT package you can easily access exposure and vulnerability data from different sources.
The following data sources are currently supported:


Expand All @@ -21,4 +21,4 @@ The following data sources are currently supported:
national_structure_inventory
openstreetmap
jrc
hazus
hazus
13 changes: 6 additions & 7 deletions docs/data/hazus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
HAZUS flood depth-damage functions
===============================================

Users of **HydroMT-FIAT** can directly and easily make use of the depth-damage
functions and repair values from `HAZUS
<https://www.fema.gov/flood-maps/products-tools/hazus>`_. Hazus is a US-based
program and the depth-damage functions are based on US data. The functions and
values can be used only together with the `hydromt_fiat_catalog_USA.yml` and
Users of **HydroMT-FIAT** can directly and easily make use of the depth-damage
functions and repair values from `HAZUS
<https://www.fema.gov/flood-maps/products-tools/hazus>`_. Hazus is a US-based
program and the depth-damage functions are based on US data. The functions and
values can be used only together with the `hydromt_fiat_catalog_USA.yml` and
by providing the following values in the configuration file::

[setup_vulnerability]
Expand All @@ -21,6 +21,5 @@ by providing the following values in the configuration file::
unit = "m"


The HAZUS flood depth-damage functions and replacement values are processed into an easy-to-use format
The HAZUS flood depth-damage functions and replacement values are processed into an easy-to-use format
for HydroMT-FIAT and stored in the ``hydromt_fiat/data`` folder.

14 changes: 7 additions & 7 deletions docs/data/jrc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
JRC Global flood depth-damage functions
===============================================

Users of **HydroMT-FIAT** can directly and easily make use of the `JRC Global flood depth-damage functions and
replacement values <https://publications.jrc.ec.europa.eu/repository/handle/JRC105688>`_ [1]. The functions and
values can be used only together with the `hydromt_fiat_catalog_global.yml` and
Users of **HydroMT-FIAT** can directly and easily make use of the `JRC Global flood depth-damage functions and
replacement values <https://publications.jrc.ec.europa.eu/repository/handle/JRC105688>`_ [1]. The functions and
values can be used only together with the `hydromt_fiat_catalog_global.yml` and
by providing the following values in the configuration file::

[setup_vulnerability]
Expand All @@ -19,10 +19,10 @@ by providing the following values in the configuration file::
unit = "m"


The JRC Global flood depth-damage functions and replacement values are processed into an easy-to-use format
The JRC Global flood depth-damage functions and replacement values are processed into an easy-to-use format
for HydroMT-FIAT and stored in the ``hydromt_fiat/data`` folder.


[1] Huizinga, J., De Moel, H. and Szewczyk, W., Global flood depth-damage functions: Methodology
and the database with guidelines, EUR 28552 EN, Publications Office of the European Union, Luxembourg,
2017, ISBN 978-92-79-67781-6, doi:10.2760/16510, JRC105688.
[1] Huizinga, J., De Moel, H. and Szewczyk, W., Global flood depth-damage functions: Methodology
and the database with guidelines, EUR 28552 EN, Publications Office of the European Union, Luxembourg,
2017, ISBN 978-92-79-67781-6, doi:10.2760/16510, JRC105688.
10 changes: 5 additions & 5 deletions docs/data/national_structure_inventory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
National Structure Inventory (USA)
==================================

For projects in the United States, users of **HydroMT-FIAT** can directly and easily make use
of the `National Structure Inventory <https://www.hec.usace.army.mil/confluence/nsi>`_ (NSI). The
For projects in the United States, users of **HydroMT-FIAT** can directly and easily make use
of the `National Structure Inventory <https://www.hec.usace.army.mil/confluence/nsi>`_ (NSI). The
user can access the data through providing 'NSI' in the configuration file as such::

[setup_exposure_buildings]
asset_locations = "NSI"
occupancy_type = "NSI"
max_potential_damage = "NSI"

The following attributes for Delft-FIAT (left-hand side) will be filled with data from the
The following attributes for Delft-FIAT (left-hand side) will be filled with data from the
corresponding NSI fields (right-hand side)::

"Object ID": "fd_id",
Expand All @@ -27,8 +27,8 @@ corresponding NSI fields (right-hand side)::
"Y Coordinate": "y",
"Aggregation Label: Census Block": "cbfips"

HydroMT-FIAT obtains the NSI data of the area of interest through the `NSI API
HydroMT-FIAT obtains the NSI data of the area of interest through the `NSI API
<https://www.hec.usace.army.mil/confluence/nsi/technicalreferences/latest/api-reference-guide>`_.

For more information about this data we refer to their online `Technical Documentation
For more information about this data we refer to their online `Technical Documentation
<https://www.hec.usace.army.mil/confluence/nsi/technicalreferences/latest/technical-documentation>`_.
8 changes: 4 additions & 4 deletions docs/data/openstreetmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
OpenStreetMap Building Footprints and Land Use
===============================================

Users of **HydroMT-FIAT** can directly and easily make use of the `OpenStreetMap <https://www.openstreetmap.org/about>`_
Users of **HydroMT-FIAT** can directly and easily make use of the `OpenStreetMap <https://www.openstreetmap.org/about>`_
(OSM) initiative. The user can access the data through providing 'OSM' in the configuration file as such::

[setup_exposure_buildings]
Expand All @@ -14,6 +14,6 @@ Users of **HydroMT-FIAT** can directly and easily make use of the `OpenStreetMap
HydroMT-FIAT obtains the OSM data of the area of interest through the OSMnx package [1].


[1] Boeing, G. 2017. "`OSMnx: New Methods for Acquiring, Constructing, Analyzing, and Visualizing Complex
Street Networks. <https://geoffboeing.com/publications/osmnx-complex-street-networks/>`_" Computers, Environment
and Urban Systems 65, 126-139.
[1] Boeing, G. 2017. "`OSMnx: New Methods for Acquiring, Constructing, Analyzing, and Visualizing Complex
Street Networks. <https://geoffboeing.com/publications/osmnx-complex-street-networks/>`_" Computers, Environment
and Urban Systems 65, 126-139.
12 changes: 6 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
HydroMT-FIAT: Automated and reproducible Delft-FIAT model building
=====================================================================

With the `HydroMT-FIAT plugin <https://github.com/Deltares/hydromt_fiat>`_, users can easily benefit
from the rich set of tools of the `HydroMT package <https://github.com/Deltares/hydromt>`_ to build and update
With the `HydroMT-FIAT plugin <https://github.com/Deltares/hydromt_fiat>`_, users can easily benefit
from the rich set of tools of the `HydroMT package <https://github.com/Deltares/hydromt>`_ to build and update
`Delft-FIAT <https://github.com/Deltares/Delft-FIAT>`_ models from available global and local data.

This plugin assists the FIAT modeller in:
Expand All @@ -12,7 +12,7 @@ This plugin assists the FIAT modeller in:
- Creating a Social Vulnerability Index (SVI) based on US Census or user-input data.
- Adjusting and updating components of a Delft-FIAT model and their associated parameters in a consistent way.

The HydroMT-FIAT plugin aims to make the FIAT model building process **fast**, **modular**, and **reproducible**
The HydroMT-FIAT plugin aims to make the FIAT model building process **fast**, **modular**, and **reproducible**
by configuring the model building process from single *yml* file.

For detailed information on HydroMT itself, you can visit the `core documentation <https://deltares.github.io/hydromt/>`_.
Expand Down Expand Up @@ -44,18 +44,18 @@ Overview
Contributing
------------

To contribute to HydroMT and the plugin plugin, please follow the
To contribute to HydroMT and the plugin plugin, please follow the
`HydroMT contribution guidelines <https://deltares.github.io/hydromt/latest/contributing.html>`_.

License
-------

Copyright (c) 2021, Deltares

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You can find the full terms of the GNU General Public License at <https://www.gnu.org/licenses/>.
Expand Down
10 changes: 5 additions & 5 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ To create a new environment follow the steps below.
1. Create a new environment:

.. code-block:: console
conda create -n hydromt_fiat python=3.11.*
2. Activate the environment:

.. code-block:: console
conda activate hydromt_fiat
3. Install conda-forge gdal.

.. code-block:: console
conda install -c conda-forge gdal
4. Install Hydromt-FIAT from Github. After creating the new environment, you need to install all dependencies from the Deltares Github repository. You can use **pip install** to do so:

.. code-block:: console
pip install git+https://github.com/Deltares/hydromt_fiat.git
Existing environment
If you want to install FIAT into an existing environment, simply activate the desired environment and run:

.. code-block:: console
pip install git+https://github.com/Deltares/hydromt_fiat.git
Expand Down
1 change: 0 additions & 1 deletion docs/user_guide/hazard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ Hazard Module
=======================

Coming soon..

1 change: 0 additions & 1 deletion docs/user_guide/social_vulnerability_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ Social Vulnerability Index Module
=================================

Coming soon..

Loading

0 comments on commit f6932b3

Please sign in to comment.