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

add build-n-publish-to-pypi github action #18

Merged
merged 3 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions" # see doc for possible values
directory: "/" # location of package manifests
schedule:
interval: "weekly"
78 changes: 78 additions & 0 deletions .github/workflows/build-n-publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# link: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
name: publish 📦 to PyPI

# Build on every branch push, tag push, and pull request change
on:
push:
branches:
- main
tags:
- v*
pull_request:

jobs:
build-sdist-n-wheel:
name: Build 🐍 distributions and wheels 📦
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install pypa/build
run: >-
python -m
pip install
build
--user

- name: Build a source tarball and a binary wheel
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.

- uses: actions/upload-artifact@v3
with:
path: |
dist/*.tar.gz
dist/*.whl

upload-to-pypi:
name: Upload 📦 to (Test) PyPI
needs: [build-sdist-n-wheel]
runs-on: ubuntu-latest
if: github.repository_owner == 'insarlab' && github.event_name == 'push'
steps:

- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist

- name: Publish developed version 📦 to Test PyPI
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: false
verbose: true

- name: Publish released version 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ python PyAPS/tests/test_dload.py

The methodology and validation can be found in:

+ Jolivet, R., R. Grandin, C. Lasserre, M.-P. Doin and G. Peltzer (2011), Systematic InSAR tropospheric phase delay corrections from global meteorological reanalysis data, Geophys. Res. Lett., 38, L17311, doi:10.1029/2011GL048757.
+ Jolivet, R., R. Grandin, C. Lasserre, M.-P. Doin and G. Peltzer (2011), Systematic InSAR tropospheric phase delay corrections from global meteorological reanalysis data, _Geophys. Res. Lett., 38,_ L17311, doi:10.1029/2011GL048757.
6 changes: 3 additions & 3 deletions src/pyaps3/delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def read_eratxt(fname,cdic):
gpht=[]
tmpt=[]
reht=[]

g=cdic['g']

f=open(fname,'r')
Expand Down Expand Up @@ -96,7 +96,7 @@ def read_eratxt(fname,cdic):
tmpt.append(float(val[2]))
reht.append(float(val[3]))
i=i+1

gpht=np.array(gpht)/g
gph=np.flipud(gpht.reshape((n,nstn),order='F'))
del gpht
Expand All @@ -109,7 +109,7 @@ def read_eratxt(fname,cdic):
vprt=(np.array(reht)/100.)*esat
vpr=np.flipud(vprt.reshape((n,nstn),order='F'))
del vprt
del esat
del esat

lvls=np.flipud(np.array(lvls))
lvls=lvls[0:n]
Expand Down
12 changes: 6 additions & 6 deletions src/pyaps3/merra.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@


def get_merra(fname,minlat,maxlat,minlon,maxlon,cdic,verbose=False):
'''Read data from MERRA hdf file. Note that the Lon values
should be between [0-360]. Hdf file with weather model
data can be downloaded from
'''Read data from MERRA hdf file. Note that the Lon values
should be between [0-360]. Hdf file with weather model
data can be downloaded from
http://disc.sci.gsfc.nasa.gov/daac-bin/FTPSubset.pl

Args:
Expand Down Expand Up @@ -105,7 +105,7 @@ def get_merra(fname,minlat,maxlat,minlon,maxlon,cdic,verbose=False):
index = nlvls - i - 1
gph[i,:] = height[index][ii,jj]

idx = np.zeros(nstn)
idx = np.zeros(nstn)
for i in range(nstn):
for m in range(nlvls):
if spressure[ii[i]][jj[i]] > lvls[m]:
Expand Down Expand Up @@ -174,7 +174,7 @@ def get_merra(fname,minlat,maxlat,minlon,maxlon,cdic,verbose=False):
nlvls = len(lvls)
lvls = np.array(lvls)

alpha = cdic['Rv']/cdic['Rd']
alpha = cdic['Rv']/cdic['Rd']

# Select latitutde and longitude
lats = ncv['lat'][:]
Expand Down Expand Up @@ -226,7 +226,7 @@ def get_merra(fname,minlat,maxlat,minlon,maxlon,cdic,verbose=False):
index = nlvls - i - 1
gph[i,:] = height[index][ii,jj]

idx = np.zeros(nstn)
idx = np.zeros(nstn)
for i in range(nstn):
for m in range(nlvls):
if spressure[ii[i]][jj[i]] > lvls[m]:
Expand Down
1 change: 1 addition & 0 deletions src/pyaps3/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# release history
Tag = collections.namedtuple('Tag', 'version date')
release_history = (
Tag('0.3.2', '2022-12-20'),
Tag('0.3.1', '2021-11-26'),
Tag('0.3.0', '2021-11-15'),
Tag('0.2.0', '2021-08-31'),
Expand Down