Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates post NISAR Early Adopters Workshop #64

Merged
merged 7 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/update_actions_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update ASFHyP3/actions version

on:
workflow_dispatch:
inputs:
version:
description: 'Version to set all ASFHyP3/actions to'
required: true
type: string

jobs:
update_actions_examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.TOOLS_BOT_PAK }}

- name: Create update branch
id: update
env:
ACTIONS_VERSION: ${{ github.event.inputs.version }}
run: |
git config user.name "tools-bot"
git config user.email "[email protected]"

export UPDATE_BRANCH=update-actions-to-${ACTIONS_VERSION}
git switch -c ${UPDATE_BRANCH}

export SEARCH_PATTERN='(ASFHyP3/actions/.github/workflows/.*.yml)@v[0-9]+\.[0-9]+\.[0-9]+'
find -iwholename "*/workflows/*.yml" -exec sed -i -r "s|$SEARCH_PATTERN|\1@${ACTIONS_VERSION}|g" {} \;

git commit -am "Bump actions ASFHyP3/actions version to ${ACTIONS_VERSION}"
git push origin ${UPDATE_BRANCH}

- name: Open PR
env:
PR_TITLE: Update ASFHyP3/actions version to ${{ env.ACTIONS_VERSION }}
PR_BODY: PR created by a new `v*` tag push event
GH_TOKEN: ${{ secrets.TOOLS_BOT_PAK }}
run: |
gh pr create -t "${PR_TITLE}" -b "${PR_BODY}" -l tools-bot -l bumpless -B develop
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ 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.3.0]
### Added
* Support for Python 3.13
* Workflow action to keep the reusable CI/CD action up to date within the cookiecutter template

### Changed
* Now uses ruff for linting and formatting instead of flake8

### Removed
* The unused `process.main` function as we don't register it as a console script entrypoint

### Fixed
* Tests using the `script_runner` fixture will no longer raise usage warnings

## [0.2.0]
### Removed
* Support for Python 3.8 and 3.9 has been dropped. The minimum version is now 3.10.
Expand Down
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"github_username": "username_for_github_actions",
"github_email": "email_for@github_actions.com",
"process_type": "RTC",
"short_description": "HyP3 plugin for {{cookiecutter.process_type}} processing",
"short_description": "HyP3 plugin for {{cookiecutter.process_type}} processing.",
"public_url": "https://github.com/ASFHyP3/hyp3-{{cookiecutter.process_type}}",
"copyright_year": "{% now 'utc', '%Y' %}",
"__project_name": "hyp3-{{cookiecutter.process_type | lower}}",
Expand Down
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-relese[email protected]
uses: ASFHyP3/actions/.github/workflows/reusable-release[email protected]
permissions:
pull-requests: write
secrets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
local_package_name: {{ cookiecutter.__package_name }}
python_versions: >-
["3.10", "3.11", "3.12"]
["3.10", "3.11", "3.12", "3.13"]

call-version-info-workflow:
# Docs: https://github.com/ASFHyP3/actions
Expand Down
3 changes: 1 addition & 2 deletions {{cookiecutter.__project_name}}/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ dependencies:
- pip
# For packaging, and testing
- ruff
- setuptools
- setuptools_scm
- wheel
- pytest
- pytest-console-scripts
- pytest-cov
# For running
- hyp3lib>=3,<4
# TODO: insert conda-forge dependencies as list here
9 changes: 4 additions & 5 deletions {{cookiecutter.__project_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "{{ cookiecutter.__package_name }}"
readme = "README.md"
requires-python = ">=3.10"
authors = [
{name="{{ cookiecutter.github_username }}", email="{{ cookiecutter.github_email }}"},
Expand All @@ -19,12 +20,13 @@ classifiers=[
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"hyp3lib>=3,<4",
# insert python dependencies as list here
# TODO: insert Python dependencies as list here
]
dynamic = ["version", "readme"]
dynamic = ["version"]

[project.optional-dependencies]
develop = [
Expand All @@ -46,9 +48,6 @@ script_launch_mode = "subprocess"
include-package-data = true
zip-safe = false

[tool.setuptools.dynamic]
readme = {file = ["README.md"], content-type = "text/markdown"}

[tool.setuptools.packages.find]
where = ["src"]

Expand Down
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
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
"""
{{cookiecutter.process_type}} processing for HyP3
"""
"""{{cookiecutter.process_type}} processing for HyP3."""

import logging
from argparse import ArgumentParser

from hyp3lib.aws import upload_file_to_s3
from hyp3lib.image import create_thumbnail


from {{cookiecutter.__package_name}}.process import {{cookiecutter.__process_name}}


def main():
"""
HyP3 entrypoint for {{cookiecutter.__package_name}}
"""
def main() -> None:
"""HyP3 entrypoint for {{cookiecutter.__package_name}}."""
parser = ArgumentParser()
parser.add_argument('--bucket', help='AWS S3 bucket HyP3 for upload the final product(s)')
parser.add_argument('--bucket-prefix', default='', help='Add a bucket prefix to product(s)')

# TODO: Your arguments here
parser.add_argument('--greeting', default='Hello world!',
help='Write this greeting to a product file')
parser.add_argument('--greeting', default='Hello world!', help='Write this greeting to a product file')

args = parser.parse_args()

logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO)
logging.basicConfig(
format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO
)

product_file = {{cookiecutter.__process_name}}(
greeting=args.greeting,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
"""
{{cookiecutter.process_type}} processing
"""
"""{{cookiecutter.process_type}} processing."""

import argparse
import logging
from pathlib import Path

from {{cookiecutter.__package_name}} import __version__

log = logging.getLogger(__name__)


def {{cookiecutter.__process_name}}(greeting: str = 'Hello world!') -> Path:
"""Create a greeting product
"""Create a greeting product.

Args:
greeting: Write this greeting to a product file (Default: "Hello world!" )
Expand All @@ -21,21 +17,3 @@ def {{cookiecutter.__process_name}}(greeting: str = 'Hello world!') -> Path:
product_file = Path('greeting.txt')
product_file.write_text(greeting)
return product_file


def main():
"""{{cookiecutter.__process_name}} entrypoint"""
parser = argparse.ArgumentParser(
prog='{{cookiecutter.__process_name}}',
description=__doc__,
)
parser.add_argument('--greeting', default='Hello world!',
help='Write this greeting to a product file')
parser.add_argument('--version', action='version', version=f'%(prog)s {__version__}')
args = parser.parse_args()

{{cookiecutter.__process_name}}(**args.__dict__)


if __name__ == "__main__":
main()