Skip to content

Commit

Permalink
Merge pull request #170 from scotthavens/smrf_package
Browse files Browse the repository at this point in the history
SMRF package
  • Loading branch information
Scott Havens authored Jun 29, 2020
2 parents 4e1ebc5 + 893f30c commit d6f062a
Show file tree
Hide file tree
Showing 228 changed files with 1,935 additions and 221,751 deletions.
15 changes: 0 additions & 15 deletions .bumpversion.cfg

This file was deleted.

12 changes: 2 additions & 10 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
Dockerfile
.venv/

# Eclipse files
.project
.settings
.pydevproject
.DS_Store
._.*
test_data/stoporad.ip

*.lprof
*.prof
*.ipw

test_data/wrfout_d02_2016-03-10.nc
test_data/stoporad*
Expand Down Expand Up @@ -42,9 +36,9 @@ lib64/
parts/
sdist/
var/
*.egg-info/
# *.egg-info/
.installed.cfg
*.egg
# *.egg

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -84,8 +78,6 @@ target/
*.py~
*.swp

# git version stuff:
smrf/utils/gitinfo.py

#Auto generate config files
*config_full.ini
Expand Down
24 changes: 2 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Eclipse files
.project
.settings
.pydevproject
.DS_Store
._.*

Expand All @@ -16,7 +12,6 @@

# Examples files
examples/*/*/maxus*.nc
*/*/output/*
*/*/log.*

# Byte-compiled / optimized / DLL files
Expand Down Expand Up @@ -44,6 +39,7 @@ var/
*.egg-info/
.installed.cfg
*.egg
wheelhouse/

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -83,9 +79,6 @@ target/
*.py~
*.swp

# git version stuff:
smrf/utils/gitinfo.py

#Auto generate config files
*config_full.ini
test_data/config.ini
Expand All @@ -98,24 +91,11 @@ docs/auto_config.rst
docs/modules.rst
docs/smrf.rst

#Ignore results in test_data
test_data/output/*
test_data/tmp/*
tests/RME/output/*
tests/RME/**/*.idx

#ignore maxus.
test_data/topo/maxus_100window.nc
test_data/topo/maxus.nc
examples/* *.nc
examples/reynolds_mountain_east/output/*
examples/simple_hill/* *.csv

*/tmp/*

# notebooks
.ipynb_checkpoints

# grib2 .idx files
*.grib2.*.idx

output/
109 changes: 100 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,106 @@
# 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 build --build-arg REQUIREMENTS=_dev -t usdaarsnwrc/smrf .
stages:
- test
- name: deploy
if: type = pull_request OR branch = master OR tag IS present AND repo = USDA-ARS-NWRC/smrf

env:
global:
- CIBW_MANYLINUX_X86_64_IMAGE=manylinux2014
- CIBW_TEST_REQUIRES=nose
- CIBW_TEST_COMMAND="NOT_ON_GOLD_HOST=yup nosetests -vv --exe smrf"
- CIBW_BUILD="cp3*-manylinux_x86_64 cp3*-macosx_x86_64"
- CIBW_SKIP="?p27* pp* cp35*"
- CIBW_BUILD_VERBOSITY=1
- CIBW_BEFORE_BUILD_LINUX="{package}/travis/cibuildwheel_before_build_linux.sh"
- CIBW_BEFORE_BUILD_MACOS="{package}/travis/cibuildwheel_before_build_macos.sh"
- CIBW_ENVIRONMENT="NOT_ON_GOLD_HOST=yup"
- CIBW_ENVIRONMENT_MACOS="NOT_ON_GOLD_HOST=yup CC=gcc-7"
- 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
addons:
apt:
packages:
- libeccodes-tools
homebrew:
packages:
- eccodes
- gcc@7
install:
- python3 --version
- python3 -m pip install tox-travis cython
script: tox

# build the wheels with cibuildwheel
ci-build-wheels: &ci-build-wheels
stage: deploy
services: docker
os: linux
dist: xenial
language: python
install: python3 -m pip install cibuildwheel==1.4.2
script: travis/build.sh

jobs:
include:
# test stage
- <<: *unittest
python: 3.6
env: TOXENV=py36,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/smrf test
# Deploy source distribution
- stage: deploy
name: Deploy source distribution
language: python
python: 3.6
install: skip
script: travis/build-sdist.sh

# Deploy on linux
- <<: *ci-build-wheels
name: Build and deploy Linux wheels

# Deploy on osx
- <<: *ci-build-wheels
name: Build and deploy macOS wheels
os: osx
language: shell
71 changes: 29 additions & 42 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,59 +1,46 @@
# SMRF is built on the IPW
FROM usdaarsnwrc/ipw:latest

MAINTAINER Scott Havens <[email protected]>

ARG REQUIREMENTS=''

####################################################
# System requirements
####################################################

RUN apt-get update -y \
&& apt-get install -y --no-install-recommends libblas-dev \
# Multi-stage SMRF 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 \
liblapack-dev \
libatlas-base-dev \
libffi-dev \
libssl-dev \
gfortran \
libyaml-dev \
libfreetype6-dev \
libpng-dev \
libhdf5-serial-dev \
python3-dev \
python3-pip \
python3-tk \
curl \
libeccodes-dev \
libeccodes-tools \
&& rm -rf /var/lib/apt/lists/* \
&& apt autoremove -y curl

####################################################
# SMRF
####################################################
&& apt-get autoremove -y curl

COPY . / /code/smrf/
COPY . /build
WORKDIR /build

RUN mkdir /data \
&& cd /code/smrf \
&& python3 -m pip install --no-cache-dir --upgrade pip \
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 -r /code/smrf/requirements${REQUIREMENTS}.txt \
&& python3 -m pip install --no-cache-dir --user -r requirements.txt \
&& python3 setup.py bdist_wheel \
&& python3 setup.py build_ext --inplace \
&& python3 setup.py install \
# && rm -r /root/.cache/pip \
&& apt-get autoremove -y gcc
&& python3 setup.py install --user

####################################################
# Create a shared data volume
####################################################
##############################################
# main image
##############################################
FROM python:3.6-slim-buster

COPY --from=builder /root/.local /usr/local

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 smrf \
&& 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
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/bin/bash"]
Loading

0 comments on commit d6f062a

Please sign in to comment.