Skip to content

Commit

Permalink
ci: try adding provider update
Browse files Browse the repository at this point in the history
refactor: drop `to_bool` function from `model` class
  • Loading branch information
tsutterley committed Sep 5, 2024
1 parent accfc63 commit b8835b0
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 18 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/update-provider-database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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 .
python providers/_providers_to_database.py
- 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 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"
}
}
}
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

0 comments on commit b8835b0

Please sign in to comment.