Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
James Wood authored and James Wood committed Jan 28, 2025
2 parents 417e260 + 65ae7ce commit 52ff551
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 88 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
elif [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
new_version=$(poetry version prerelease -s)
elif [[ "${{ github.ref }}" =~ ^refs/heads/release/ ]]; then
if [[ ${current_version} =~ -rc ]]; then
if [[ ${current_version} =~ rc ]]; then
new_version=$(poetry version prerelease -s)
else
new_version="${GITHUB_REF#refs/heads/release/}rc1"
Expand Down Expand Up @@ -129,7 +129,8 @@ jobs:
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release') ||
contains(github.event.head_commit.message, '/deploy')
github.event.head_commit.message == '/deploy sit' ||
github.event.head_commit.message == '/deploy uat'
uses: ncipollo/release-action@v1.14.0
with:
tag: ${{ env.new_version }}
Expand Down Expand Up @@ -174,7 +175,8 @@ jobs:
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release') ||
contains(github.event.head_commit.message, '/deploy')
github.event.head_commit.message == '/deploy sit' ||
github.event.head_commit.message == '/deploy uat'
)
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -209,7 +211,9 @@ jobs:
fi
- name: Deploy Env Override
if: contains(github.event.head_commit.message, '/deploy')
if: |
github.event.head_commit.message == '/deploy sit' ||
github.event.head_commit.message == '/deploy uat'
run: |
message="${{ github.event.head_commit.message }}"
trimmed_message=${message:1} # Remove leading slash
Expand All @@ -231,7 +235,7 @@ jobs:
flavor: |
latest=${{ github.ref == 'refs/heads/main' }}
tags: |
type=semver,pattern={{raw}},value=${{ needs.build.outputs.version }}
type=pep440,pattern={{version}},value=${{ needs.build.outputs.version }}
type=raw,value=${{ env.TARGET_ENV_LOWERCASE }}
- name: Set Build Source
Expand All @@ -241,8 +245,8 @@ jobs:
echo "SOURCE=${{ needs.build.outputs.pyproject_name }}==${{ needs.build.outputs.version }}" >> $GITHUB_ENV
# Override source if deploying (find .whl file in dist/)
if [[ "${{ contains(github.event.head_commit.message, '/deploy sit') ||
contains(github.event.head_commit.message, '/deploy uat') }}" == "true" ]]; then
if [[ "${{ github.event.head_commit.message }}" == "/deploy sit" ||
"${{ github.event.head_commit.message }}" == "/deploy uat" ]]; then
local_forge_py=$(find dist -type f -name "*.whl")
echo "SOURCE=${local_forge_py}" >> $GITHUB_ENV
echo "DIST_PATH=dist/" >> $GITHUB_ENV
Expand All @@ -269,5 +273,5 @@ jobs:
build-args: |
SOURCE=${{ env.SOURCE }}
DIST_PATH=${{ env.DIST_PATH || '' }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/cache:cache,mode=max
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cache:forge-py-cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/cache:forge-py-cache,mode=max
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ disable=raw-checker-failed,
use-symbolic-message-instead,
too-many-arguments,
too-many-locals,
too-many-positional-arguments
too-many-positional-arguments,
broad-exception-raised
# 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
# multiple time (only on the command line, not in the configuration file where
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added in forge-py fargate terraform code
- Updated and cleaned up github action
- Added new function to check for valid longitude and latitude values for granule.
### Deprecated
### Removed
### Fixed
Expand Down
27 changes: 27 additions & 0 deletions podaac/forge_py/forge.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def generate_footprint(lon, lat, strategy=None, is360=False, path=None, **kwargs
if is360:
lon = ((lon + 180) % 360.0) - 180

is_lon_lat_invalid = are_all_lon_lat_invalid(lon, lat)
if is_lon_lat_invalid:
raise Exception("Can't generate footprint for empty granule")

# Dispatch to the correct footprint strategy based on `strategy`
if strategy == "open_cv":
footprint = open_cv_footprint.footprint_open_cv(lon, lat, path=path, **kwargs)
Expand All @@ -164,3 +168,26 @@ def generate_footprint(lon, lat, strategy=None, is360=False, path=None, **kwargs
footprint = remove_small_polygons(footprint, kwargs['min_area'])

return dumps(footprint, trim=True)


def are_all_lon_lat_invalid(lon, lat):
"""
Checks if all longitude and latitude values in a NetCDF file are invalid.
Parameters:
lon (array): longitude values.
lat (array): latitude values.
Returns:
bool: True if all longitude and latitude values are invalid, False otherwise.
"""

# Define valid ranges
valid_lon = (lon >= -180) & (lon <= 180)
valid_lat = (lat >= -90) & (lat <= 90)

# Check if all values are invalid
all_invalid_lon = (~valid_lon).all().item()
all_invalid_lat = (~valid_lat).all().item()

return all_invalid_lon and all_invalid_lat
Loading

0 comments on commit 52ff551

Please sign in to comment.