Skip to content

Commit

Permalink
Merge pull request #91 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release v0.5.1
  • Loading branch information
AndrewPlayer3 authored Dec 17, 2024
2 parents f5e05c5 + 4075066 commit c18e5bc
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 22 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ jobs:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected]

call-flake8-workflow:
call-ruff-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected]
with:
local_package_names: opera_rtc_s1_browse
uses: ASFHyP3/actions/.github/workflows/[email protected]
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.1]

### Changed
- The [`static-analysis`](.github/workflows/static-analysis.yml) Github Actions workflow now uses `ruff` rather than `flake8` for linting.

## [0.5.0]

### Added
Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ channels:
dependencies:
- python=3.11
- pip
- gdal=3.9.3
- gdal=3.10.0
- numpy=2.1.2
- ruff
- pytest=8.3.3
- pytest-cov=5.0.0
- setuptools_scm=8.1.0
Expand Down
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,30 @@ dependencies = {file = ["requirements.txt"]}
where = ["src"]

[tool.setuptools_scm]

[tool.ruff]
line-length = 120
src = ["src", "tests"]

[tool.ruff.format]
indent-style = "space"
quote-style = "single"

[tool.ruff.lint]
extend-select = [
"I", # isort: https://docs.astral.sh/ruff/rules/#isort-i
"UP", # pyupgrade: https://docs.astral.sh/ruff/rules/#pyupgrade-up

# TODO: uncomment the following extensions and address their warnings:
#"D", # pydocstyle: https://docs.astral.sh/ruff/rules/#pydocstyle-d
#"ANN", # annotations: https://docs.astral.sh/ruff/rules/#flake8-annotations-ann

"PTH", # use-pathlib-pth: https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
]

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.lint.isort]
case-sensitive = true
lines-after-imports = 2
11 changes: 6 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# duplicated in environment.yml
gdal[numpy]==3.9.3
harmony-service-lib==2.2.0
numpy==2.1.2
gdal[numpy]==3.10
harmony-service-lib==2.3.0
numpy==2.2.0
pystac==1.11.0
pytest==8.3.3
pytest-cov==5.0.0
pytest==8.3.4
pytest-cov==6.0.0
setuptools_scm==8.1.0
ruff
4 changes: 2 additions & 2 deletions src/opera_rtc_s1_browse/create_browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def normalize_image_array(input_array: np.ndarray, vmin: float, vmax: float) ->
vmin: The minimum value to normalize to (mapped to 0).
vmax: The maximum value to normalize to (mapped to 255).
Returns
Returns:
The normalized array.
"""
input_array = input_array.astype(float)
Expand Down Expand Up @@ -104,7 +104,7 @@ def main():
parser.add_argument('cross_pol_path', type=Path, help='Path to the cross-polarized (VH) image')
args = parser.parse_args()

create_browse_image(args.co_pol_path, args.cross_pol_path, Path('.'))
create_browse_image(args.co_pol_path, args.cross_pol_path, Path())


if __name__ == '__main__':
Expand Down
9 changes: 3 additions & 6 deletions src/opera_rtc_s1_browse/harmony_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@


class HarmonyAdapter(harmony_service_lib.BaseHarmonyAdapter):

def process_item(self, item: pystac.Item, source: harmony_service_lib.message.Source | None = None) -> pystac.Item:
"""
Processes a single input item.
"""Processes a single input item.
Parameters
----------
Expand All @@ -22,7 +20,7 @@ def process_item(self, item: pystac.Item, source: harmony_service_lib.message.So
source : harmony_service_lib.message.Source
the input source defining the variables, if any, to subset from the item
Returns
Returns:
-------
pystac.Item
a STAC catalog whose metadata and assets describe the service output
Expand All @@ -33,7 +31,6 @@ def process_item(self, item: pystac.Item, source: harmony_service_lib.message.So
cross_pol_url = get_asset_url(item, '_VH.tif')

with tempfile.TemporaryDirectory() as temp_dir:

co_pol_filename = harmony_service_lib.util.download(
url=co_pol_url,
destination_dir=temp_dir,
Expand Down Expand Up @@ -81,5 +78,5 @@ def main() -> None:
harmony_service_lib.run_cli(parser, args, HarmonyAdapter)


if __name__ == "__main__":
if __name__ == '__main__':
main()
9 changes: 5 additions & 4 deletions tests/test_harmony_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ def test_process_item():
)
},
)
with patch('harmony_service_lib.util.download', mock_download), \
patch('opera_rtc_s1_browse.create_browse.create_browse_image', mock_create_browse_image), \
patch('harmony_service_lib.util.stage', mock_stage):

with (
patch('harmony_service_lib.util.download', mock_download),
patch('opera_rtc_s1_browse.create_browse.create_browse_image', mock_create_browse_image),
patch('harmony_service_lib.util.stage', mock_stage),
):
assert adapter.process_item(item).to_dict() == expected_result.to_dict()


Expand Down

0 comments on commit c18e5bc

Please sign in to comment.