Skip to content

Commit

Permalink
Merge pull request #294 from podaac/release/2.12.0
Browse files Browse the repository at this point in the history
Release 2.12.0
  • Loading branch information
jamesfwood authored Nov 13, 2024
2 parents 4fe5875 + 014ed6c commit 94f67d7
Show file tree
Hide file tree
Showing 8 changed files with 1,196 additions and 1,080 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/build-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Poetry
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
- name: Build Python Artifact
run: |
poetry build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: python-artifact
path: dist/*
Expand Down Expand Up @@ -244,7 +244,7 @@ jobs:
steps.pypi-test-publish.conclusion == 'success' ||
steps.pypi-publish.conclusion == 'success'
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
Expand All @@ -261,7 +261,7 @@ jobs:
if: |
steps.pypi-test-publish.conclusion == 'success' ||
steps.pypi-publish.conclusion == 'success'
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
Expand Down Expand Up @@ -307,3 +307,15 @@ jobs:
working-directory: deployment
run:
poetry run python harmony_deploy.py --tag ${{ env.software_version }}

- name: Create Release
id: create_release
if: |
github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v2
with:
tag_name: "${{ env.software_version }}" # Use the tag that triggered the action
release_name: Release v{{ env.software_version }}
draft: false
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ confidence=
disable=too-many-lines,
too-many-arguments,
too-many-locals,
no-member
no-member,
too-many-positional-arguments,
too-many-statements

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security


## [2.12.0]
### Added
- Added custom exception to progate error messages to harmony.
- Added an automated release step for main branch in github actions.
- Handle OB.DAAC files, which do not have time variables
- Update harmony library from 1.0 to 2.0 which changes the import harmony structure
### Changed
### Deprecated
### Removed
### Fixed
### Security


## [2.11.0]
### Added
- [issue/267](https://github.com/podaac/l2ss-py/pull/261): Add xtrack and atrack dimension options for get_nd_indexers when bounding box subsetting is performed on SNDR.
Expand Down
4 changes: 4 additions & 0 deletions podaac/subsetter/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ def compute_time_variable_name(dataset: xr.Dataset, lat_var: xr.Variable, total_
if var_name not in total_time_vars and 'time' in var_name_time.lower() and dataset[var_name].squeeze().dims[0] in lat_var.squeeze().dims:
return var_name

# OB.DAAC data does not have a time variable. Returning the following field of a composite time value to avoid exceptions.
if '__scan_line_attributes__day' in dataset.data_vars:
return '__scan_line_attributes__day'

raise ValueError('Unable to determine time variable')


Expand Down
40 changes: 32 additions & 8 deletions podaac/subsetter/subset_harmony.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,44 @@
import subprocess
import shutil
from tempfile import mkdtemp
import traceback
from typing import List, Union

import pystac
from pystac import Asset

import harmony
import harmony_service_lib
import numpy as np
from harmony import BaseHarmonyAdapter
from harmony.util import download, stage, generate_output_filename, bbox_to_geometry
from harmony_service_lib import BaseHarmonyAdapter
from harmony_service_lib.util import download, stage, generate_output_filename, bbox_to_geometry
from harmony_service_lib.exceptions import HarmonyException

from podaac.subsetter import subset
from podaac.subsetter.subset import SERVICE_NAME

DATA_DIRECTORY_ENV = "DATA_DIRECTORY"


class L2SSException(HarmonyException):
"""Base class for exceptions in the Harmony GDAL Adapter."""

def __init__(self, original_exception):
# Extract the last traceback entry (most recent call) for the error location
tb = traceback.extract_tb(original_exception.__traceback__)[-1]

# Get the error details: file, line, function, and message
filename = tb.filename
lineno = tb.lineno
funcname = tb.name
error_msg = str(original_exception)

# Format the error message to be more readable
readable_message = (f"Error in file '{filename}', line {lineno}, in function '{funcname}': "
f"{error_msg}")

super().__init__(readable_message, 'nasa/harmony-gdal-adapter')


def podaac_to_harmony_bbox(bbox: np.ndarray) -> Union[np.ndarray, float]:
"""
Convert PO.DAAC bbox ((west, east), (south, north))
Expand Down Expand Up @@ -89,7 +111,7 @@ def __init__(self, message, catalog=None, config=None):

self.data_dir = os.getenv(DATA_DIRECTORY_ENV, '/home/dockeruser/data')

def process_item(self, item: pystac.Item, source: harmony.message.Source) -> pystac.Item:
def process_item(self, item: pystac.Item, source: harmony_service_lib.message.Source) -> pystac.Item:
"""
Performs variable and bounding box subsetting on the input STAC Item's data, returning
an output STAC item
Expand Down Expand Up @@ -206,6 +228,8 @@ def filter_by_subtype(variables, subtype):

# Return the STAC record
return result
except Exception as ex:
raise L2SSException(ex) from ex
finally:
# Clean up any intermediate resources
shutil.rmtree(temp_dir)
Expand Down Expand Up @@ -240,7 +264,7 @@ def cmd(self, *args) -> List[str]:
return result_str.split("\n")


def main(config: harmony.util.Config = None) -> None:
def main(config: harmony_service_lib.util.Config = None) -> None:
"""Parse command line arguments and invoke the service to respond to
them.
Expand All @@ -254,10 +278,10 @@ def main(config: harmony.util.Config = None) -> None:
"""
parser = argparse.ArgumentParser(prog=SERVICE_NAME,
description='Run the l2_subsetter service')
harmony.setup_cli(parser)
harmony_service_lib.setup_cli(parser)
args = parser.parse_args()
if harmony.is_harmony_cli(args):
harmony.run_cli(parser, args, L2SubsetterService, cfg=config)
if harmony_service_lib.is_harmony_cli(args):
harmony_service_lib.run_cli(parser, args, L2SubsetterService, cfg=config)
else:
parser.error("Only --harmony CLIs are supported")

Expand Down
Loading

0 comments on commit 94f67d7

Please sign in to comment.