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

ci: try adding provider update #330

Merged
merged 10 commits into from
Sep 5, 2024
Merged
68 changes: 68 additions & 0 deletions .github/workflows/update-provider-database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This workflow will install Python dependencies and update database from the provider files

name: Update provider database on pull request

on:
pull_request:

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.11]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4
- name: Set up mamba ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: 'latest'
environment-file: environment.yml
init-shell: bash
environment-name: pyTMD
cache-environment: true
post-cleanup: 'all'
create-args: >-
python=${{ matrix.python-version }}
flake8
gh
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Merge Providers
run: |
pip install --no-deps --editable .
python providers/_providers_to_database.py --pretty -vv
- name: Check for changes
id: changes
run: |
if [ -n "$(git status --porcelain)" ] ; then
echo "DETECTED=true" >> $GITHUB_OUTPUT;
echo "::debug::Changes detected";
else
echo "DETECTED=false" >> $GITHUB_OUTPUT;
echo "::debug::No changes detected";
fi
- name: Checkout PR and Push Changes
if: steps.changes.outputs.DETECTED == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout ${{ github.event.pull_request.number }}
git add -A
git config user.name ${{ github.actor }}
git config user.email ${{ github.actor }}@users.noreply.github.com
git commit -m "Update provider database"
git push
28 changes: 28 additions & 0 deletions providers/GSFC.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,34 @@
"type": "z",
"variable": "tide_load",
"version": "5.5"
},
"GOT5.5D": {
"format": "GOT-netcdf",
"name": "GOT5.5D",
"model_file": [
"GOT5.5/ocean_tides/2n2.nc",
"GOT5.5/ocean_tides/j1.nc",
"GOT5.5D/ocean_tides/k1_5.5D.nc",
"GOT5.5/ocean_tides/k2.nc",
"GOT5.5D/ocean_tides/m2_5.5D.nc",
"GOT5.5/ocean_tides/m4.nc",
"GOT5.5/ocean_tides/ms4.nc",
"GOT5.5/ocean_tides/mu2.nc",
"GOT5.5/ocean_tides/n2.nc",
"GOT5.5/ocean_tides/o1.nc",
"GOT5.5/ocean_tides/oo1.nc",
"GOT5.5D/ocean_tides/p1_5.5D.nc",
"GOT5.5/ocean_tides/q1.nc",
"GOT5.5D/ocean_tides/s1_5.5D.nc",
"GOT5.5D/ocean_tides/s2_5.5D.nc",
"GOT5.5/ocean_tides/sig1.nc"
],
"type": "z",
"variable": "tide_ocean",
"version": "5.5",
"scale": 0.01,
"compressed": false,
"reference": "https://ntrs.nasa.gov/citations/19990089548"
}
}
}
28 changes: 28 additions & 0 deletions pyTMD/data/database.json
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,34 @@
"variable": "tide_ocean",
"version": "5.5"
},
"GOT5.5D": {
"compressed": false,
"format": "GOT-netcdf",
"model_file": [
"GOT5.5/ocean_tides/2n2.nc",
"GOT5.5/ocean_tides/j1.nc",
"GOT5.5D/ocean_tides/k1_5.5D.nc",
"GOT5.5/ocean_tides/k2.nc",
"GOT5.5D/ocean_tides/m2_5.5D.nc",
"GOT5.5/ocean_tides/m4.nc",
"GOT5.5/ocean_tides/ms4.nc",
"GOT5.5/ocean_tides/mu2.nc",
"GOT5.5/ocean_tides/n2.nc",
"GOT5.5/ocean_tides/o1.nc",
"GOT5.5/ocean_tides/oo1.nc",
"GOT5.5D/ocean_tides/p1_5.5D.nc",
"GOT5.5/ocean_tides/q1.nc",
"GOT5.5D/ocean_tides/s1_5.5D.nc",
"GOT5.5D/ocean_tides/s2_5.5D.nc",
"GOT5.5/ocean_tides/sig1.nc"
],
"name": "GOT5.5D",
"reference": "https://ntrs.nasa.gov/citations/19990089548",
"scale": 0.01,
"type": "z",
"variable": "tide_ocean",
"version": "5.5"
},
"GOT5.5_load": {
"format": "GOT-netcdf",
"model_file": [
Expand Down
19 changes: 1 addition & 18 deletions pyTMD/io/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def formats() -> list:
parameters = load_database()
# extract all known formats
format_list = []
for type, models in parameters.items():
for variable, models in parameters.items():
for model, val in models.items():
format_list.append(val['format'])
# return unique list of formats
Expand Down Expand Up @@ -872,23 +872,6 @@ def parse_file(
else:
return None

@staticmethod
def to_bool(val: str) -> bool:
"""
Converts strings of True/False to a boolean values

Parameters
----------
val: str
string for converting to True/False
"""
if val.lower() in ('y', 'yes', 't', 'true', '1'):
return True
elif val.lower() in ('n', 'no', 'f', 'false', '0'):
return False
else:
raise ValueError(f'Invalid boolean string {val}')

def __str__(self):
"""String representation of the ``io.model`` object
"""
Expand Down