Skip to content

Commit

Permalink
Merge pull request #89 from asfadmin/test
Browse files Browse the repository at this point in the history
Release v1.1.2 - attempt #2
  • Loading branch information
jtherrmann authored Jan 14, 2025
2 parents 1bab9d6 + cbe94a6 commit ea8ac3e
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ on:
jobs:
call-changelog-check-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.13.2
uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.14.0
2 changes: 1 addition & 1 deletion .github/workflows/create-jira-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
call-create-jira-issue-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.13.2
uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.14.0
secrets:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeled-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ on:
jobs:
call-labeled-pr-check-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.13.2
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.14.0
2 changes: 1 addition & 1 deletion .github/workflows/release-checklist-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
call-release-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.13.2
uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.14.0
permissions:
pull-requests: write
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
call-release-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.13.2
uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.14.0
with:
release_prefix: GRFN GDAL API
release_branch: prod
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on: push
jobs:

call-ruff-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.13.2
uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.14.0

call-mypy-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-mypy.yml@v0.14.0

cfn-lint:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
call-bump-version-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.13.2
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.14.0
with:
user: tools-bot
email: UAF-asf-apd@alaska.edu
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ 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).

## [1.1.2]
### Added
- Added `mypy` to static analysis workflow.

### Changed
- Replaced `flake8` with `ruff`.

Expand Down
11 changes: 11 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: grfn-gdal-api
channels:
- conda-forge
- nodefaults
dependencies:
- python=3.11
- pip
- pip:
# requirements-reformat.txt is not included because gdal is annoying to install,
# and the conda environment is only needed for running linters.
- -r requirements-dev.txt
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ convention = "google"
[tool.ruff.lint.isort]
case-sensitive = true
lines-after-imports = 2

[tool.mypy]
python_version = "3.11"
warn_redundant_casts = true
warn_unused_ignores = true
warn_unreachable = true
strict_equality = true
check_untyped_defs = true
18 changes: 9 additions & 9 deletions reformat/src/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import os
from logging import getLogger
from os import chmod, getenv, path, remove
from urllib.parse import urljoin, urlparse
from uuid import uuid4

Expand All @@ -11,7 +11,7 @@

log = getLogger()
log.setLevel('INFO')
config = json.loads(getenv('CONFIG'))
config = json.loads(os.environ['CONFIG'])
s3 = boto3.resource('s3')
secrets_manager = boto3.client('secretsmanager')
session = Session()
Expand All @@ -24,10 +24,10 @@ def get_secret(secret_arn):


def write_content_to_netrc_file(netrc_content):
netrc_file = path.join(getenv('HOME'), '.netrc')
netrc_file = os.path.join(os.environ['HOME'], '.netrc')
with open(netrc_file, 'w') as f:
f.write(netrc_content)
chmod(netrc_file, 0o600)
os.chmod(netrc_file, 0o600)


def set_up_netrc(secret_arn):
Expand Down Expand Up @@ -116,9 +116,9 @@ def _check_error(self):

def get_output_key(product, layer):
prefix = uuid4()
product_basename = path.basename(product)
product_basename_without_extension = path.splitext(product_basename)[0]
layer_basename = path.basename(layer)
product_basename = os.path.basename(product)
product_basename_without_extension = os.path.splitext(product_basename)[0]
layer_basename = os.path.basename(layer)
output_key = f'{prefix}/{product_basename_without_extension}-{layer_basename}.tif'
return output_key

Expand All @@ -127,7 +127,7 @@ def download_file(host_url, product):
download_url = urljoin(host_url, product)
response = session.get(download_url)
response.raise_for_status()
file_name = path.join('/tmp', product)
file_name = os.path.join('/tmp', product)
with open(file_name, 'wb') as f:
for block in response.iter_content(1024):
f.write(block)
Expand Down Expand Up @@ -181,7 +181,7 @@ def lambda_handler(event, context):
try:
translate_netcdf_to_geotiff(input_datasource, vsimem_datasource)
finally:
remove(input_file_name)
os.remove(input_file_name)

output_key = get_output_key(parms['product'], parms['layer'])
try:
Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ruff
mypy

0 comments on commit ea8ac3e

Please sign in to comment.