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

Remove binder add codespace #227

Merged
merged 13 commits into from
Jul 11, 2024
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ "name": "Hydropandas",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
"updateContentCommand": "chmod u+x .devcontainer/setup.sh && .devcontainer/setup.sh && chmod 666 .devcontainer/setup.sh",
"postAttachCommand": "code examples/01_groundwater_observations.ipynb", //alternative for customizations openFile -> https://github.com/orgs/community/discussions/58399#discussioncomment-6222762
"customizations": {
"vscode": {
"extensions": [
"github.codespaces",
"ms-python.python",
"ms-toolsai.jupyter"
]
}
}
}
4 changes: 4 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# Create model environments
pip install -e .
26 changes: 5 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,25 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- name: Test suite with py312-ubuntu
python: "3.12"
os: ubuntu-latest
toxenv: py312
- name: Test suite with py311-ubuntu
python: "3.11"
os: ubuntu-latest
toxenv: py311
- name: Test suite with py310-ubuntu
python: "3.10"
os: ubuntu-latest
toxenv: py310
- name: Formatting with black + isort
python: "3.9"
os: ubuntu-latest
toxenv: format
- name: Linting with flake8 + ruff
python: "3.9"
os: ubuntu-latest
toxenv: lint
- name: Formatting and linting with ruff
python: "3.11"
toxenv: ruff
- name: Test suite for notebooks and coverage
python: "3.9"
os: ubuntu-latest
toxenv: notebooks

name: ${{ matrix.name }}
Expand Down Expand Up @@ -68,11 +59,4 @@ jobs:
run: tox -e ${{ matrix.toxenv }} --notest

- name: Test
run: tox -e ${{ matrix.toxenv }} --skip-pkg-install

- name: Run codacy-coverage-reporter
if: ${{ matrix.toxenv == 'notebooks' && github.repository == 'ArtesiaWater/hydropandas' && success() }}
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
run: tox -e ${{ matrix.toxenv }} --skip-pkg-install
15 changes: 13 additions & 2 deletions hydropandas/io/bro.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import json
import logging
import xml.etree.ElementTree
from functools import lru_cache

import numpy as np
import pandas as pd
import requests
from functools import lru_cache
from pyproj import Proj, Transformer
from tqdm import tqdm

Expand Down Expand Up @@ -424,7 +424,7 @@ def get_full_metadata_from_gmw(bro_id, tube_nr):


@lru_cache()
def _get_gmw_from_bro_id(bro_id):
def _get_gmw_from_bro_id(bro_id, retries=0):
"""get a gmw object from a bro_id

Parameters
Expand Down Expand Up @@ -460,6 +460,17 @@ def _get_gmw_from_bro_id(bro_id):

gmws = tree.findall(".//dsgmw:GMW_PO", ns)
if len(gmws) != 1:
val_ind = req.text.find("valid")
valid = req.text[(val_ind + 9) : (val_ind + 14)]
if valid == "false" and retries < 5:
logger.debug(
f"got invalid response for {bro_id}, trying again {retries+1}/4"
)
return _get_gmw_from_bro_id(bro_id, retries=retries + 1)
elif valid == "false":
raise Exception(
f"got invalid response for {bro_id} after trying {retries+1} times"
)
raise (Exception("Only one gmw supported"))
gmw = gmws[0]

Expand Down
2 changes: 1 addition & 1 deletion hydropandas/io/knmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ def get_knmi_daily_meteo_url(stn: int) -> Tuple[pd.DataFrame, Dict[str, Any]]:


def read_knmi_file(
path: Union[str, Path, StringIO]
path: Union[str, Path, StringIO],
) -> Tuple[pd.DataFrame, Dict[str, Any]]:
"""read knmi daily meteo data from a file

