Skip to content

Commit

Permalink
Switch to setuptools (#583)
Browse files Browse the repository at this point in the history
* take one, I think we will need to tweak more becasue of files in share directory

* ok should be loading files from egg now

* try fixes from testsrunner for coverage on subprocesses with --coverage-from-repo

* just rerun linux_pmp_py3 to test coverage for now

* rerun linux_pmp_py3

* trying subprocess coverage

* correct coverage option

* removiung lina special testrunner version

* bring back all jobs

* correct job dependency

* noarch

* mved script to correct location

* fixes flake8 test and erorrs now reported on scripts (not checked before)

* travis no jobs in parallel

* new flake8 warning

* another flake8 caught on py3

* testing new testsrunner

* trying on mac

* need to tell mac to run coverall...

* typo

* pmp mdriver seems to be ok w/o subprocess

* missing file

* linux only

* seems like we need to turn autobounds off

* didn't do dirunal at this point

* flake8ed

* turn back on all machines

* removed unsed default_regions

* more flake8

* travis keeps timing out and creating troubles, removing
  • Loading branch information
doutriaux1 committed Nov 14, 2018
1 parent 8cc11d6 commit 0adc60a
Show file tree
Hide file tree
Showing 90 changed files with 672 additions and 706 deletions.
22 changes: 9 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ aliases:
conda update -y -q conda
conda config --set anaconda_upload no
if [[ $PY_VER = "py2" ]]; then
conda create -n $PY_VER -q -n $PY_VER $CHANNELS "python<3" $PKGS $FFMPEG
conda create -q -n $PY_VER $CHANNELS "python<3" $PKGS $FFMPEG
else
conda create -n $PY_VER -q -n $PY_VER $CHANNELS "python>3" $PKGS $FFMPEG $COVERAGE_PKGS
conda create -q -n $PY_VER $CHANNELS "python>3" $PKGS $FFMPEG $COVERAGE_PKGS
fi
- &setup_pmp
Expand All @@ -45,7 +45,6 @@ aliases:
source activate $PY_VER
python run_tests.py -H -v2 $COVERAGE
RESULT=$?
cd ..
echo "*** $PY_VER test result: "${RESULT}
- &run_coveralls
Expand Down Expand Up @@ -78,12 +77,8 @@ aliases:
rm -rf cdp
cp -r ../../recipes/pcmdi_metrics .
python ./prep_for_build.py -l 1.2
if [[ $PY_VER = 'py2' ]]; then
conda build $PKG_NAME $CHANNELS --python=27
else
conda build $PKG_NAME $CHANNELS --python=36
fi
anaconda -t $CONDA_UPLOAD_TOKEN upload -u pcmdi -l $LABEL $CONDA_BLD_PATH/$OS/$PKG_NAME-*tar.bz2 --force
conda build $PKG_NAME $CHANNELS --python=36
anaconda -t $CONDA_UPLOAD_TOKEN upload -u pcmdi -l $LABEL $CONDA_BLD_PATH/noarch/$PKG_NAME-*tar.bz2 --force
jobs:
Expand All @@ -101,7 +96,6 @@ jobs:
- run: *create_conda_env
- run: *setup_pmp
- run: *run_pmp_tests
- run: *conda_upload
- store_artifacts:
path: tests_html
destination: tests_html
Expand All @@ -117,13 +111,15 @@ jobs:
OS: "osx-64"
PY_VER: "py3"
FFMPEG: "'ffmpeg>4' 'libpng>1.6.34'"
COVERAGE: "-c tests/coverage.json --coverage-from-egg"
COVERAGE_PKGS: "coverage coveralls"
steps:
- checkout
- run: *setup_miniconda
- run: *create_conda_env
- run: *setup_pmp
- run: *run_pmp_tests
- run: *conda_upload
- run: *run_coveralls
- store_artifacts:
path: tests_html
destination: tests_html
Expand All @@ -145,7 +141,6 @@ jobs:
- run: *create_conda_env
- run: *setup_pmp
- run: *run_pmp_tests
- run: *conda_upload
- store_artifacts:
path: tests_html
destination: tests_html
Expand All @@ -161,7 +156,7 @@ jobs:
OS: "linux-64"
PY_VER: "py3"
FFMPEG: "ffmpeg"
COVERAGE: "-c tests/coverage.json"
COVERAGE: "-c tests/coverage.json --coverage-from-egg"
COVERAGE_PKGS: "coverage coveralls"
steps:
- checkout
Expand All @@ -178,6 +173,7 @@ jobs:
path: tests_png
destination: tests_png


workflows:
version: 2
pcmdi_metrics:
Expand Down
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import cdutil
import MV2
import os
import sys
import glob
import pcmdi_metrics
import collections
import json
import pkg_resources
from pcmdi_metrics.diurnal.common import monthname_d, P, populateStringConstructor


Expand Down Expand Up @@ -218,11 +218,10 @@ def spacevavg(tvarb1, tvarb2, sftlf, model):
os.path.abspath(
args.results_dir),
os.path.basename(jsonname))
egg_pth = pkg_resources.resource_filename(pkg_resources.Requirement.parse("pcmdi_metrics"), "share/pmp")
disclaimer = open(
os.path.join(
sys.prefix,
"share",
"pmp",
egg_pth,
"disclaimer.txt")).read()
metrics_dictionary["DISCLAIMER"] = disclaimer
metrics_dictionary["REFERENCE"] = "The statistics in this file are based on Covey et al., J Climate 2016"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import pcmdi_metrics
import collections
import glob
import sys
import json
import pkg_resources

