Skip to content

Fix/simplify dependencies #32

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

Merged
merged 8 commits into from
Aug 15, 2024
Merged
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
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

26 changes: 9 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,29 @@ on:
branches: [ "main", "develop" ]

jobs:

quality_assurance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: pip install black flake8 isort
- run: isort --check .
- run: black --check .
- run: flake8 .

- run: pip install ruff
- run: ruff check

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: pip install -r docs/requirements.txt
- run: mkdocs build

setup_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: mamba-org/setup-micromamba@v1
with:
activate-environment: test
environment-file: environment.yml
auto-activate-base: false
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
- name: install hat package
shell: bash -l {0}
run: pip install .
run: pip install .[test]
- name: run tests
shell: bash -l {0}
run: |
pip install pytest
pytest
run: pytest
39 changes: 20 additions & 19 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,41 @@ jobs:
name: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
- run: python -m pip install .
- name: install hat package
shell: bash -l {0}
run: pip install .

test:
name: test
runs-on: ubuntu-latest
needs: [setup]
steps:
- uses: actions/checkout@v2
- uses: mamba-org/setup-micromamba@v1
with:
activate-environment: test
environment-file: environment.yml
auto-activate-base: false
- name: install hat package
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
- name: developer install of hat package
shell: bash -l {0}
run: pip install .
run: pip install .[test]
- name: run tests
shell: bash -l {0}
run: |
pip install pytest
pytest
run: pytest

distribution:
name: distribution
runs-on: ubuntu-latest
needs: [setup, test]

needs: [setup]
steps:
- uses: actions/checkout@v3
- name: Build distributions
- uses: actions/setup-python@v2
- name: install hat package
shell: bash -l {0}
run: pip install .
- name: build distributions
run: |
$CONDA/bin/python -m pip install build
$CONDA/bin/python -m build
- name: Publish a Python distribution to PyPI
pip install build
python build
- name: publish a Python distribution to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
42 changes: 30 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
default_language_version:
python: python3
default_stages:
- commit
- push
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
# - repo: https://github.com/PyCQA/flake8
# rev: 6.0.0
# hooks:
# - id: flake8
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.5.6
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: detect-private-key
- id: check-ast
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
- id: check-case-conflict
- repo: local
hooks:
- id: forbid-to-commit
name: Don't commit rej files
entry: |
Cannot commit .rej files. These indicate merge conflicts that arise during automated template updates.
Fix the merge conflicts manually and remove the .rej files.
language: fail
files: '.*\.rej$'
49 changes: 38 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# HAT - Hydrological Analysis Toolkit

HAT is a suite of tools to perform data analysis on hydrological datasets.
The Hydrological Analysis Toolkit (HAT) is a software suite for hydrologists working with simulated and observed river discharge. HAT performs data analysis on hydrological datasets, with its main features being:
- mapping station locations into hydrological model grids
- extraction of timeseries
- statistical analysis of hydrological timeseries

The documentation can be found at https://hydro-analysis-toolkit.readthedocs.io


**DISCLAIMER**
This project is **BETA** and will be **Experimental** for the foreseeable future.
Interfaces and functionality are likely to change, and the project itself may be scrapped.
Expand All @@ -15,28 +17,53 @@ Interfaces and functionality are likely to change, and the project itself may be
Clone source code repository

$ git clone https://github.com/ecmwf/hat.git
$ cd hat

Create conda python environment
Create and activate conda environment

$ conda env create -n hat python=3.10
$ conda activate hat

For default installation, run

$ cd hat
$ conda env create -f environment.yml
$ pip install .

### Usage
For a developer installation (includes linting and test libraries), run

Start a hat environment
$ pip install .[dev]
$ pre-commit install

If you only plan to run the tests, instead run

$ pip install .[test]

If you plan to build a source and a wheel distribution, it is additionally required to run

$ pip install build

### Usage

$ conda activate hat

Run a command line tool

$ hat-extract-timeseries --help

### Running the tests

Tests are stored in the `tests/` folder and can be run with

$ pytest