Expand Down
1 change: 1 addition & 0 deletions hydropandas/io/pastas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@author: Artesia
"""

import logging
import numbers

Expand Down
2 changes: 1 addition & 1 deletion hydropandas/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import logging
import os
import warnings
from _io import StringIO
from typing import List, Optional

import numpy as np
import pandas as pd
from _io import StringIO
from pandas._config import get_option
from pandas.api.types import is_numeric_dtype
from pandas.io.formats import console
Expand Down
2 changes: 1 addition & 1 deletion hydropandas/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from importlib import metadata
from sys import version as os_version

__version__ = "0.12.1"
__version__ = "0.12.2b"


def show_versions():
Expand Down
30 changes: 14 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ rtd = [
"nbsphinx",
"nbsphinx_link",
]
linting = ["flake8", "ruff"]
formatting = ["black[jupyter]", "isort"]
ruffing = ["ruff"]
pytesting = ["hydropandas[full,rtd]", "pytest>=7", "pytest-cov", "pytest-sugar"]
coveraging = ["coverage"]
dev = ["hydropandas[linting,formatting,pytesting]", "tox"]
dev = ["hydropandas[ruffing,pytesting]", "tox"]

[tool.setuptools]
include-package-data = true
Expand Down Expand Up @@ -99,7 +98,7 @@ markers = ["slow: mark test as slow."]
legacy_tox_ini = """
[tox]
requires = tox>=4
env_list = format, lint, notebooks, py{39, 310, 311, 312}
env_list = ruff, notebooks, py{39, 310, 311, 312}

[testenv]
description = run unit tests
Expand All @@ -114,19 +113,18 @@ legacy_tox_ini = """
coverage run -m pytest tests
coverage xml

[testenv:format]
description = run formatters
basepython = python3.9
extras = formatting
[testenv:ruff]
description = run ruff checks
basepython = python3.11
extras = ruffing
commands =
black . --check --diff
isort . --check-only --diff
ruff check --extend-select I --preview
ruff format --check

[testenv:lint]
description = run linters
basepython = python3.9
extras = linting
[testenv:ruff_fix]
description = run ruff locally and fix issues
extras = ruffing
commands =
flake8 . --max-line-length=88 --ignore=E741,W503
ruff check .
ruff check --extend-select I --fix
ruff format
"""
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

[![PyPi](https://img.shields.io/pypi/v/hydropandas.svg)](https://pypi.python.org/pypi/hydropandas)
[![PyPi Supported Python Versions](https://img.shields.io/pypi/pyversions/hydropandas)](https://pypi.python.org/pypi/hydropandas)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ArtesiaWater/hydropandas/master)
[<img src="https://github.com/codespaces/badge.svg" height="20">](https://codespaces.new/ArtesiaWater/hydropandas?quickstart=1)


[![hydropandas](https://github.com/ArtesiaWater/hydropandas/workflows/hydropandas/badge.svg)](https://github.com/ArtesiaWater/hydropandas/actions?query=workflow%3Ahydropandas)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/c1b99f474bdc49b0a47e00e4e9f66c2f)](https://www.codacy.com/gh/ArtesiaWater/hydropandas/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ArtesiaWater/hydropandas&utm_campaign=Badge_Grade)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_001_to_from.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_bro_gld():

def test_bro_gmn():
# single observation
bro_id = "GMN000000000163"
bro_id = "GMN000000001084" # 34 objecten 2024-7-11
hpd.read_bro(bro_id=bro_id, only_metadata=True)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_005_dino.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ def test_dino_csv_new_style():
def test_dino_csv_duplicate_index():
# contains 1 duplicate index 2019-11-19
fname = "./tests/data/2019-Dino-test/Grondwaterstanden_Put/B22D0155001_1.csv"
measurements, meta = dino.read_dino_groundwater_csv(fname)
measurements, _ = dino.read_dino_groundwater_csv(fname)

# check if measurements contains duplicate indices
assert measurements.index.duplicated().any()

measurements, meta = dino.read_dino_groundwater_csv(
measurements, _ = dino.read_dino_groundwater_csv(
fname, remove_duplicates=True, keep_dup="last"
)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_006_knmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def test_calculate_evaporation():


def test_download_knmi_xy():
df1, meta1 = knmi.get_knmi_obs(meteo_var="RH", stn=344)
df2, meta2 = knmi.get_knmi_obs(meteo_var="RH", xy=(90600, 442800))
df1, _ = knmi.get_knmi_obs(meteo_var="RH", stn=344)
df2, _ = knmi.get_knmi_obs(meteo_var="RH", xy=(90600, 442800))

assert df1.equals(df2), "Dataframes should be identical"

Expand Down
3 changes: 0 additions & 3 deletions tests/test_013_lizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ def test_codes():


def test_many_tubed_well():

oc = hpd.read_lizard(codes="EEWP004", tube_nr="all")
assert not oc.empty


def test_complex_well():

oc = hpd.read_lizard(codes="BUWP014", tube_nr="all")
assert not oc.empty


def test_combine():

hpd.GroundwaterObs.from_lizard("39F-0736", tube_nr=1, type_timeseries="combine")