from pcmdi_metrics.diurnal.common import monthname_d, P, populateStringConstructor, INPUT
import cdp
Expand Down Expand Up @@ -116,11 +116,10 @@ def compute(param):
os.path.abspath(
args.results_dir),
jsonFile())
egg_pth = pkg_resources.resource_filename(pkg_resources.Requirement.parse("pcmdi_metrics"), "share/pmp")
disclaimer = open(
os.path.join(
sys.prefix,
"share",
"pmp",
egg_pth,
"disclaimer.txt")).read()
metrics_dictionary["DISCLAIMER"] = disclaimer
metrics_dictionary["REFERENCE"] = "The statistics in this file are based on Trenberth, Zhang & Gehne, J Hydromet. 2017"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import pcmdi_metrics
import collections
import glob
import sys
import cdp
import json
import pkg_resources
from pcmdi_metrics.diurnal.common import monthname_d, P, populateStringConstructor, INPUT


Expand Down Expand Up @@ -126,12 +126,10 @@ def compute(param):
os.path.abspath(
args.results_dir),
jsonFile())

egg_pth = pkg_resources.resource_filename(pkg_resources.Requirement.parse("pcmdi_metrics"), "share/pmp")
disclaimer = open(
os.path.join(
sys.prefix,
"share",
"pmp",
egg_pth,
"disclaimer.txt")).read()
metrics_dictionary["DISCLAIMER"] = disclaimer
metrics_dictionary["REFERENCE"] = "The statistics in this file are based on Trenberth, Zhang & Gehne, J Hydromet. 2017"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import pcmdi_metrics
import collections
import glob
import sys
import genutil
import json
import cdp
import pkg_resources
from pcmdi_metrics.diurnal.common import monthname_d, P, populateStringConstructor, INPUT


Expand Down Expand Up @@ -128,11 +128,10 @@ def compute(param):
os.path.abspath(
args.results_dir),
jsonFile())
egg_pth = pkg_resources.resource_filename(pkg_resources.Requirement.parse("pcmdi_metrics"), "share/pmp")
disclaimer = open(
os.path.join(
sys.prefix,
"share",
"pmp",
egg_pth,
"disclaimer.txt")).read()
metrics_dictionary["DISCLAIMER"] = disclaimer
metrics_dictionary["REFERENCE"] = "The statistics in this file are based on Trenberth, Zhang & Gehne, J Hydromet. 2017"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import cdutil
import cdms2
import pkg_resources
from pcmdi_metrics.io.base import Base
from six import with_metaclass

Expand Down Expand Up @@ -117,7 +118,8 @@ def get(self):
@staticmethod
def load_path_as_file_obj(name):
''' Returns a File object for the file named name. '''
file_path = sys.prefix + '/share/pmp/' + name
egg_pth = pkg_resources.resource_filename(pkg_resources.Requirement.parse("pcmdi_metrics"), "share/pmp")
file_path = os.path.join(egg_pth, name)
opened_file = None
try:
opened_file = open(file_path)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def calculate_and_output_metrics(self, ref, test):

try:
test_data = test()
except RuntimeError as e:
except RuntimeError:
# THIS EXCEPTION IS RAISED TO BREAK OUT OF THE FOR LOOP IN PCMDI_DRIVER
# THIS SHOULD BE A CUSTOM EXCEPTION (PrematureBreakError)
raise RuntimeError('Need to skip model: %s' % test.obs_or_model)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/python/io/base.py → pcmdi_metrics/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,12 @@ def getAxisList(self):
for a in self.json_struct:
values.append(set())
self.get_axes_values_recursive(0, len(self.json_struct) - 1, self.data, values)
autoBounds = cdms2.getAutoBounds()
cdms2.setAutoBounds("off")
for i, nm in enumerate(self.json_struct):
axes.append(cdms2.createAxis(sorted(list(values[i])), id=nm))
self.axes = axes
cdms2.setAutoBounds(autoBounds)
return self.axes

def __call__(self, **kargs):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions pcmdi_metrics/monsoon_wang/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .monsoon_precip_index_fncs import mpd, mpi_skill_scores # noqa
from .monsoon_wang_driver import create_monsoon_wang_parser, monsoon_wang_runner # noqa
Loading

0 comments on commit 0adc60a

Please sign in to comment.