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

Updates for SMRF #70

Merged
merged 16 commits into from
Aug 3, 2020
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Eclipse files
.venv
.vscode
.project
.settings
.pydevproject
Expand All @@ -10,6 +12,8 @@ test_data/stoporad.ip
*.prof
*.ipw

output/*.png

test_data/wrfout_d02_2016-03-10.nc
test_data/stoporad*
examples/*.nc
Expand Down
84 changes: 74 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,79 @@
# Config file for automatic testing at travis-ci.org

sudo: required

language: python
# test stage will test all branches against:
# - linux python 3.5, 3.6, 3.7, 3.8
# - osx python 3.7
#
# deploy stage builds and test the wheels when jobs is
# - pull request
# - master branch
# - tagged commit, only this will be uploaded to pypi

services:
- docker

before_install:
- docker pull usdaarsnwrc/smrf:latest
- docker build --build-arg REQUIREMENTS=_dev -t usdaarsnwrc/awsm .
stages:
- test
- name: deploy
if: type = pull_request OR branch = master OR tag IS present AND repo = USDA-ARS-NWRC/awsm

env:
global:
- TWINE_USERNAME=__token__
# Note: TWINE_PASSWORD is set to a PyPI API token in Travis settings

# defining the unittest jobs
unittest: &unittest
stage: test
os: linux
dist: bionic
language: python
cache: pip
addons:
apt:
packages:
- libeccodes-tools
homebrew:
packages:
- eccodes
- gcc@7
install:
- python3 --version
- python3 -m pip install tox-travis cython
script: tox

jobs:
include:
# test stage
- <<: *unittest
python: 3.6
env: TOXENV=py36

- <<: *unittest
python: 3.6
env: TOXENV=coverage

- <<: *unittest
python: 3.6
env: TOXENV=flake8

- <<: *unittest
python: 3.7
env: TOXENV=py37

- <<: *unittest
python: 3.8
env: TOXENV=py38

- <<: *unittest
os: osx
osx_image: xcode11.2 # Python 3.7.X running on macOS 10.14
language: shell
env:
- TOXENV=py37
- CC=gcc-7
- NOT_ON_GOLD_HOST=yup

script:
docker run -it usdaarsnwrc/awsm test
allow_failures:
- python: 3.6
env: TOXENV=coverage
- python: 3.6
env: TOXENV=flake8
78 changes: 36 additions & 42 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
# AWSM is built on SMRF
FROM usdaarsnwrc/smrf:latest

MAINTAINER Scott Havens <[email protected]>

ARG REQUIREMENTS=''

####################################################
# Software version
####################################################
ENV VPYSNOBAL "0.2.0"

####################################################
# Install dependencies
####################################################

RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& apt-get install -y gcc \
&& cd /code \
&& git clone --depth 1 https://github.com/USDA-ARS-NWRC/pysnobal.git \
# Multi-stage AWSM docker build
FROM python:3.6-slim-buster as builder

RUN mkdir /install \
&& mkdir /build \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends \
gcc \
git \
libssl-dev \
libyaml-dev \
libhdf5-serial-dev \
curl \
libeccodes-tools \
&& rm -rf /var/lib/apt/lists/* \
&& apt remove -y curl \
&& apt autoremove -y
&& apt-get autoremove -y curl

####################################################
# AWSM
####################################################
COPY . /build
WORKDIR /build

COPY . / /code/awsm/
RUN python3 -m pip install --no-cache-dir --upgrade pip \
&& python3 -m pip install --no-cache-dir setuptools wheel \
&& python3 -m pip install --no-cache-dir --user 'numpy<1.19.0' cython \
&& python3 -m pip install --no-cache-dir --user -r requirements.txt \
&& python3 setup.py install --user

#ENV PYTHONPATH=/code/awsm/
##############################################
# main image
##############################################
FROM python:3.6-slim-buster

RUN cd /code/pysnobal \
&& python3 -m pip install --upgrade pip \
&& python3 setup.py install
COPY --from=builder /root/.local /usr/local

RUN cd /code/awsm \
&& python3 -m pip install --no-cache-dir -r /code/awsm/requirements${REQUIREMENTS}.txt \
&& python3 setup.py install \
&& rm -r /root/.cache/pip
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends libeccodes-tools \
# && python3 -m pip install --no-cache-dir nose \
# && nosetests -vv --exe awsm \
# && python3 -m pip uninstall -y nose \
&& rm -rf /var/lib/apt/lists/*

# Create a shared data volume
VOLUME /data
WORKDIR /data

COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
RUN echo "umask 0002" >> /etc/bash.bashrc
ENTRYPOINT ["/docker-entrypoint.sh"]
#CMD ["python3", "/code/awsm/scripts/awsm"]

#ENTRYPOINT ["python3", "/code/awsm/scripts/awsm"]
CMD ["/bin/bash"]
31 changes: 19 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ for line in sys.stdin:
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"
BROWSER := python3 -c "$$BROWSER_PYSCRIPT"

help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

Expand All @@ -47,19 +47,26 @@ clean-test: ## remove test and coverage artifacts
rm -f .coverage
rm -fr htmlcov/

isort: ## using isort to sort imports
isort -rc -v .

lint: ## check style with flake8
flake8 awsm tests

test: ## run tests quickly with the default Python

python setup.py test
test: ## run tests quickly with the default python3
python3 -m unittest -v

test-all: ## run tests on every Python version with tox
tox

coverage: ## check code coverage quickly with the default Python
coverage: ## run coverage and submit
coverage run --source awsm setup.py test
coverage report -m
coverage report --fail-under=40

coveralls: coverage ## run coveralls
coveralls

coverage-html: coverage ## check code coverage quickly with the default Python
coverage html
$(BROWSER) htmlcov/index.html

Expand All @@ -75,13 +82,13 @@ servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .

release: clean ## package and upload a release
python setup.py sdist upload
python setup.py bdist_wheel upload
python3 setup.py sdist upload
python3 setup.py bdist_wheel upload

dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
python3 setup.py sdist
python3 setup.py bdist_wheel
ls -l dist

install: clean ## install the package to the active Python's site-packages
python setup.py install
python3 setup.py install
49 changes: 24 additions & 25 deletions awsm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
# -*- coding: utf-8 -*-

"""Top-level package for awsm."""

__author__ = """Micah Sandusky"""
__email__ = '[email protected]'
__version__ = '0.10.0'
import matplotlib
matplotlib.use('Agg')

from . import framework
from . import interface
from . import convertFiles
from . import utils
import os

__core_config__ = os.path.abspath(os.path.dirname(__file__) + '/framework/CoreConfig.ini')
__recipes__ = os.path.abspath(os.path.dirname(__file__) + '/framework/recipes.ini')
__core_config__ = os.path.abspath(
os.path.dirname(__file__) + '/framework/CoreConfig.ini')
__recipes__ = os.path.abspath(os.path.dirname(
__file__) + '/framework/recipes.ini')

__config_titles__ = {'awsm master': 'Configurations for AWSM Master section',
'paths': 'Configurations for PATHS section'
' for rigid directory work',
'grid': 'Configurations for GRID data to run iSnobal',
'files': 'Input files to run AWSM',
'awsm system': 'System parameters',
'isnobal restart': 'Parameters for restarting'
' from crash',
'ipysnobal': 'Running Python wrapped iSnobal',
'ipysnobal initial conditions': 'Initial condition'
' parameters for'
' PySnobal',
'ipysnobal constants': 'Input constants for PySnobal'
}
__config_titles__ = {
'awsm master': 'Configurations for AWSM Master section',
'paths': 'Configurations for PATHS section'
' for rigid directory work',
'grid': 'Configurations for GRID data to run iSnobal',
'files': 'Input files to run AWSM',
'awsm system': 'System parameters',
'isnobal restart': 'Parameters for restarting'
' from crash',
'ipysnobal': 'Running Python wrapped iSnobal',
'ipysnobal initial conditions': 'Initial condition'
' parameters for'
' PySnobal',
'ipysnobal constants': 'Input constants for PySnobal'
}

from . import utils

__config_header__ = utils.utilities.get_config_header()

Loading