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

Github actions #16

Merged
merged 18 commits into from
Jul 1, 2021
56 changes: 56 additions & 0 deletions .github/workflows/new_pypi_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Release to Pypi

# Run on a published release and push to Pypi
on:
release:
types: [published]

jobs:

build_dist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.6'

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip wheel
python3 -m pip install -r requirements.txt

- name: Build dist
run: python setup.py sdist --formats=gztar

- name: Build wheel
run: python3 setup.py bdist_wheel

- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_dist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
# To test: repository_url: https://test.pypi.org/legacy/
43 changes: 43 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Unittest

# Run action on pull requests
on:
pull_request:
branches: [ main ]

jobs:

unittest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.6'

- name: Install system dependencies
run: |
sudo apt-get install -y sqlite3 \
texlive-base \
texlive-latex-base \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-fonts-extra
shell: bash

- name: Install python dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 setup.py install
mkdir ~/.config/matplotlib
echo "backend: Agg" > ~/.config/matplotlib/matplotlibrc

- name: Run unittests
run: python3 -m unittest -v
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ tests/lakes/results/gold.db
snowav/utils/gitinfo.py

# pycharm
.idea/
.idea/

.venv
.vscode
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SNOw and Water model Analysis and Visualization

[![GitHub version](https://badge.fury.io/gh/USDA-ARS-NWRC%2Fsnowav.svg)](https://badge.fury.io/gh/USDA-ARS-NWRC%2Fsnowav)
[![Build Status](https://travis-ci.org/USDA-ARS-NWRC/snowav.svg?branch=devel)](https://travis-ci.org/USDA-ARS-NWRC/snowav)

SNOWAV was developed at the USDA Agricultural Research Service in Boise, Idaho, and processes AWSM model outputs into formats and figures for use by water resource managers. See CoreConfig.ini for details on config options.

Expand All @@ -26,6 +25,8 @@ $ snowav -f config.ini

Below are notes for some of the config file fields, for additional information for all options see ```snowav/config/CoreConfig.ini```.

> **NOTE:** Do not have AWSM/SMRF outputs in a root directory with `run` in the path as `snowav` does a regex to replace this string. For example, the following path will produce an error `/path/runs/basin/ops` as it will be changed to `/data/datas/basin/ops`.

#### [snowav]
```save_path:``` Path to save results to.

Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
coloredlogs==6.1
cmocean==1.1
inicheck>0.7.5,<0.8
Jinja2==2.10.1
Jinja2==2.11.3
latexcodec==1.0.5
latex==0.7.0
matplotlib==2.0.0
Expand All @@ -13,6 +13,5 @@ numpy==1.16.3
requests>=2.0.0
seaborn==0.8
SQLAlchemy==1.3.3
tablizer>=0.2.1,<0.3.0
urllib3==1.24.3
utm==0.4.0
tablizer @ git+https://github.com/USDA-ARS-NWRC/tablizer@master#egg=tablizer
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
name='snowav',
version='0.11.16',
description="Snow and Water Model Analysis and Visualization ",
author="Mark Robertson",
author_email='mark.robertson@usda.gov',
author="USDA ARS NWRC",
author_email='snow@ars.usda.gov',
url='https://github.com/USDA-ARS-NWRC/snowav',
packages=['snowav',
'snowav.config',
Expand Down
5 changes: 3 additions & 2 deletions snowav/framework/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ def __init__(self, cfg, db):
for name in cfg.masks:
mask_list.append(deepcopy(cfg.masks[name]['mask']))

sf = cfg.rundirs_dict[wy_hour].replace('runs', 'data')
sf = sf.replace('run', 'data') + '/smrfOutputs/'
# sf = cfg.rundirs_dict[wy_hour].replace('runs', 'data')
# sf = sf.replace('run', 'data') + '/smrfOutputs/'
sf = cfg.rundirs_dict[wy_hour].replace('/runs/run', '/data/data') + '/smrfOutputs/'

params = {Inputs: [
('date_time', 'eq', out_date),
Expand Down
Binary file modified tests/lakes/results/gold.db
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_snowav.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

"""

matplotlib.use('agg')
matplotlib.use('Agg')

topo_path = './tests/lakes/topo/topo.nc'
gold_db_path = './tests/lakes/results/gold.db'
Expand Down
18 changes: 0 additions & 18 deletions tox.ini

This file was deleted.

124 changes: 0 additions & 124 deletions travis_pypi_setup.py

This file was deleted.