Skip to content

Commit

Permalink
Merge pull request #22 from BillMills/gridtools
Browse files Browse the repository at this point in the history
easyocean
  • Loading branch information
bkatiemills authored Jan 18, 2024
2 parents 96bde58 + da54c5c commit bb9ca58
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM python:3.9

RUN pip install requests pytest area numpy scipy
WORKDIR /app
COPY . .
COPY . .
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
## Build and release

- Review metadata in `pyproject.toml`; while determining if code is release worthy, append an rc tag to the semantic version, like `major.minor.patch.rcxx`
- Build a release:
- Build a release (image is built off of `Dockerfile-build-env`):
```
docker container run -v $(pwd):/src argovis/argovis_helpers:build-220912 python -m build
docker container run -v $(pwd):/src argovis/argovis_helpers:build-240118 python -m build
```
- Push to testPypi:
- Push to testPypi (notice you'll need a file `pypirc` with appropriate API tokens for the pypi servers):
```
docker container run -v $(pwd):/src -it argovis/argovis_helpers:build-220912 twine upload -r testpypi dist/<your new rc>
docker container run -v $(pwd):/src -v $(pwd)/pypirc:/root/.pypirc -it argovis/argovis_helpers:build-240118 twine upload -r testpypi dist/<your new rc>
```
- Test install and try: `python -m pip install -i https://test.pypi.org/simple argovis_helpers`
- If all is well, rebuild without the rc tag and push to pypi:
```
docker container run -v $(pwd):/src -it argovis/argovis_helpers:build-220912 twine upload dist/<your new release>
docker container run -v $(pwd):/src -v $(pwd)/pypirc:/root/.pypirc -it argovis/argovis_helpers:build-240118 twine upload dist/<your new release>
```
- `git add` your new build artifacts under `/dist`
- Push to github and mint a release matching the version number in `pyproject.toml`.



10 changes: 7 additions & 3 deletions argovisHelpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def argofetch(route, options={}, apikey='', apiroot='https://argovis-api.colorad
time.sleep(wait*1.1)
return argofetch(route, options=o, apikey=apikey, apiroot=apiroot, suggestedLatency=latency, verbose=verbose)

if statuscode!=404 and statuscode!=200:
if (statuscode!=404 and statuscode!=200) or (statuscode==200 and type(dl) is dict and 'code' in dl):
if statuscode == 413:
print('The temporospatial extent of your request is enormous! Consider using the `query` helper in this package to split it up into more manageable chunks.')
elif statuscode >= 500:
elif statuscode >= 500 or (statuscode==200 and type(dl) is dict and 'code' in dl):
print("Argovis' servers experienced an error. Please try your request again, and email [email protected] if this keeps happening; please include the full details of the the request you made so we can help address.")
raise Exception(statuscode)

Expand All @@ -41,14 +41,15 @@ def query(route, options={}, apikey='', apiroot='https://argovis-api.colorado.ed
r = re.sub('^/', '', route)
r = re.sub('/$', '', r)

data_routes = ['argo', 'cchdo', 'drifters', 'tc', 'argotrajectories', 'grids/rg09', 'grids/kg21', 'grids/glodap' 'timeseries/noaasst', 'timeseries/copernicussla', 'timeseries/ccmpwind']
data_routes = ['argo', 'cchdo', 'drifters', 'tc', 'argotrajectories', 'easyocean', 'grids/rg09', 'grids/kg21', 'grids/glodap' 'timeseries/noaasst', 'timeseries/copernicussla', 'timeseries/ccmpwind']

scoped_parameters = {
'argo': ['id','platform'],
'cchdo': ['id', 'woceline', 'cchdo_cruise'],
'drifters': ['id', 'wmo', 'platform'],
'tc': ['id', 'name'],
'argotrajectories': ['id', 'platform'],
'easyocean': ['id', 'woceline'],
'grids/rg09': ['id'],
'grids/kg21': ['id'],
'grids/glodap': ['id'],
Expand All @@ -63,6 +64,7 @@ def query(route, options={}, apikey='', apiroot='https://argovis-api.colorado.ed
'drifters': parsetime("1987-10-01T13:00:00.000Z"),
'tc': parsetime("1851-06-24T00:00:00.000Z"),
'argotrajectories': parsetime("2001-01-03T22:46:33.000Z"),
'easyocean': parsetime("1983-10-08T00:00:00.000Z"),
'grids/rg09': parsetime("2004-01-14T00:00:00.000Z"),
'grids/kg21': parsetime("2005-01-14T00:00:00.000Z"),
'grids/glodap': parsetime("0001-01-01T00:00:00.000Z"),
Expand All @@ -71,12 +73,14 @@ def query(route, options={}, apikey='', apiroot='https://argovis-api.colorado.ed
'timeseries/ccmpwind': parsetime("1993-01-02T00:00:00Z")
}

# plus a day vs the API, just to make sure we don't artificially cut off
last_records = {
'argo': datetime.datetime.now(),
'cchdo': parsetime("2023-03-10T17:48:00.000Z"),
'drifters': parsetime("2020-07-01T23:00:00.000Z"),
'tc': parsetime("2020-12-26T12:00:00.000Z"),
'argotrajectories': parsetime("2021-01-02T01:13:26.000Z"),
'easyocean': parsetime("2022-10-17T00:00:00.000Z"),
'grids/rg09': parsetime("2022-05-16T00:00:00.000Z"),
'grids/kg21': parsetime("2020-12-16T00:00:00.000Z"),
'grids/glodap': parsetime("0001-01-02T00:00:00.000Z"),
Expand Down
Binary file added dist/argovisHelpers-0.0.16-py3-none-any.whl
Binary file not shown.
Binary file added dist/argovisHelpers-0.0.16.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "argovisHelpers"
version = "0.0.15"
version = "0.0.16"
description = "Helper functions to consume and parse information from University of Colorado's Argovis API."
readme = "README.md"
authors = [{name = "Bill Mills" }]
Expand Down

0 comments on commit bb9ca58

Please sign in to comment.