diff --git a/.dockerignore b/.dockerignore index 14a369920a936e0a44fe853e38cbd7fef367a6c1..6a5d174d3fa806a3216e35a4e9087a4458c1e192 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ +.coverage .DS_Store node_modules *.pyc -conf +coverage.xml \ No newline at end of file diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000000000000000000000000000000000000..9d134c4da678cd330c2345c02a280fa97267ad8a --- /dev/null +++ b/.flake8 @@ -0,0 +1,13 @@ +[flake8] +count = True +exclude = .git,__pycache,node_modules +# This project uses PEP8 with the following exceptions: +# - continuation lines should use 2 levels of indentation (8 spaces) +# E122: continuation line missing indentation or outdented +# E126: continuation line over-indented for hanging indent +# E127: continuation line over-indented for visual indent +# E128: continuation line under-indented for visual indent +# E131: continuation line unaligned for hanging indent +# - short variables should be avoided, but not currently enforced +# E741: do not use variables named ‘l’, ‘O’, or ‘I’ +ignore = E122, E126, E127, E128, E131, E741 diff --git a/.gitignore b/.gitignore index 14a369920a936e0a44fe853e38cbd7fef367a6c1..cfc395469c2eccf92dfe9c3920c0879c693596a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ +.coverage .DS_Store node_modules *.pyc -conf +coverage.xml diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 170e837d5e7cc120e8a7acc1827af5db8c437f02..0000000000000000000000000000000000000000 --- a/.jshintrc +++ /dev/null @@ -1,20 +0,0 @@ -{ - "bitwise": true, - "curly": true, - "eqeqeq": true, - "immed": true, - "latedef": true, - "newcap": true, - "noarg": true, - "newcap": false, - "quotmark": "single", - "undef": true, - "unused": true, - "strict": true, - "trailing": true, - - "smarttabs": true, - - "browser": true, - "node": true -} diff --git a/.travis.yml b/.travis.yml index 0bc0912fad466bf6bec205d57d8eeda6de6ff697..87c689c86664b8736a840615f15585906c1cdeb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ python: - 2.7 - 3.4 - 3.5 + - 3.6 before_install: ## courtesy of http://conda.pydata.org/docs/travis.html - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then @@ -18,15 +19,13 @@ before_install: - conda config --set always_yes yes --set changeps1 no - conda update --yes conda - conda info -a - ## back to other dependencies - - nvm install v4.2.4 - - nvm use 4.2.4 - - npm install -g grunt-cli - - npm --version - - node --version install: - conda config --add channels conda-forge - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION obspy pycurl nose flake8 - source activate test-environment - - npm install -script: grunt lint test +script: + - flake8 -v bin/ geomagio/ test/ + - nosetests -v . +after_success: + - nosetests --with-coverage --cover-package=geomagio --cover-xml + - bash <(curl -s https://codecov.io/bash) diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index ab4caea68c4b051a314cf2d49ae1436d97b0922e..0000000000000000000000000000000000000000 --- a/Gruntfile.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -module.exports = function (grunt) { - var config = require('./gruntconfig'); - - config.tasks.forEach(grunt.loadNpmTasks); - grunt.initConfig(config); - - grunt.registerTask('lint', [ - 'flake8', - 'jshint' - ]); - - grunt.registerTask('test', [ - 'nose:main' - ]); - - grunt.registerTask('default', [ - 'clean', - 'lint', - 'test', - 'watch' - ]); -}; diff --git a/README.md b/README.md index 98cbeae3e6487787e90d4351cc316bac49bfbaad..cab1035e1ae30cb3fdaaebc43c7882ef3c1d12e4 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,6 @@ Docker is the simplest install option. http://localhost:8000/?token=TOKEN ``` - 3. Use the running container - Run the `geomag.py` command line interface: diff --git a/docs/develop.md b/docs/develop.md index 2a861bd0a633cde084162d866347df7dbed64162..f94e5cf39988fd6df7f509fc80b9468f03e787b6 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -2,50 +2,64 @@ Development Dependencies ======================== These instructions only need to be completed if you plan on developing new -code for this project. +code for this project, and may also be used to run a local copy of the code. -If developing on windows, see the [Windows](#windows) section below. Begin Developing ---------------- -1. Use npm to install `grunt-cli` +1. Install `obspy`, `pycurl`, `flake8`, and `nose`. +> Using Anaconda is recommended ( https://conda.io/miniconda.html ). - npm install -g grunt-cli + conda config --add channels conda-forge + conda create --name geomagenv obspy pycurl flake8 nose + source activate geomagenv -2. Install `numpy`, `scipy`, `obspy`, and `flake8` if they aren't already - installed. +2. Fork this project on Github ( https://guides.github.com/activities/forking/ ). -3. Clone this project (or fork and clone your fork) + https://github.com/{YOUR_GITHUB_ACCOUNT}/geomag-algorithms.git - git clone https://github.com/usgs/geomag-algorithms.git +3. Clone your fork -4. From root directory of project, install npm dependencies + git clone https://github.com/{YOUR_GITHUB_ACCOUNT}/geomag-algorithms.git + cd geomag-algorithms + git remote add upstream https://github.com/usgs/geomag-algorithms.git + +4. Use branches to develop new features and submit pull requests. - npm install -5. Run grunt to run unit tests, and watch for changes to python files +Developer Tools +--------------- - grunt +- **Linting errors** +Check for linting errors using Flake8 + cd geomag-algorithms + flake8 -### Windows +- **Unit tests** +Run unit tests using Nose -1. Install the newest release of Node - [(http://nodejs.org/download/)](http://nodejs.org/download/) for Windows, - using the Windows Installer (.msi). + cd geomag-algorithms + nosetests -1. Close and re-open your terminal so that your new PATH is loaded. +- **Automatically run linting and tests while developing** +(Requires NodeJS) + cd geomag-algorithms + npm install + npm run watch -### Coding Standards + +Coding Standards +---------------- This project adheres to PEP8 standards in most cases: https://www.python.org/dev/peps/pep-0008 -#### PEP8 Exceptions +**PEP8 Exceptions** -- Hanging/Visual indents (E126, E127, E128, E131) +- Hanging/Visual indents (E122, E126, E127, E128, E131) - line continuations should use two indentations (8 spaces). - do not use visual indents. diff --git a/docs/install.md b/docs/install.md index c3ff9cb0dca1f3a2023257105fb2908520d492cc..3ea54835a580d56fa4d210dfdc7fac242a311eba 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,70 +1,23 @@ Installation ============ -We recommend using virtual environments: -[(http://docs.python-guide.org/en/latest/dev/virtualenvs/)](http://docs.python-guide.org/en/latest/dev/virtualenvs/) +Using Anaconda is recommended ( https://conda.io/miniconda.html ). -[Mac](#mac) and [Windows](#windows) specific details are below. -1. Install __geomagio__ +1) Install Anaconda/Miniconda - pip install git+https://github.com/usgs/geomag-algorithms.git +2) Create a virtual environment -1. Use __geomagio__ + conda config --add channels conda-forge + conda create --name geomagenv obspy pycurl flake8 nose + source activate geomagenv - - Use the main script, `geomag.py -h` - - In python scripts, `import geomagio` - -The [Command Line Usage](./usage.md) and [Python API](./api.md) -pages have more instructions and examples. - - ---- -### Mac ### - -1. Install `python` (2.7.X) - - On OS X, we recommend using Homebrew [http://brew.sh/](http://brew.sh/) - -1. Install numpy, obspy requires this be installed separately. - - pip install numpy - -1. Install `node`, `git` and `python` (2.7.X). +3) Install **geomagio** - On OS X, we recommend using Homebrew -``` -brew install node -brew install git -``` + pip install git+https://github.com/usgs/geomag-algorithms.git -1. Use pip to install `numpy`, `scipy`, `obspy`, and `flake8` +4) Use **geomagio** - pip install numpy scipy obspy flake8 - -1. Update paths as needed in your `~/.bash_profile`: - - export PATH=$PATH:/usr/local/bin - # npm installed binaries - export PATH=$PATH:/usr/local/share/npm/bin - # gem installed binaries - export PATH=$PATH:/usr/local/opt/ruby/bin - -1. Close and re-open your terminal so that your new PATH is loaded. - Make sure to navigate back to your `geomag-algorithms` project directory. - - ---- -### Windows ### - -1. You will need a terminal tool for Windows. We recommend Git Bash - [(http://git-scm.com/download/win)](http://git-scm.com/download/win), but - another unix-like editor should work too. - -1. Install Anaconda - [(http://continuum.io/downloads)](http://continuum.io/downloads), which - includes `numpy`, `scipy` and `flake8`. - -1. Run `python` to verify that Anaconda's version of Python is being used. - If it isn't, update your PATH so that Conda's HOME is before any other - versions of Python. + - Use the main script, `geomag.py -h` + - In python scripts, `import geomagio` + - Install the Jupyter notebook server ( http://jupyter.org/install.html ) diff --git a/etc/DOIRootCA2.crt b/etc/DOIRootCA2.crt deleted file mode 100644 index 3a49f729b3975bf9fcbf9fa400ab647c69792b62..0000000000000000000000000000000000000000 --- a/etc/DOIRootCA2.crt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RJQL5xOaSzV9blszHv5 -okR+lkSsVo2QzR/mzFD7lXtwznkd/uak0hripTB7MtZenBzoQ8zAgjgw5TXjRSAZ -goWiJTAg+YTKclhJ7Cfg/m4XeCxzNgz/pU1XEdBF2Ngvp3C9M5CSBcqzb234uiFF -SyvJl/6erDTkQ5dLrnSnsJIw1ZS/XG/Fi41u8il0piLc5depTLn9qiWf29BRBEtG -xwFKSmqlRWsClj/zADirBTjcctw7ajPMkRpebgn+Bzv1eWDx4+OolQuR/a45644Q -GHVtIa/kVEl2DE0WcUw= ------END CERTIFICATE----- diff --git a/gruntconfig/clean.js b/gruntconfig/clean.js deleted file mode 100644 index d3262bca8545eb0247396318e5115f4a6806fc63..0000000000000000000000000000000000000000 --- a/gruntconfig/clean.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = { - pyc: [ - '**/*.pyc' - ] -}; diff --git a/gruntconfig/config.js b/gruntconfig/config.js deleted file mode 100644 index d14a9eff03ea528062df57f3babdb6b5d3dded97..0000000000000000000000000000000000000000 --- a/gruntconfig/config.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = { - bin: 'bin', - test: 'test' -}; diff --git a/gruntconfig/flake8.js b/gruntconfig/flake8.js deleted file mode 100644 index 2c664c628e288e4fe113d4902a9ae4ef565b6aec..0000000000000000000000000000000000000000 --- a/gruntconfig/flake8.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -module.exports = { - src: { - options: { - ignore: ['E122', 'E126', 'E127', 'E128', 'E131', 'E741'] - }, - src: [ - 'bin/*.py', - 'geomagio/**/*.py' - ] - }, - - test: { - options: { - ignore: ['E122', 'E126', 'E127', 'E128', 'E131', 'E741'] - }, - src: [ - 'test/**/*.py' - ] - } -}; diff --git a/gruntconfig/index.js b/gruntconfig/index.js deleted file mode 100644 index f34ee79c39ad80c02d8b92256d47c9ff660f9a45..0000000000000000000000000000000000000000 --- a/gruntconfig/index.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = { - clean: require('./clean'), - flake8: require('./flake8'), - jshint: require('./jshint'), - nose: require('./nose'), - watch: require('./watch'), - // task node module names - tasks: [ - 'grunt-contrib-clean', - 'grunt-contrib-jshint', - 'grunt-contrib-watch', - 'grunt-flake8', - 'grunt-nose' - ] -}; diff --git a/gruntconfig/jshint.js b/gruntconfig/jshint.js deleted file mode 100644 index 55f3379ba672997740bade69821c5d7048ccac71..0000000000000000000000000000000000000000 --- a/gruntconfig/jshint.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = { - options: { - jshintrc: '.jshintrc' - }, - gruntfile: [ - 'Gruntfile.js', - 'gruntconfig/**/*.js' - ] -}; diff --git a/gruntconfig/nose.js b/gruntconfig/nose.js deleted file mode 100644 index 33f27c51b552e47d665ba5d7d26fefda1384393e..0000000000000000000000000000000000000000 --- a/gruntconfig/nose.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = { - main: { - options: { - match: '[Tt]est', - verbose: true, - include: 'test/*/*.py' - } - } -}; diff --git a/gruntconfig/watch.js b/gruntconfig/watch.js deleted file mode 100644 index 5d360cb4a2eac8f61c89387cdd23889ac12c19e6..0000000000000000000000000000000000000000 --- a/gruntconfig/watch.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -module.exports = { - gruntfile: { - files: [ - 'Gruntfile.js', - 'gruntconfig/**/*.js' - ], - tasks: [ - 'jshint:gruntfile' - ] - }, - scripts: { - files: [ - 'bin/**/*.py', - 'geomagio/**/*.py' - ], - tasks: [ - 'flake8:src', - 'test' - ] - }, - tests: { - files: [ - 'test/**/*.py' - ], - tasks: [ - 'flake8:test', - 'test' - ] - } -}; diff --git a/package.json b/package.json index c842128ff0f409d4a4d53fb8153960008a44e4de..639ec38d9ec7db866a626ace4cd189a6ab3fb57b 100644 --- a/package.json +++ b/package.json @@ -19,18 +19,38 @@ "geomag", "hazdev" ], - "scripts": {}, + "scripts": { + "clean": "rimraf '**/*.pyc'", + "coverage": "nosetests --with-coverage --cover-package=geomagio --cover-xml", + "lint": "flake8 && echo \"No linting errors found\"", + "test": "nosetests -q test", + "watch": "npm-watch" + }, + "watch": { + "lint": { + "extensions": "py", + "patterns": [ + "bin", + "geomagio", + "test" + ] + }, + "test": { + "extensions": "py", + "patterns": [ + "bin", + "geomagio", + "test" + ] + } + }, "license": "Public Domain", "dependencies": {}, "devDependencies": { - "grunt": "^0.4.5", - "grunt-contrib-clean": "^0.7.0", - "grunt-contrib-jshint": "^0.10.0", - "grunt-contrib-watch": "^0.6.1", - "grunt-flake8": "^0.1.3", - "grunt-nose": "^0.4.0" + "npm-watch": "^0.3.0", + "rimraf": "^2.6.2" }, "engines": { - "node": ">=0.1.0" + "node": ">=4" } }