From 89d4d16acd08ca7a0a9507491fe02162353b8310 Mon Sep 17 00:00:00 2001 From: Scott Staniewicz Date: Wed, 8 Nov 2023 20:46:24 -0500 Subject: [PATCH] switch over to `opera-utils` package --- .pre-commit-config.yaml | 20 ++++++-------------- conda-env.yml | 2 ++ requirements.txt | 1 + scripts/prep_mintpy.py | 2 +- src/sweets/_geometry.py | 2 +- src/sweets/_missing_data.py | 2 +- src/sweets/core.py | 2 +- src/sweets/interferogram.py | 4 ++-- tests/requirements.txt | 1 + 9 files changed, 16 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 16430c7..27721b7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,21 +19,13 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - - repo: https://github.com/psf/black - rev: "23.10.1" + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.2 hooks: - - id: black - - id: black-jupyter - - - repo: https://github.com/PyCQA/flake8 - rev: "6.1.0" - hooks: - - id: flake8 - - - repo: https://github.com/PyCQA/isort - rev: "5.12.0" - hooks: - - id: isort + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + types_or: [python, jupyter] + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: "v1.6.1" diff --git a/conda-env.yml b/conda-env.yml index f571d80..3aa5d7e 100644 --- a/conda-env.yml +++ b/conda-env.yml @@ -13,6 +13,7 @@ dependencies: # - gdal>=3.5 # - h5py>=3.6 # - numpy>=1.20 + # - opera-utils>=0.1.1 # - pydantic>=2.1 # - requests>=2.20 # - rich>=12.0 @@ -28,6 +29,7 @@ dependencies: - gdal - h5py - numpy + - opera-utils - pydantic>2.1 - pyproj>=3.3 - python-dateutil diff --git a/requirements.txt b/requirements.txt index ec52046..11a0809 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ dask>=2022.6.0 h5py>=3.6 numpy>=1.20 +opera-utils>0.1.1 pandas pydantic>=2 pyproj>=3.2 diff --git a/scripts/prep_mintpy.py b/scripts/prep_mintpy.py index 2ba04e5..3d23639 100755 --- a/scripts/prep_mintpy.py +++ b/scripts/prep_mintpy.py @@ -18,10 +18,10 @@ import numpy as np import pyproj from dolphin import io -from dolphin.opera_utils import OPERA_DATASET_ROOT from dolphin.utils import full_suffix, get_dates from mintpy.utils import arg_utils, ptime, readfile, writefile from mintpy.utils.utils0 import calc_azimuth_from_east_north_obs +from opera_utils import OPERA_DATASET_ROOT #################################################################################### EXAMPLE = """example: diff --git a/src/sweets/_geometry.py b/src/sweets/_geometry.py index 0892973..0f2b9c1 100644 --- a/src/sweets/_geometry.py +++ b/src/sweets/_geometry.py @@ -6,7 +6,7 @@ import rasterio as rio from dolphin import io, stitching from dolphin._types import Bbox -from dolphin.opera_utils import group_by_burst +from opera_utils import group_by_burst from ._log import get_log from ._types import Filename diff --git a/src/sweets/_missing_data.py b/src/sweets/_missing_data.py index 167e1c7..7083f12 100644 --- a/src/sweets/_missing_data.py +++ b/src/sweets/_missing_data.py @@ -40,7 +40,7 @@ def get_geodataframe( """ gslc_files = list(gslc_files) # make sure generator doesn't deplete after first run if one_per_burst: - from dolphin.opera_utils import group_by_burst + from opera_utils import group_by_burst burst_to_file_list = group_by_burst(gslc_files) slc_files = [file_list[0] for file_list in burst_to_file_list.values()] diff --git a/src/sweets/core.py b/src/sweets/core.py index 009d474..df720db 100644 --- a/src/sweets/core.py +++ b/src/sweets/core.py @@ -10,9 +10,9 @@ from dolphin import io, stitching, unwrap from dolphin._types import Bbox from dolphin.interferogram import Network -from dolphin.opera_utils import group_by_burst from dolphin.utils import group_by_date, set_num_threads from dolphin.workflows.config import YamlModel +from opera_utils import group_by_burst from pydantic import ConfigDict, Field, field_validator, model_validator from shapely import geometry, wkt diff --git a/src/sweets/interferogram.py b/src/sweets/interferogram.py index 440f2a8..3ab24a3 100644 --- a/src/sweets/interferogram.py +++ b/src/sweets/interferogram.py @@ -15,7 +15,7 @@ from dask.distributed import Client from dolphin import utils from dolphin.io import DEFAULT_HDF5_OPTIONS, get_raster_xysize, load_gdal, write_arr -from dolphin.opera_utils import OPERA_DATASET_NAME +from opera_utils import OPERA_DATASET_NAME from pydantic import BaseModel, Field, model_validator from rich.progress import track @@ -267,7 +267,7 @@ def _get_cli_args(): parser = argparse.ArgumentParser() parser.add_argument( "--slcs", nargs=2, metavar=("ref_slc_file", "sec_slc_file"), required=True - ), + ) parser.add_argument("--dset", default=OPERA_DATASET_NAME) parser.add_argument("-l", "--looks", type=int, nargs=2, default=(1, 1)) parser.add_argument( diff --git a/tests/requirements.txt b/tests/requirements.txt index 9b14878..d163904 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -4,3 +4,4 @@ pre-commit pytest pytest-cov pytest-xdist # parallel tests: https://pytest-xdist.readthedocs.io/en/latest/ +ruff