Skip to content

Commit

Permalink
Merge pull request #251 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release v0.8.1
  • Loading branch information
AndrewPlayer3 authored Dec 17, 2024
2 parents 5b522a4 + bf55032 commit 9f6b469
Show file tree
Hide file tree
Showing 42 changed files with 1,090 additions and 615 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ on:
- develop
jobs:
call-changelog-check-workflow:
uses: ASFHyP3/actions/.github/workflows/[email protected]
secrets:
USER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ASFHyP3/actions/.github/workflows/[email protected]
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.11.0
uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.12.0
secrets:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ on:

jobs:
call-version-info-workflow:
uses: ASFHyP3/actions/.github/workflows/[email protected]
uses: ASFHyP3/actions/.github/workflows/[email protected]
with:
python_version: "3.11"

distribute:
runs-on: ubuntu-latest
Expand All @@ -19,7 +21,7 @@ jobs:
with:
fetch-depth: 0

- uses: mamba-org/setup-micromamba@v1
- uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml

Expand All @@ -29,7 +31,7 @@ jobs:
python -m build
- name: upload to PyPI.org
uses: pypa/gh-action-pypi-publish@v1.9.0
uses: pypa/gh-action-pypi-publish@v1.12.3
with:
user: __token__
password: ${{ secrets.TOOLS_PYPI_PAK }}
2 changes: 1 addition & 1 deletion .github/workflows/labeled-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ on:

jobs:
call-labeled-pr-check-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.11.0
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.12.0
24 changes: 12 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ jobs:
git merge --ff-only origin/main
git push
- name: Open PR to bring main back to develop
- name: On failure, open PR to bring release back to develop
if: ${{ failure() }}
uses: repo-sync/pull-request@v2
with:
source_branch: main
destination_branch: develop
pr_title: Pulling ${{ github.ref }} into default
pr_body: Fast-forward of main to default failed!
pr_assignee: ${{ github.actor }}
pr_label: tools-bot
pr_draft: false
pr_allow_empty: true
github_token: ${{ secrets.TOOLS_BOT_PAK }}
env:
PR_TITLE: Pulling ${{ github.ref }} into develop
PR_BODY: Fast-forward of main to develop failed!
GH_TOKEN: ${{ secrets.USER_TOKEN }}
run: |
gh pr create --title "${PR_TITLE}" \
--body "${PR_BODY}" \
--assignee ${{ github.actor }} \
--label tools-bot \
--head main \
--base develop
27 changes: 6 additions & 21 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,10 @@ name: Static analysis
on: push

jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 flake8-import-order flake8-blind-except flake8-builtins
- name: Lint with flake8
run: |
flake8 --max-line-length=120 --import-order-style=pycharm --statistics \
--application-import-names asf_tools ArcGIS-toolbox/ASF_Tools.pyt src/asf_tools
call-secrets-analysis-workflow:
uses: ASFHyP3/actions/.github/workflows/[email protected]
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected]

call-ruff-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected]
2 changes: 1 addition & 1 deletion .github/workflows/tag-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ on:

jobs:
call-bump-version-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.11.0
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.12.0
secrets:
USER_TOKEN: ${{ secrets.TOOLS_BOT_PAK }}
6 changes: 3 additions & 3 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ on:

jobs:
call-pytest-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.11.0
uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.12.0
with:
local_package_name: asf_tools
python_versions: >- # Optional; default shown
["3.10", "3.11"]
call-version-info-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.11.0
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.12.0
with:
python_version: "3.10"

call-docker-ghcr-workflow:
needs: call-version-info-workflow
uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.11.0
uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.12.0
with:
version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }}
secrets:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ 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.8.1]

### Fixed
- The [`release`](.github/workflows/release.yml) Github Actions workflow now uses the `gh` CLI instead of the archived `repo-sync/pull-request` action.

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

## [0.8.0]

### Removed
Expand Down
7 changes: 2 additions & 5 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ dependencies:
- pip
# For packaging, and testing
# - arcpy # windows only
- build
- flake8
- flake8-import-order
- flake8-blind-except
- flake8-builtins
- python-build
- ruff
- setuptools>=61
- setuptools_scm>=6.2
- pytest
Expand Down
32 changes: 28 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ flood_map = "asf_tools.hydrosar.flood_map:hyp3"

[project.optional-dependencies]
develop = [
"flake8",
"flake8-import-order",
"flake8-blind-except",
"flake8-builtins",
"gdal-utils",
"ruff",
"pytest",
"pytest-cov",
"pytest-console-scripts",
Expand All @@ -79,3 +76,30 @@ where = ["src"]
markers = [
"integration: long-running integration tests",
]

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

[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
1 change: 1 addition & 0 deletions src/asf_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from importlib.metadata import version


__version__ = version(__name__)

__all__ = [
Expand Down
10 changes: 5 additions & 5 deletions src/asf_tools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
def main():
parser = argparse.ArgumentParser(prefix_chars='+', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'++process', choices=['water_map', 'flood_map'], default='water_map',
help='Select the HyP3 entrypoint to use' # HyP3 entrypoints are specified in `pyproject.toml`
'++process',
choices=['water_map', 'flood_map'],
default='water_map',
help='Select the HyP3 entrypoint to use', # HyP3 entrypoints are specified in `pyproject.toml`
)

args, unknowns = parser.parse_known_args()
# NOTE: Cast to set because of: https://github.com/pypa/setuptools/issues/3649
(process_entry_point,) = set(entry_points(group='hyp3', name=args.process))

sys.argv = [args.process, *unknowns]
sys.exit(
process_entry_point.load()()
)
sys.exit(process_entry_point.load()())


if __name__ == '__main__':
Expand Down
15 changes: 4 additions & 11 deletions src/asf_tools/aws.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
import logging
from mimetypes import guess_type
from pathlib import Path
from typing import Union

import boto3


S3_CLIENT = boto3.client('s3')
log = logging.getLogger(__name__)


def get_tag_set() -> dict:
tag_set = {
'TagSet': [
{
'Key': 'file_type',
'Value': 'product'
}
]
}
tag_set = {'TagSet': [{'Key': 'file_type', 'Value': 'product'}]}
return tag_set


def get_content_type(file_location: Union[Path, str]) -> str:
def get_content_type(file_location: Path | str) -> str:
content_type = guess_type(file_location)[0]
if not content_type:
content_type = 'application/octet-stream'
return content_type


def upload_file_to_s3(path_to_file: Union[str, Path], bucket: str, prefix: str = ''):
def upload_file_to_s3(path_to_file: str | Path, bucket: str, prefix: str = ''):
path_to_file = Path(path_to_file)
key = str(Path(prefix) / path_to_file.name)
extra_args = {'ContentType': get_content_type(key)}
Expand Down
Loading

0 comments on commit 9f6b469

Please sign in to comment.