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

Lint the whole codebase and add coverage test. #317

Merged
merged 29 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5a0fbe0
Update pre-commit configuration
lsetiawan Apr 30, 2021
fa37344
Ignore tests and test_data for flake8
lsetiawan Apr 30, 2021
211d5d6
Isort ignore docs
lsetiawan Apr 30, 2021
b144859
Black and isort setup.py
lsetiawan Apr 30, 2021
2901c14
Move settings to setup.cfg
lsetiawan Apr 30, 2021
875b494
Moving some metadata to setup cfg
lsetiawan May 1, 2021
de614a9
Fix formatting in build system files
lsetiawan May 1, 2021
31c8323
Pre-commit ignore docs, run pre-commit-hooks only
lsetiawan May 1, 2021
af39756
Black and isort CI scripts
lsetiawan May 1, 2021
415584b
Allow label option to run all tests on PR
lsetiawan May 24, 2021
362fd89
Fix pr workflow yaml
lsetiawan May 24, 2021
9f0b220
Add coverage test
lsetiawan May 24, 2021
b2e5340
Add codecov upload for coverage test
lsetiawan May 24, 2021
96f0add
Remove notebooks
lsetiawan May 24, 2021
8e67ae4
Run pre-commit on non ep code
lsetiawan May 24, 2021
cd8d402
Update pre-commit settings and run on ep code
lsetiawan May 24, 2021
033b8a8
Add function to correct ping_time reversal (#297)
leewujung May 24, 2021
9cc36e2
Flake8 ep code
lsetiawan May 24, 2021
e7c75ef
Don't allow linting error anymore
lsetiawan May 24, 2021
ad84540
Merge branch 'dev' of https://github.com/OSOceanAcoustics/echopype in…
lsetiawan May 24, 2021
a431d0c
Lint latest qc module
lsetiawan May 24, 2021
6ea1368
Fix setup requirement to match current
lsetiawan May 24, 2021
d8c9978
Merge branch 'master' of https://github.com/OSOceanAcoustics/echopype…
lsetiawan May 25, 2021
8725b90
Merge branch 'dev' of https://github.com/OSOceanAcoustics/echopype in…
lsetiawan May 25, 2021
3fa0f15
Fix a couple of formatting issues
lsetiawan May 28, 2021
be9587c
Run all CI test on dev branch also
lsetiawan May 28, 2021
83d15c1
Merge branch 'dev' of https://github.com/OSOceanAcoustics/echopype in…
lsetiawan May 28, 2021
0e3fc3f
Fix eof lint issue
lsetiawan May 28, 2021
6a06fa1
A couple more linting modifications
lsetiawan May 28, 2021
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
1 change: 0 additions & 1 deletion .ci_helpers/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ services:
- echopypenetwork
networks:
echopypenetwork:

2 changes: 1 addition & 1 deletion .ci_helpers/docker/http.dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM httpd:2.4

COPY echopype/test_data /usr/local/apache2/htdocs/data
COPY echopype/test_data /usr/local/apache2/htdocs/data
2 changes: 1 addition & 1 deletion .ci_helpers/docker/minioci.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM minio/minio
# Install git
RUN microdnf install git

CMD ["minio", "server", "/data"]
CMD ["minio", "server", "/data"]
16 changes: 9 additions & 7 deletions .ci_helpers/docker/setup-services.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
Script to help bring up docker services for testing.

"""
import argparse
import os
import shutil
import sys
from pathlib import Path
import argparse

HERE = Path('.').absolute()
HERE = Path(".").absolute()
BASE = Path(__file__).parent.absolute()
COMPOSE_FILE = BASE / "docker-compose.yaml"
TEST_DATA_PATH = HERE / "echopype" / "test_data"


def parse_args():
parser = argparse.ArgumentParser(description='Setup services for testing')
parser = argparse.ArgumentParser(description="Setup services for testing")
parser.add_argument(
'--deploy', action='store_true', help="Flag to setup docker services"
"--deploy", action="store_true", help="Flag to setup docker services"
)
parser.add_argument(
'--tear-down',
action='store_true',
"--tear-down",
action="store_true",
help="Flag to tear down docker services",
)

Expand All @@ -48,7 +48,9 @@ def parse_args():
os.system(f"docker-compose -f {COMPOSE_FILE} pull")

print("3) Bringing up services.")
os.system(f"docker-compose -f {COMPOSE_FILE} up -d --remove-orphans --force-recreate")
os.system(
f"docker-compose -f {COMPOSE_FILE} up -d --remove-orphans --force-recreate"
)

print(f"4) Deleting old test folder at {TEST_DATA_PATH}")
if TEST_DATA_PATH.exists():
Expand Down
2 changes: 1 addition & 1 deletion .ci_helpers/py3.7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencies:
- requests
- aiohttp
- s3fs==0.5.2
- mamba
- mamba
2 changes: 1 addition & 1 deletion .ci_helpers/py3.8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencies:
- requests
- aiohttp
- s3fs==0.5.2
- mamba
- mamba
2 changes: 1 addition & 1 deletion .ci_helpers/py3.9.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencies:
- requests
- aiohttp
- s3fs==0.5.2
- mamba
- mamba
2 changes: 1 addition & 1 deletion .ci_helpers/run-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
type=str,
nargs="?",
default="",
help="Comma separated list of changed files."
help="Comma separated list of changed files.",
)
parser.add_argument(
"--pytest-args", type=str, help="Optional pytest args", default=""
Expand Down
1 change: 0 additions & 1 deletion .ci_helpers/user_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ dependencies:
- echopype
- dask
- pandas

8 changes: 8 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[run]
omit =
*/echopype/tests/*
*/echopype/test_data/*
*/echopype/process/*
*/echopype/convert/add_ancillary.py
*/echopype/convert/convert_combine.py
*/echopype/visualize/*
2 changes: 1 addition & 1 deletion .github/actions/gdrive-rclone/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: 'GDrive Rclone'
description: 'Performs RClone from a google drive folder'
runs:
using: 'docker'
image: 'Dockerfile'
image: 'Dockerfile'
3 changes: 1 addition & 2 deletions .github/actions/gdrive-rclone/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ then
echo "Copying new test data from google drive"
rclone copy gdrive: $TEST_DATA_FOLDER
echo "Done"

chmod -R ugoa+w $TEST_DATA_FOLDER
ls -lah $TEST_DATA_FOLDER
else
echo "${TEST_DATA_FOLDER} not found"
fi

14 changes: 13 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- dev
paths-ignore: [".ci_helpers/docker/**", "**/docker.yaml"]
workflow_dispatch:

Expand Down Expand Up @@ -49,6 +50,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Set environment variables
run: |
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
- name: Cache conda
uses: actions/cache@v2
env:
Expand Down Expand Up @@ -83,10 +87,18 @@ jobs:
- name: Running All Tests
shell: bash -l {0}
run: |
python .ci_helpers/run-test.py --local --pytest-args="--log-cli-level=WARNING,-vv,--disable-warnings" |& tee ci_test_log.log
python .ci_helpers/run-test.py --local --pytest-args="--cov=echopype,--cov-report=xml,--log-cli-level=WARNING,-vv,--disable-warnings" |& tee ci_test_log.log
- name: Upload ci test log
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v2
with:
name: ci_test_log
path: ci_test_log.log
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
env_vars: RUNNER_OS,PYTHON_VERSION
name: codecov-umbrella
fail_ci_if_error: false
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
# allow to error for now
continue-on-error: true
19 changes: 18 additions & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Set environment variables
run: |
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
- name: Cache conda
uses: actions/cache@v2
env:
Expand Down Expand Up @@ -85,13 +88,27 @@ jobs:
- name: Print Changed files
shell: bash -l {0}
run: echo "${{ steps.files.outputs.added_modified }}"
- name: Running all Tests
if: contains(github.event.pull_request.labels.*.name, 'Needs Complete Testing')
shell: bash -l {0}
run: |
python .ci_helpers/run-test.py --local --pytest-args="--cov=echopype,--cov-report=xml,--log-cli-level=WARNING,-vv,--disable-warnings" |& tee ci_test_log.log
- name: Running Tests
if: "!contains(github.event.pull_request.labels.*.name, 'Needs Complete Testing')"
shell: bash -l {0}
run: |
python .ci_helpers/run-test.py --pytest-args="--log-cli-level=WARNING,-vv,--disable-warnings" ${{ steps.files.outputs.added_modified }} |& tee ci_test_log.log
python .ci_helpers/run-test.py --pytest-args="--cov=echopype,--cov-report=xml,--log-cli-level=WARNING,-vv,--disable-warnings" ${{ steps.files.outputs.added_modified }} |& tee ci_test_log.log
- name: Upload ci test log
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v2
with:
name: ci_test_log
path: ci_test_log.log
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
env_vars: RUNNER_OS,PYTHON_VERSION
name: codecov-umbrella
fail_ci_if_error: false
6 changes: 3 additions & 3 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
# local part of the version isn't included, making the version string
# compatible with PyPI.
sed --in-place "s/node-and-date/no-local-version/g" setup.py

- name: Build source and wheel distributions
run: |
python setup.py sdist bdist_wheel
Expand Down Expand Up @@ -84,14 +84,14 @@ jobs:
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre echopype
python -c "import echopype; print(echopype.__version__)"
echo "=== Done testing wheel file ==="

echo "=== Testing source tar file ==="
# Install tar gz and check import
python -m pip uninstall --yes echopype
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre --no-binary=:all: echopype
python -c "import echopype; print(echopype.__version__)"
echo "=== Done testing source tar file ==="

publish-pypi:
name: Push echopype to production pypi
needs: test-built-dist
Expand Down
55 changes: 27 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
exclude: |
(?x)^(
docs/|
echopype/tests/|
echopype/test_data/|
echopype/process/|
echopype/visualize/|
echopype/convert/add_ancillary.py|
echopype/convert/convert_combine.py
)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-json
- id: check-yaml
- id: pretty-format-json
args: ["--autofix", "--indent=2", "--no-sort-keys"]
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-json
- id: check-yaml
- id: pretty-format-json
args: ["--autofix", "--indent=2", "--no-sort-keys"]

- repo: https://github.com/ambv/black
rev: 19.10b0
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: ["--line-length", "100"]
- id: black

- repo: https://gitlab.com/pycqa/flake8
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
- id: flake8

- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
- repo: https://github.com/PyCQA/isort
rev: 5.8.0
hooks:
- id: seed-isort-config

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.2.0
hooks:
- id: isort

- repo: https://github.com/myint/rstcheck
rev: master
hooks:
- id: rstcheck
- id: isort
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

Echopype is a package built to enable interoperability and scalability in ocean sonar data processing. These data are widely used for obtaining information about the distribution and abundance of marine animals, such as fish and krill. Our ability to collect large volumes of sonar data from a variety of ocean platforms has grown significantly in the last decade. However, most of the new data remain under-utilized. echopype aims to address the root cause of this problem - the lack of interoperable data format and scalable analysis workflows that adapt well with increasing data volume - by providing open-source tools as entry points for scientists to make discovery using these new data.

Watch the [echopype talk](https://www.youtube.com/watch?v=qboH7MyHrpU)
Watch the [echopype talk](https://www.youtube.com/watch?v=qboH7MyHrpU)
at SciPy 2019 for background, discussions and a quick demo!

## Documentation
Expand All @@ -53,7 +53,7 @@ Please report any bugs by [creating issues on GitHub](https://medium.com/nyc-pla
Contributors
------------

[Wu-Jung Lee](http://leewujung.github.io) (@leewujung) leads this project and together with
[Wu-Jung Lee](http://leewujung.github.io) (@leewujung) leads this project and together with
[Kavin Nguyen](https://github.com/ngkavin) (@ngkavin), [Landung "Don" Setiawan](https://github.com/lsetiawan) (@lsetiawan), and [Imran Majeed](https://github.com/imranmaj) (@imranmaj) are primary developers of this package.
[Emilio Mayorga](https://www.apl.washington.edu/people/profile.php?last_name=Mayorga&first_name=Emilio) (@emiliom)
and [Valentina Staneva](https://escience.washington.edu/people/valentina-staneva/) (@valentina-s)
Expand Down
9 changes: 5 additions & 4 deletions echopype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import absolute_import, division, print_function
from .convert.api import open_raw
from .echodata.api import open_converted
from .process import Process
from . import calibrate

from _echopype_version import version as __version__ # noqa

from . import calibrate
from .convert.api import open_raw
from .echodata.api import open_converted
from .process import Process # noqa

__all__ = [open_raw, open_converted, calibrate]
4 changes: 2 additions & 2 deletions echopype/calibrate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .api import compute_Sv, compute_Sp
from .api import compute_Sp, compute_Sv

# __all__ = [compute_Sv, compute_Sp]
__all__ = [compute_Sv, compute_Sp]
Loading