### Deployment

To build a source and a wheel distribution, run

$ python build

### Contributing

The main repository is hosted on [GitHub](https://github.com/ecmwf/hat), testing, bug reports and contributions are highly welcomed and appreciated.
The main repository is hosted on [GitHub](https://github.com/ecmwf/hat). Testing, bug reports and contributions are highly welcomed and appreciated.

Please report [bug](https://github.com/ecmwf/hat/issues) reports or [pull-requests](https://github.com/ecmwf/hat/pulls) on [GitHub](https://github.com/ecmwf/hat)
Please report [bug](https://github.com/ecmwf/hat/issues) reports or [pull-requests](https://github.com/ecmwf/hat/pulls) on [GitHub](https://github.com/ecmwf/hat).

We want your feedback, please e-mail: [email protected]

Expand Down
5 changes: 4 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Welcome to HAT

Hydrological Analysis Tools (HAT) is a suite of software for hydrologists working with simulated and observed river discharge.
The Hydrological Analysis Toolkit (HAT) is a software suite for hydrologists working with simulated and observed river discharge. HAT performs data analysis on hydrological datasets, with its main features being:
- mapping station locations into hydrological model grids
- extraction of timeseries
- statistical analysis of hydrological timeseries
12 changes: 4 additions & 8 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

Clone source code repository

git clone [email protected]:ecmwf-projects/hat.git
git clone https://github.com/ecmwf/hat.git
cd hat

Create conda python environment

cd hat

# If on HPC..
# module load conda

conda env create -f environment.yml
conda env create -n hat python=3.10
conda activate hat

Install HAT software
Installation of required dependencies

pip install .

Open a new terminal to start
3 changes: 1 addition & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

If you have already [installed](installation.md) hat then

#### Activate environment
#### Activate Environment

$ conda activate hat

Expand All @@ -21,4 +21,3 @@ In your python code you can import the hat module
import hat

For examples, please see these [jupyter notebooks](https://github.com/ecmwf-projects/hat/tree/main/notebooks)

29 changes: 0 additions & 29 deletions environment.yml

This file was deleted.

4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
site_name: Hydrological Analysis Tools
site_name: Hydrological Analysis Toolkit
site_url: https://ecmwf.github.io/hat/

nav:
Expand All @@ -10,4 +10,4 @@ nav:
- hat-extract-timeseries: hat_extract-timeseries.md
- hat-hydrostats: hat_hydrostats.md

theme: readthedocs
theme: readthedocs
34 changes: 20 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

[build-system]
requires = ["setuptools>=65", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"
Expand Down Expand Up @@ -40,7 +39,12 @@ dependencies = [
"ipyleaflet",
"ipywidgets",
"earthkit-data",
"cfgrib"
"cfgrib",
"netCDF4",
"eccodes",
"plotly",
"jupyter",
"geopy"
]

[project.urls]
Expand All @@ -50,25 +54,27 @@ dependencies = [

[project.optional-dependencies]
test = [
"pytest",
"pytest"
]
docs = [
"mkdocs",
"mkdocs-material",
"mkdocstrings-python",
"mkdocs-autorefs",
"mkdocs-gen-files",
"pymdown-extensions",
"markdown-exec[ansi]",
dev = [
"pytest",
"ruff",
"pre-commit"
]

[project.scripts]
hat-extract-timeseries = "hat.tools.extract_simulation_timeseries_cli:main"
hat-hydrostats = "hat.tools.hydrostats_cli:main"
hat-stations-mapping = "hat.mapping.station_mapping:main"

[tool.isort]
profile="black"
# Linting settings
[tool.ruff]
line-length = 120
indent-width = 4

[tool.ruff.format]
quote-style = "double"
indent-style = "space"

# Testing
[tool.pytest]
Expand Down Expand Up @@ -98,4 +104,4 @@ write_to_template = '''
__version__ = "{version}"
'''
parentdir_prefix_version='hat-' # get version from GitHub-like tarballs
fallback_version='0.7.1'
fallback_version='0.7.1'
Loading