Skip to content

Commit 382c68c

Browse files
authored
Merge pull request #46 from DataIntegrationGroup/dev/jab
2 parents 0c9a228 + 08a0aeb commit 382c68c

23 files changed

Lines changed: 732 additions & 424 deletions

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pip" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.github/workflows/cicd.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: CI/CD
55

66
on:
77
push:
8-
branches: [ "main", "feature/jir", "dev/jab"]
8+
branches: [ "pre-production", "feature/jir", "dev/jab"]
99
pull_request:
10-
branches: [ "main"]
10+
branches: [ "pre-production"]
1111

1212
permissions:
1313
contents: read
@@ -18,26 +18,39 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
22+
2223
- name: Set up Python 3.10
23-
uses: actions/setup-python@v3
24+
uses: actions/setup-python@v4
2425
with:
2526
python-version: "3.10"
2627
cache: "pip"
28+
29+
- name: Cache pip dependencies
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.cache/pip
33+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
34+
restore-keys: |
35+
${{ runner.os }}-pip-
36+
2737
- name: Install dependencies
2838
run: |
2939
python -m pip install --upgrade pip
3040
pip install flake8 pytest mypy
3141
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
42+
3243
- name: Lint with flake8
3344
run: |
3445
# stop the build if there are Python syntax errors or undefined names
3546
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3647
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3748
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
49+
3850
- name: Type check with mypy
3951
run: |
4052
mypy . --ignore-missing-imports
53+
4154
- name: Test with pytest
4255
run: |
4356
pytest -s -rx tests

.github/workflows/publish-to-pypi.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
33
# pushes only occur on successful pull request merges
44
# this makes it so that the main branch gets published to PyPi, not the
55
# target branch from the pull request (pre-production)
6+
7+
# pushing tags should be the only way to trigger this workflow
68
on:
79
push:
8-
branches:
9-
- main
10+
tags:
11+
- '*'
1012

1113
jobs:
1214
build-and-publish-if-merged:
@@ -20,7 +22,7 @@ jobs:
2022
uses: actions/setup-python@v1
2123
with:
2224
python-version: 3.9
23-
cache: 'pip'
25+
2426
- name: Install pypa/build
2527
run: >-
2628
python -m

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## Unreleased: 0.8.0
7+
## 0.9.2
8+
9+
### Added
10+
- `--sites-only` flag to only retrieve site data
11+
- `--output-format` flag to write out sites/summary tables as csv or geojson.
12+
- options are `csv` or `geojson`
13+
- timeseries data is always written to a csv
14+
- NM OSE POD data for sites.
15+
- can be removed from output with `--no-nmose-pod`
16+
- `--output-dir` to change the output directory to a location other than `.` (the current working directory)
17+
18+
### Changed
19+
- `output` to `output-type` for CLI
20+
21+
### Fixed
22+
- a bug with `--site-limit`. it now exports the number of sets requested by the
23+
24+
## 0.8.0
825

