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

add iSort #68

Merged
merged 2 commits into from
May 1, 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
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
repos:
-
repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
language_version: python3.7
-
repo: 'https://github.com/psf/black'
rev: stable
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,15 @@ $ pip install -e .[dev]

**Python >=3.7 only**

This repo is set to use `pre-commit` to run *flake8*, *pydocstring*, *black* ("uncompromising Python code formatter") and mypy when committing new code.
This repo is set to use `pre-commit` to run *isort*, *flake8*, *pydocstring*, *black* ("uncompromising Python code formatter") and mypy when committing new code.

```
$ pre-commit install

$ git add .

$ git commit -m'my change'
isort....................................................................Passed
black....................................................................Passed
Flake8...................................................................Passed
Verifying PEP257 Compliance..............................................Passed
Expand Down
6 changes: 3 additions & 3 deletions cogeo_mosaic/backends/base.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""cogeo_mosaic.backend.base: base Backend class."""

from typing import Dict, List, Sequence

import abc
from contextlib import AbstractContextManager
from typing import Dict, List, Sequence

import mercantile
from cogeo_mosaic.mosaic import MosaicJSON

from cogeo_mosaic.backends.utils import get_hash
from cogeo_mosaic.mosaic import MosaicJSON
from cogeo_mosaic.utils import bbox_union


Expand Down
3 changes: 1 addition & 2 deletions cogeo_mosaic/backends/dynamodb.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""cogeo-mosaic AWS DynamoDB backend."""

from typing import Any, Dict, List, Optional, Union, Sequence

import functools
import itertools
import json
import os
import sys
import warnings
from decimal import Decimal
from typing import Any, Dict, List, Optional, Sequence, Union

import boto3
import click
Expand Down
7 changes: 3 additions & 4 deletions cogeo_mosaic/backends/file.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
"""cogeo-mosaic File backend."""

from typing import Any, Dict, List, Optional, Union

import json
import functools
import json
from typing import Any, Dict, List, Optional, Union

import mercantile

from cogeo_mosaic.mosaic import MosaicJSON
from cogeo_mosaic.backends.base import BaseBackend
from cogeo_mosaic.backends.utils import (
_compress_gz_json,
_decompress_gz,
get_assets_from_json,
)
from cogeo_mosaic.mosaic import MosaicJSON


class FileBackend(BaseBackend):
Expand Down
9 changes: 4 additions & 5 deletions cogeo_mosaic/backends/http.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"""cogeo-mosaic HTTP backend."""

from typing import Any, Dict, List, Optional, Union

import json
import functools
import json
from typing import Any, Dict, List, Optional, Union

import requests
import mercantile
import requests

from cogeo_mosaic.mosaic import MosaicJSON
from cogeo_mosaic.backends.base import BaseBackend
from cogeo_mosaic.backends.utils import _decompress_gz, get_assets_from_json
from cogeo_mosaic.mosaic import MosaicJSON


class HttpBackend(BaseBackend):
Expand Down
8 changes: 3 additions & 5 deletions cogeo_mosaic/backends/s3.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
"""cogeo-mosaic AWS S3 backend."""

from typing import Any, Dict, List, Optional, Union

import json
import functools
import json
from typing import Any, Dict, List, Optional, Union

import mercantile

from boto3.session import Session as boto3_session

from cogeo_mosaic.mosaic import MosaicJSON
from cogeo_mosaic.backends.base import BaseBackend
from cogeo_mosaic.backends.utils import (
_compress_gz_json,
_decompress_gz,
get_assets_from_json,
)
from cogeo_mosaic.mosaic import MosaicJSON


class S3Backend(BaseBackend):
Expand Down
3 changes: 1 addition & 2 deletions cogeo_mosaic/backends/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""cogeo-mosaic.backends utility functions."""

from typing import Any, Dict, List

import hashlib
import itertools
import json
import os
import zlib
from typing import Any, Dict, List

import mercantile

Expand Down
8 changes: 3 additions & 5 deletions cogeo_mosaic/mosaic.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
"""cogeo_mosaic.mosaic MosaicJSON models and helper functions."""

from typing import Any, Callable, Dict, List, Optional, Tuple, Sequence

import warnings
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple

import click
import mercantile
from pydantic import BaseModel, Field
from pygeos import STRtree, polygons, total_bounds
from supermercado import burntiles

from cogeo_mosaic.utils import get_footprints, _intersect_percent

from pydantic import BaseModel, Field
from cogeo_mosaic.utils import _intersect_percent, get_footprints


def default_accessor(feature: Dict):
Expand Down
17 changes: 6 additions & 11 deletions cogeo_mosaic/overviews.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
"""cogeo_mosaic.overviews: create low resolution image from a mosaic."""

from typing import Dict, Tuple

import random
from concurrent import futures
from typing import Dict, Tuple

import click

import mercantile
from affine import Affine
from supermercado.burntiles import tile_extrema

import rasterio
from affine import Affine
from rasterio.io import MemoryFile
from rasterio.windows import Window

from rio_tiler.io import cogeo
from rio_tiler_mosaic.mosaic import mosaic_tiler
from rio_tiler_mosaic.methods import defaults

from rio_cogeo.cogeo import cog_translate
from rio_cogeo.utils import _meters_per_pixel, has_mask_band
from rio_tiler.io import cogeo
from rio_tiler_mosaic.methods import defaults
from rio_tiler_mosaic.mosaic import mosaic_tiler
from supermercado.burntiles import tile_extrema

from cogeo_mosaic.backends import MosaicBackend
from cogeo_mosaic.utils import _filter_futures
Expand Down
15 changes: 7 additions & 8 deletions cogeo_mosaic/scripts/cli.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
"""Cogeo-mosaic: cli."""

import os
import json
import multiprocessing
from pkg_resources import iter_entry_points
import os

from click_plugins import with_plugins
import click
import cligj
from click_plugins import with_plugins
from pkg_resources import iter_entry_points
from rasterio.rio import options
from rio_cogeo.profiles import cog_profiles

from cogeo_mosaic import version as cogeo_mosaic_version
from cogeo_mosaic.utils import get_footprints
from cogeo_mosaic.mosaic import MosaicJSON
from cogeo_mosaic.backends import MosaicBackend
from cogeo_mosaic.mosaic import MosaicJSON
from cogeo_mosaic.overviews import create_low_level_cogs

from rasterio.rio import options
from rio_cogeo.profiles import cog_profiles
from cogeo_mosaic.utils import get_footprints


@with_plugins(iter_entry_points("cogeo_mosaic.plugins"))
Expand Down
14 changes: 5 additions & 9 deletions cogeo_mosaic/utils.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
"""cogeo_mosaic.utils: utility functions."""

from typing import Dict, List, Sequence

import logging
import os
import sys
import logging
from concurrent import futures
from typing import Dict, List, Sequence

import click

import numpy
from pygeos import intersection, area
import mercantile

import numpy
import rasterio
from rio_tiler.mercator import get_zooms
from pygeos import area, intersection
from rasterio.warp import transform_bounds

from rio_tiler.mercator import get_zooms

logger = logging.getLogger()
logger.setLevel(logging.INFO)
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Setup cogeo-mosaic."""

from setuptools import setup, find_packages

from setuptools import find_packages, setup

# Runtime requirements.
inst_reqs = [
Expand Down
13 changes: 5 additions & 8 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
"""Test backends."""

from typing import Dict, List

import os
import json
import os
import time
from io import BytesIO
from decimal import Decimal

import pytest
from io import BytesIO
from typing import Dict, List
from unittest.mock import patch

import pytest
from click.testing import CliRunner

from cogeo_mosaic.mosaic import MosaicJSON
from cogeo_mosaic.backends import MosaicBackend
from cogeo_mosaic.backends.dynamodb import DynamoDBBackend
from cogeo_mosaic.backends.file import FileBackend
from cogeo_mosaic.backends.http import HttpBackend
from cogeo_mosaic.backends.s3 import S3Backend
from cogeo_mosaic.backends.utils import _decompress_gz

from cogeo_mosaic.mosaic import MosaicJSON

mosaic_gz = os.path.join(os.path.dirname(__file__), "fixtures", "mosaic.json.gz")
mosaic_bin = os.path.join(os.path.dirname(__file__), "fixtures", "mosaic.bin")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_backends_utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Test backends utils."""

import json
import os
import re
import json

import mercantile
from cogeo_mosaic.backends import utils

from cogeo_mosaic.backends import utils

mosaic_gz = os.path.join(os.path.dirname(__file__), "fixtures", "mosaic.json.gz")
mosaic_json = os.path.join(os.path.dirname(__file__), "fixtures", "mosaic.json")
Expand Down
1 change: 0 additions & 1 deletion tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from cogeo_mosaic.mosaic import MosaicJSON, default_filter


basepath = os.path.join(os.path.dirname(__file__), "fixtures")
mosaic_gz = os.path.join(basepath, "mosaic.json.gz")
mosaic_json = os.path.join(basepath, "mosaic.json")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_overview.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""tests cogeo_mosaic.overview."""

import os
import json
from click.testing import CliRunner
import os

import rasterio
from click.testing import CliRunner
from rio_cogeo.profiles import cog_profiles

from cogeo_mosaic.mosaic import MosaicJSON
Expand Down
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ ignore = D203
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist
max-complexity = 15
max-line-length = 90

[tool:isort]
include_trailing_comma = True
multi_line_output = 3
line_length = 90
known_first_party = cogeo_mosaic
known_third_party = rasterio,rio_tiler,rio_cogeo,mercantile,supermercado,pygeos
default_section = THIRDPARTY