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

fix isort lint github actions workflow #21

Merged
merged 1 commit into from
Jan 22, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install isort black flake8
# - name: isort
# run: python -m isort . --check --diff
- name: isort
run: python -m isort . --check --diff
# - name: black
# run: python -m black --check --diff .
# - name: flake8
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ testpaths = [
addopts = [
"--import-mode=importlib",
]

[tool.isort]
profile = "black"
2 changes: 1 addition & 1 deletion src/openeo_gfmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .backend import Backend, BackendContext
from .metadata import FakeMetadata
from .spatial import SpatialContext, BoundingBoxExtent
from .spatial import BoundingBoxExtent, SpatialContext
from .temporal import TemporalContext

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion src/openeo_gfmap/fetching/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"""

from .fetching import CollectionFetcher, FetchType
from .s2 import build_sentinel2_l2a_extractor
from .s1 import build_sentinel1_grd_extractor
from .s2 import build_sentinel2_l2a_extractor

__all__ = [
"build_sentinel2_l2a_extractor", "CollectionFetcher", "FetchType",
Expand Down
7 changes: 3 additions & 4 deletions src/openeo_gfmap/fetching/s1.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
""" Collection fetching of S1 features, supporting different backends.
"""
from typing import Callable
from functools import partial
from typing import Callable

import openeo
from geojson import GeoJSON

from openeo_gfmap.backend import Backend, BackendContext
from openeo_gfmap.spatial import SpatialContext, BoundingBoxExtent
from openeo_gfmap.spatial import BoundingBoxExtent, SpatialContext
from openeo_gfmap.temporal import TemporalContext

from .fetching import CollectionFetcher, FetchType

from .commons import (
convert_band_names,
load_collection,
rename_bands,
resample_reproject,
)
from .fetching import CollectionFetcher, FetchType

BASE_SENTINEL1_GRD_MAPPING = {
"VH": "S1-VH",
Expand Down
9 changes: 7 additions & 2 deletions src/openeo_gfmap/preprocessing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
right after the extraction and the execution of the features UDF.
"""

from openeo_gfmap.preprocessing.cloudmasking import mask_scl_dilation, get_bap_score, bap_masking, get_bap_mask
from openeo_gfmap.preprocessing.cloudmasking import (
bap_masking,
get_bap_mask,
get_bap_score,
mask_scl_dilation,
)
from openeo_gfmap.preprocessing.compositing import mean_compositing, median_compositing
from openeo_gfmap.preprocessing.interpolation import linear_interpolation
from openeo_gfmap.preprocessing.compositing import median_compositing, mean_compositing

__all__ = [
"mask_scl_dilation",
Expand Down
3 changes: 2 additions & 1 deletion src/openeo_gfmap/preprocessing/cloudmasking.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Different cloud masking strategies for an OpenEO datacubes."""

from typing import Union
from pathlib import Path
from typing import Union

import openeo
from openeo.processes import if_, is_nan

Expand Down
1 change: 1 addition & 0 deletions src/openeo_gfmap/preprocessing/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import openeo


def linear_interpolation(cube: openeo.DataCube,) -> openeo.DataCube:
"""Perform linear interpolation on the given datacube."""
return cube.apply_dimension(
Expand Down
5 changes: 3 additions & 2 deletions src/openeo_gfmap/preprocessing/udf_rank.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import xarray as xr
from pathlib import Path
import numpy as np

import numpy as np
import xarray as xr
from openeo.udf import XarrayDataCube


def apply_datacube(cube: XarrayDataCube, context: dict) -> XarrayDataCube:
"""For a cube having the BAP score, and a given period of list of intervals,
create a binary mask that for each pixel, is True if the BAP score is the
Expand Down
13 changes: 6 additions & 7 deletions src/openeo_gfmap/preprocessing/udf_score.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import numpy as np
import time, math
import xarray as xr
import datetime
import math
import time

from scipy.ndimage import distance_transform_cdt
from skimage.morphology import footprints
from skimage.morphology import binary_erosion, binary_dilation
import numpy as np
import xarray as xr
from openeo.udf import XarrayDataCube
from scipy.ndimage import distance_transform_cdt
from skimage.morphology import binary_dilation, binary_erosion, footprints
from xarray.ufuncs import isnan as ufuncs_isnan



def apply_datacube(cube: XarrayDataCube, context: dict) -> XarrayDataCube:

cube_array: xr.DataArray = cube.get_array()
Expand Down
3 changes: 1 addition & 2 deletions src/openeo_gfmap/spatial.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
""" Definitions of spatial context, either point-based or spatial"""
from dataclasses import dataclass
from typing import Union
from typing import Dict, Union

from geojson import GeoJSON
from typing import Dict


@dataclass
Expand Down
3 changes: 1 addition & 2 deletions src/openeo_gfmap/temporal.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
""" Definitions of temporal context"""
from dataclasses import dataclass
from typing import Tuple

from datetime import datetime
from typing import Tuple


@dataclass
Expand Down
6 changes: 3 additions & 3 deletions src/openeo_gfmap/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""This sub-module contains utilitary function and tools for OpenEO-GFMap"""

from openeo_gfmap.utils.build_df import load_json
from openeo_gfmap.utils.intervals import quintad_intervals
from openeo_gfmap.utils.tile_processing import (
array_bounds,
arrays_cosine_similarity,
normalize_array,
select_optical_bands,
array_bounds,
select_sar_bands,
arrays_cosine_similarity
)
from openeo_gfmap.utils.intervals import quintad_intervals

__all__ = [
"load_json", "normalize_array", "select_optical_bands", "array_bounds",
Expand Down
5 changes: 3 additions & 2 deletions src/openeo_gfmap/utils/catalogue.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Functionalities to interract with product catalogues."""
import requests

from shapely.geometry import shape
from geojson import GeoJSON
from shapely.geometry import shape

from openeo_gfmap import SpatialContext, TemporalContext


def _check_cdse_catalogue(
collection: str,
spatial_extent: SpatialContext,
Expand Down
4 changes: 2 additions & 2 deletions src/openeo_gfmap/utils/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
methods.
"""

from openeo_gfmap import TemporalContext

from datetime import datetime, timedelta

from openeo_gfmap import TemporalContext


def quintad_intervals(temporal_extent: TemporalContext) -> list:
""" Returns a list of tuples (start_date, end_date) of quintad intervals
Expand Down
3 changes: 2 additions & 1 deletion src/openeo_gfmap/utils/tile_processing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Utilitaries to process data tiles."""

import xarray as xr
import numpy as np
import xarray as xr


def normalize_array(
inarr: xr.DataArray,
Expand Down
14 changes: 7 additions & 7 deletions tests/test_openeo_gfmap/test_cloud_masking.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from pathlib import Path

from typing import Union

import pytest

from openeo_gfmap.backend import Backend, BackendContext, BACKEND_CONNECTIONS
from openeo_gfmap.temporal import TemporalContext
from openeo_gfmap.spatial import BoundingBoxExtent
from openeo_gfmap.backend import BACKEND_CONNECTIONS, Backend, BackendContext
from openeo_gfmap.fetching import FetchType, build_sentinel2_l2a_extractor

from openeo_gfmap.preprocessing import (
get_bap_score, bap_masking, median_compositing, get_bap_mask
bap_masking,
get_bap_mask,
get_bap_score,
median_compositing,
)

from openeo_gfmap.spatial import BoundingBoxExtent
from openeo_gfmap.temporal import TemporalContext
from openeo_gfmap.utils import quintad_intervals

backends = [Backend.TERRASCOPE, Backend.CDSE]
Expand Down
3 changes: 2 additions & 1 deletion tests/test_openeo_gfmap/test_intervals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from openeo_gfmap.utils import quintad_intervals
from openeo_gfmap.temporal import TemporalContext
from openeo_gfmap.utils import quintad_intervals


def test_quintad_january():
start_date = "2023-01-01"
Expand Down
33 changes: 19 additions & 14 deletions tests/test_openeo_gfmap/test_s1_fetchers.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
""" Test the data extractors for Sentinel1 data. """
from pathlib import Path

import pytest

import geojson
import openeo
import geopandas as gpd
import xarray as xr
import openeo
import pytest
import rioxarray
import xarray as xr

from openeo_gfmap.backend import BACKEND_CONNECTIONS
from openeo_gfmap import (
SpatialContext, TemporalContext, Backend, BackendContext, BoundingBoxExtent
Backend,
BackendContext,
BoundingBoxExtent,
SpatialContext,
TemporalContext,
)

from openeo_gfmap.backend import BACKEND_CONNECTIONS
from openeo_gfmap.fetching import (
CollectionFetcher, build_sentinel1_grd_extractor, FetchType
CollectionFetcher,
FetchType,
build_sentinel1_grd_extractor,
)

from openeo_gfmap.utils import (
array_bounds, normalize_array, select_sar_bands, arrays_cosine_similarity,
load_json
array_bounds,
arrays_cosine_similarity,
load_json,
normalize_array,
select_sar_bands,
)

# Retrieve the test parameters from the s2 fetcher tests
from .test_s2_fetchers import (
test_configurations, test_backends, POINT_EXTRACTION_DF
)
from .test_s2_fetchers import POINT_EXTRACTION_DF, test_backends, test_configurations


class TestS1Extractors:
"""Build collection extractor for different S1 collections on different
Expand Down
10 changes: 8 additions & 2 deletions tests/test_openeo_gfmap/test_s2_fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@
import rioxarray
import xarray as xr

from openeo_gfmap import SpatialContext, TemporalContext, BoundingBoxExtent
from openeo_gfmap import BoundingBoxExtent, SpatialContext, TemporalContext
from openeo_gfmap.backend import BACKEND_CONNECTIONS, Backend, BackendContext
from openeo_gfmap.fetching import (
CollectionFetcher,
FetchType,
build_sentinel2_l2a_extractor,
)
from openeo_gfmap.utils import load_json, normalize_array, select_optical_bands, array_bounds, arrays_cosine_similarity
from openeo_gfmap.utils import (
array_bounds,
arrays_cosine_similarity,
load_json,
normalize_array,
select_optical_bands,
)

# Fields close to TAP, Belgium
SPATIAL_EXTENT_1 = {
Expand Down
Loading