926
### Added
1027
- water level for WQP

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Format code](https://github.com/DataIntegrationGroup/PyWeaver/actions/workflows/format_code.yml/badge.svg?branch=main)](https://github.com/DataIntegrationGroup/PyWeaver/actions/workflows/format_code.yml)
33
[![Publish Python 🐍 distributions 📦 to PyPI and TestPyPI](https://github.com/DataIntegrationGroup/PyWeaver/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/DataIntegrationGroup/PyWeaver/actions/workflows/publish-to-pypi.yml)
44
[![CI/CD](https://github.com/DataIntegrationGroup/PyWeaver/actions/workflows/cicd.yml/badge.svg)](https://github.com/DataIntegrationGroup/PyWeaver/actions/workflows/cicd.yml)
5-
5+
[![Dependabot Updates](https://github.com/DataIntegrationGroup/DataIntegrationEngine/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/DataIntegrationGroup/DataIntegrationEngine/actions/workflows/dependabot/dependabot-updates)
66

77
![NMWDI](https://newmexicowaterdata.org/wp-content/uploads/2023/11/newmexicowaterdatalogoNov2023.png)
88
![NMBGMR](https://waterdata.nmt.edu/static/nmbgmr_logo_resized.png)
@@ -71,22 +71,22 @@ where `{parameter}` is the name of the parameter whose data is to be retrieved,
7171
| **pvacd** | X | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
7272
| **wqp** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
7373

74-
### Output
75-
The `--output` option is required and used to set the output type:
74+
### Output Type
75+
The `--output-type` option is required and used to set the output type:
7676

7777
```
78-
--output summary
78+
--output-type summary
7979
```
8080
- A summary table consisting of location information as well as summary statistics for the parameter of interest for every location that has observations.
8181

8282
```
83-
--output timeseries_unified
83+
--output-type timeseries_unified
8484
```
8585
- A single table consisting of time series data for all locations for the parameter of interest.
8686
- A single table of site data that contains information such as latitude, longitude, and elevation
8787

8888
```
89-
--output timeseries_separated
89+
--output-type timeseries_separated
9090
```
9191
- Separate time series tables for all locations for the parameter of interest.
9292
- A single table of site data that contains information such as latitude, longitude, and elevation
@@ -146,6 +146,7 @@ A log of the inputs and processes, called `die.log`, is also saved to the output
146146
| formation | geologic formation in which the well terminates | string | N |
147147
| aquifer | aquifer from which the well draws water | string | N |
148148
| well_depth | depth of well | float | N |
149+
| well_depth_units | units of well depth. Defaults to ft | string | N |
149150

150151
<sup>**CABQ elevation is calculated as [elevation at top of casing] - [stickup height]; if stickup height < 0 the measuring point is assumed to be beneath the ground surface</sup>
151152

@@ -180,7 +181,7 @@ The Data Integration Engine enables the user to obtain groundwater level and gro
180181
- `--no-pvacd` to exclude Pecos Valley Artesian Convservancy District (PVACD) data
181182
- `--no-wqp` to exclude Water Quality Portal (WQP) data
182183

183-
### Geographic Filters
184+
### Geographic Filters [In Development]
184185

185186
The following flags can be used to geographically filter data:
186187

@@ -192,7 +193,11 @@ The following flags can be used to geographically filter data:
192193
-- bbox 'x1 y1, x2 y2'
193194
```
194195

195-
### Date Filters
196+
```
197+
-- wkt {wkt polygon or multipolygon}
198+
```
199+
200+
### Date Filters [In Development]
196201

197202
The following flags can be used to filter by dates:
198203

@@ -214,12 +219,12 @@ die sources {parameter}
214219

215220
to print the sources that report that parameter to the terminal.
216221

217-
### Wells [In Development]
222+
### Sites
218223

219224
Use
220225

221226
```
222-
die wells
227+
die sites
223228
```
224229

225-
to print wells to the terminal.
230+
to export site information only

backend/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
from enum import Enum
2+
from os import environ
23

34

45
class OutputFormat(str, Enum):
56
GEOJSON = "geojson"
67
CSV = "csv"
7-
GEOSERVER = "geoserver"
8+
GEOSERVER = "geoserver"
9+
10+
11+
def get_bool_env_variable(var: str) -> bool:
12+
env_var = environ.get(var, None)
13+
if env_var is None or env_var.strip().lower() not in ["true", "1", "yes"]:
14+
return False
15+
else:
16+
return True

backend/config.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from datetime import datetime, timedelta
1919
from enum import Enum
2020
import shapely.wkt
21+
import yaml
22+
2123
from . import OutputFormat
2224
from .bounding_polygons import get_county_polygon
2325
from .connectors.nmbgmr.source import (
@@ -68,7 +70,8 @@
6870
)
6971
from .connectors.usgs.source import NWISSiteSource, NWISWaterLevelSource
7072
from .connectors.wqp.source import WQPSiteSource, WQPAnalyteSource, WQPWaterLevelSource
71-
from .logger import Loggable
73+
from backend.logger import Loggable
74+
7275

7376
SOURCE_DICT = {
7477
"bernco": BernCoSiteSource,
@@ -98,9 +101,6 @@ def get_source(source):
98101
return klass()
99102

100103

101-
102-
103-
104104
class Config(Loggable):
105105
site_limit: int = 0
106106
dry: bool = False
@@ -149,18 +149,14 @@ class Config(Loggable):
149149
analyte_output_units: str = MILLIGRAMS_PER_LITER
150150
waterlevel_output_units: str = FEET
151151

152-
# use_csv: bool = True
153-
# use_geojson: bool = False
154-
155-
output_format: OutputFormat = OutputFormat.CSV
152+
output_format: str = OutputFormat.CSV
156153

157-
yes: bool = True
154+
yes: bool = False
158155

159156
def __init__(self, model=None, payload=None, path=None):
160157
# need to initialize logger
161158
super().__init__()
162159

163-
self.bbox = {}
164160
if path:
165161
payload = self._load_from_yaml(path)
166162

@@ -186,24 +182,27 @@ def __init__(self, model=None, payload=None, path=None):
186182
if value is not None:
187183
setattr(self, f"use_source_{sk}", value)
188184

189-
for attr in ("wkt", "county", "bbox",
190-
"output_summary",
191-
"output_timeseries_unified",
192-
"output_timeseries_separated",
193-
"start_date",
194-
"end_date",
195-
"parameter",
196-
"output_name",
197-
"dry",
198-
"latest_water_level_only",
199-
"output_format",
200-
"use_cloud_storage",
201-
"yes"):
185+
for attr in (
186+
"wkt",
187+
"county",
188+
"bbox",
189+
"output_summary",
190+
"output_timeseries_unified",
191+
"output_timeseries_separated",
192+
"start_date",
193+
"end_date",
194+
"parameter",
195+
"output_name",
196+
"dry",
197+
"latest_water_level_only",
198+
"output_format",
199+
"use_cloud_storage",
200+
"yes",
201+
):
202202
if attr in payload:
203203
setattr(self, attr, payload[attr])
204204

205205
def _load_from_yaml(self, path):
206-
import yaml
207206
path = os.path.abspath(path)
208207
if os.path.exists(path):
209208
self.log(f"Loading config from {path}")
@@ -221,7 +220,6 @@ def get_config_and_false_agencies(self):
221220
"ebid",
222221
"nmbgmr_amp",
223222
"nmose_isc_seven_rivers",
224-
"nmose_pod",
225223
"nmose_roswell",
226224
"nwis",
227225
"pvacd",
@@ -450,7 +448,7 @@ def _report_attributes(title, attrs):
450448
"output_horizontal_datum",
451449
"output_elevation_units",
452450
"use_cloud_storage",
453-
"output_format"
451+
"output_format",
454452
),
455453
)
456454

@@ -573,4 +571,6 @@ def output_path(self):
573571
def get(self, attr):
574572
if self._payload:
575573
return self._payload.get(attr)
574+
575+
576576
# ============= EOF =============================================

0 commit comments

Comments
 (0)