From 11ec65b5d6a7762404c6e52fda4dc855671fafa3 Mon Sep 17 00:00:00 2001 From: Forrest Williams Date: Mon, 22 Apr 2024 13:05:46 -0500 Subject: [PATCH 1/6] remove 2021 version of back-projection plugin --- .github/ISSUE_TEMPLATE/bug_report.md | 25 ----- .github/ISSUE_TEMPLATE/feature_request.md | 20 ---- .github/PULL_REQUEST_TEMPLATE/release.md | 37 ------ .github/queries/associated-pr.query.yml | 28 ----- .github/queries/pr-labels.query.yml | 24 ---- .trufflehog.txt | 1 - CHANGELOG.md | 12 -- CODE_OF_CONDUCT.md | 130 ---------------------- Dockerfile | 44 -------- LICENSE | 29 ----- MANIFEST.in | 6 - README.md | 3 - back_projection/__init__.py | 19 ---- back_projection/__main__.py | 55 --------- back_projection/process.py | 126 --------------------- pyproject.toml | 2 - setup.py | 56 ---------- tests/conftest.py | 0 tests/test_entrypoints.py | 3 - 19 files changed, 620 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE/release.md delete mode 100644 .github/queries/associated-pr.query.yml delete mode 100644 .github/queries/pr-labels.query.yml delete mode 100644 .trufflehog.txt delete mode 100755 CHANGELOG.md delete mode 100755 CODE_OF_CONDUCT.md delete mode 100755 Dockerfile delete mode 100755 LICENSE delete mode 100755 MANIFEST.in delete mode 100755 README.md delete mode 100755 back_projection/__init__.py delete mode 100755 back_projection/__main__.py delete mode 100755 back_projection/process.py delete mode 100755 pyproject.toml delete mode 100755 setup.py delete mode 100755 tests/conftest.py delete mode 100755 tests/test_entrypoints.py diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 41d49b6..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: bug -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 6532412..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: enhancement -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE/release.md b/.github/PULL_REQUEST_TEMPLATE/release.md deleted file mode 100644 index ddab131..0000000 --- a/.github/PULL_REQUEST_TEMPLATE/release.md +++ /dev/null @@ -1,37 +0,0 @@ -## Description of this release - - - - - -### Developer checklist - -- [ ] Assigned a reviewer - -- [ ] Indicated the level of changes to this package by affixing one of these labels: - * major -- Major changes to the API that may break current workflows - * minor -- Minor changes to the API that do not break current workflows - * patch -- Patches and bugfixes for the current version that do not break current workflows - * bumpless -- Changes to documentation, CI/CD pipelines, etc. that don't affect the software's version - -- [ ] (If applicable) Updated the dependencies and indicated any downstream changes that are required - -- [ ] Updated `CHANGELOG.md` -- [ ] Added/updated documentation for these changes -- [ ] Added/updated tests for these changes - -### Reviewer checklist - -- [ ] Have all dependencies been updated? -- [ ] Is the level of changes labeled appropriately? -- [ ] Are all the changes described appropriately in `CHANGELOG.md`? -- [ ] Has the documentation been adequately updated? -- [ ] Are the tests adequate? \ No newline at end of file diff --git a/.github/queries/associated-pr.query.yml b/.github/queries/associated-pr.query.yml deleted file mode 100644 index e3b0adb..0000000 --- a/.github/queries/associated-pr.query.yml +++ /dev/null @@ -1,28 +0,0 @@ -query: ' - query($owner:String!, $name:String!, $sha:String!) { - repository(owner:$owner, name:$name) { - commit: object(expression:$sha) { - ... on Commit { - associatedPullRequests(first:1, orderBy:{field: UPDATED_AT, direction: DESC}){ - edges{ - node{ - title - number - body - } - } - } - } - } - } - }' -variables: - owner: - type: arg - name: owner - name: - type: arg - name: name - sha: - type: arg - name: sha \ No newline at end of file diff --git a/.github/queries/pr-labels.query.yml b/.github/queries/pr-labels.query.yml deleted file mode 100644 index a105712..0000000 --- a/.github/queries/pr-labels.query.yml +++ /dev/null @@ -1,24 +0,0 @@ -query: ' - query($owner:String!, $name:String!, $pr:Int!) { - repository(owner:$owner, name:$name) { - pullRequest(number:$pr) { - labels(first:100) { - nodes { - name - } - } - } - } - }' -variables: - owner: - type: arg - name: owner - name: - type: arg - name: name - pr: - type: jq - file: pr.json - query: '.data.repository.commit.associatedPullRequests.edges[0].node.number' - cast: Int \ No newline at end of file diff --git a/.trufflehog.txt b/.trufflehog.txt deleted file mode 100644 index a91912f..0000000 --- a/.trufflehog.txt +++ /dev/null @@ -1 +0,0 @@ -.*gitleaks.toml$ diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100755 index 0fd0321..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -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). - -## [Unreleased](https://github.com/andrewplayer3/back_projection/compare/v0.0.0...develop) -- likely 0.0.1 - -### Added --- Added validation for gpu existance (defaults to cpu if none exists) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100755 index c71814b..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,130 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, religion, or sexual identity -and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the - overall community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or - advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email - address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement by emailing the -ASF APD/Tools team at [UAF-asf-apd@alaska.edu](mailto:UAF-asf-apd@alaska.edu). -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series -of actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or -permanent ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within -the community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.0, available at -https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. - -Community Impact Guidelines were inspired by [Mozilla's code of conduct -enforcement ladder](https://github.com/mozilla/diversity). - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at -https://www.contributor-covenant.org/translations. - diff --git a/Dockerfile b/Dockerfile deleted file mode 100755 index 4b25525..0000000 --- a/Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -FROM ubuntu:latest - -# For opencontainers label definitions, see: -# https://github.com/opencontainers/image-spec/blob/master/annotations.md -LABEL org.opencontainers.image.title="Back_projection" -LABEL org.opencontainers.image.description="This is a process to process L0 Raw Products using a back projection algorithm" -LABEL org.opencontainers.image.vendor="Alaska Satellite Facility" -LABEL org.opencontainers.image.authors="ASF APD/Tools Team " -LABEL org.opencontainers.image.licenses="BSD-3-Clause" -LABEL org.opencontainers.image.url="https://github.com/ASFHyP3/hyp3-back-projection" -LABEL org.opencontainers.image.source="https://github.com/ASFHyP3/hyp3-back-projection" -# LABEL org.opencontainers.image.documentation="" - -# Dynamic lables to define at build time via `docker build --label` -# LABEL org.opencontainers.image.created="" -# LABEL org.opencontainers.image.version="" -# LABEL org.opencontainers.image.revision="" - -ENV TZ=America/Anchorage -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -RUN apt-get update && apt-get install -y --no-install-recommends build-essential wget gcc gfortran libgfortran-8-dev make unzip vim gdal-bin python3-pip libsqlite3-dev libfftw3-dev libfftw3-doc nvidia-cuda-toolkit && \ - apt-get clean && rm -rf /var/lib/apt/lists/* - -RUN useradd -ms /bin/bash user - -USER user -SHELL ["/bin/bash", "-l", "-c"] -ENV PYTHONDONTWRITEBYTECODE=true -WORKDIR /home/user - -COPY dist/* /home/user/ - -RUN python3 -m pip install /home/user/back_projection-0.0.0.tar.gz && \ - tar -xvf back_projection-0.0.0.tar.gz && \ - cd back_projection-0.0.0/back_projection/src && \ - source build_proc && \ - mkdir /home/user/back_projection-0.0.0/back_projection/src/output 2>/dev/null && \ - ls /home/user/back_projection-0.0.0/back_projection/src - -ENV PROC_HOME="/home/user/back_projection-0.0.0/back_projection/src" - -ENTRYPOINT ["python3", "/home/user/back_projection-0.0.0/back_projection/__main__.py"] -CMD ["-h"] diff --git a/LICENSE b/LICENSE deleted file mode 100755 index c8c9868..0000000 --- a/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 0000, Alaska Satellite Facility -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100755 index e1f9070..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include LICENSE -include README.md - -graft back_projection - -global-exclude *.py[cod] __pycache__ *.so diff --git a/README.md b/README.md deleted file mode 100755 index 81a017d..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Back_projection - -This is a process to process L0 Raw Products using a back projection algorithm diff --git a/back_projection/__init__.py b/back_projection/__init__.py deleted file mode 100755 index 76e1445..0000000 --- a/back_projection/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -"""Process L0 Raw Products using a back projection algorithm""" - -from importlib.metadata import PackageNotFoundError, version - -from back_projection.process import back_projection - -try: - __version__ = version(__name__) -except PackageNotFoundError: - print(f'{__name__} package is not installed!\n' - f'To install in editable/develop mode (from the repo\'s root):\n' - f' python -m pip install -e .[develop]\n' - f'Or, to just get the version number use:\n' - f' python setup.py --version') - -__all__ = [ - '__version__', - 'back_projection', -] diff --git a/back_projection/__main__.py b/back_projection/__main__.py deleted file mode 100755 index 0fbff8d..0000000 --- a/back_projection/__main__.py +++ /dev/null @@ -1,55 +0,0 @@ -""" -projector processing for HyP3 -""" -import logging -import os -from argparse import ArgumentParser -from pathlib import Path - -import back_projection -from hyp3lib.aws import upload_file_to_s3 - -__version__ = 1.0 - - -def main(): - """ - HyP3 entrypoint for back_projection - """ - parser = ArgumentParser() - parser.add_argument("granule", metavar='granule', type=str, - help="name of granule to be processed.") - parser.add_argument('--bucket', - help='S3 bucket HyP3 for upload the final product(s)') - parser.add_argument('--bucket-prefix', default='', - help='Add a bucket prefix to product(s)') - parser.add_argument("--username", type=str, - help="hyp3 username") - parser.add_argument('--password', type=str, - help="hyp3 password") - parser.add_argument('--use_gpu', action='store_true', - help="use gpu rather than cpu for processing") - - args = parser.parse_args() - - logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', - datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO) - - product_path_string = back_projection.back_projection( - granule=args.granule, - username=args.username, - password=args.password, - use_gpu=args.use_gpu - ) - - HOME = os.environ['PROC_HOME'] - print(os.listdir(HOME + "/output")) - - if args.bucket: - upload_file_to_s3(Path(product_path_string), - args.bucket, - args.bucket_prefix) - - -if __name__ == '__main__': - main() diff --git a/back_projection/process.py b/back_projection/process.py deleted file mode 100755 index f0c6068..0000000 --- a/back_projection/process.py +++ /dev/null @@ -1,126 +0,0 @@ -""" -projector processing -""" -import argparse -import logging -import os -import subprocess -from pathlib import Path -from zipfile import ZipFile - -__version__ = 1.0 - -log = logging.getLogger(__name__) - - -def back_projection(granule: str, username: str, password: str, use_gpu: bool) -> Path: - """Create GSLCS and Convert them to tiffs for viewing - - Args: - granule: granule name to be processed. - username: hyp3 username - password: hyp3 password - """ - - HOME = os.environ['PROC_HOME'] - - # Make granules.list file to be read by sentinel_cpu.py - # to download necessary granules - file = open("granule.list", "w") - output_string = granule + ".zip\n" - file.write(output_string) - file.close() - - gpu_exists = False - if use_gpu: - # grab gpu number, -1 if there isn't one - proc = subprocess.Popen(HOME+"/sentinel/bestgpu.sh", stdout=subprocess.PIPE, shell=True) - (bestGPU, err) = proc.communicate() - bestGPU = str(int(bestGPU.strip())) - print("GPU: ", bestGPU) - if bestGPU != "-1": - gpu_exists = True - - # Run the back_projection through sentinel_cpu.py or sentinel_gpu.py VV - run_backprojection = "" - if use_gpu and gpu_exists: - print("RUNNING WITH GPU") - print("----------------") - run_backprojection = HOME + "/sentinel/sentinel_gpu.py" - else: - print("RUNNING WITH CPU") - print("----------------") - run_backprojection = HOME + "/sentinel/sentinel_cpu.py" - run_backprojection += " --username \"" + username + "\" --password \"" + password + "\"" - print("GRANULES TO DOWNLOAD: ", granule) - print("Command: ", run_backprojection) - ret = os.system(run_backprojection) - - # create a amplitude tiff - # band 1: amplitude - make_tiff = "python3 " + HOME + "/make_tiff.py " + granule + ".geo " - make_tiff += "elevation.dem.rsc " + granule - print(make_tiff + "_VV.tiff") - ret = os.system(make_tiff + "_VV.tiff") - - move_vv_file = "mv *.geo "+HOME+"/output/"+granule+"_VV.geo" - ret = os.system(move_vv_file) - - # Run the back_projection through sentinel_cpu.py VH - run_backprojection += " --polarization vh --use_existing_data True" - print("Command: ", run_backprojection) - ret = os.system(run_backprojection) - - # create amplitude tiff - # band 1: amplitude - print(make_tiff + "_VH.tiff") - ret = os.system(make_tiff + "_VH.tiff") - - move_vh_file = "mv *.geo "+HOME+"/output/"+granule+"_VH.geo" - ret = os.system(move_vh_file) - - # Remove all of the temporary files - remove_files = "rm *.list *.EOF *.dem *.orbtiming " - remove_files += "*.full latloncoords preciseorbitfiles " - remove_files += "precise_orbtiming params" - ret = os.system(remove_files) - remove_SAFE = "rm -rf *.SAFE" - ret = os.system(remove_SAFE) - move_rsc_files = "mv elevation.dem.rsc "+HOME+"/output/" - ret = os.system(move_rsc_files) - ret = os.system("rm *.rsc") - print(ret) - - with ZipFile(granule + ".zip", "w") as zipObj: - for folder_name, sub_folders, filenames in os.walk(HOME+"/output/"): - for filename in filenames: - file_path = os.path.join(folder_name, filename) - zipObj.write(file_path, os.path.basename(file_path)) - - return granule+".zip" - - -def main(): - """back_projection entrypoint""" - parser = argparse.ArgumentParser( - prog='back_projection', - description=__doc__, - ) - parser.add_argument("granule", type=str, - help="granule name to be processed") - parser.add_argument("--username", type=str, - help="hyp3 username") - parser.add_argument('--password', type=str, - help="hyp3 password") - parser.add_arguemnt('--use_gpu', action='store_true', - help="use gpu rather than cpu for processing") - parser.add_argument('--version', action='version', - version=f'%(prog)s {__version__}') - args = parser.parse_args() - - return back_projection(args.granule, args.username, args.password, args.use_gpu) - - -if __name__ == "__main__": - product = main() - print(product) diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100755 index 51000e4..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,2 +0,0 @@ -[build-system] -requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] diff --git a/setup.py b/setup.py deleted file mode 100755 index 039c98e..0000000 --- a/setup.py +++ /dev/null @@ -1,56 +0,0 @@ -from pathlib import Path - -from setuptools import find_packages, setup - -readme = Path(__file__).parent / 'README.md' - -setup( - name='back_projection', - use_scm_version=False, - description='Process L0 Raw Products using a back projection algorithm', - long_description=readme.read_text(), - long_description_content_type='text/markdown', - - url='https://github.com/ASFHyP3/hyp3-back-projection', - - author='ASF APD/Tools Team', - author_email='uaf-asf-apd@alaska.edu', - - license='BSD', - include_package_data=True, - - classifiers=[ - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - ], - - python_requires='~=3.8', - - install_requires=[ - 'hyp3lib', - ], - - extras_require={ - 'develop': [ - 'flake8', - 'flake8-import-order', - 'flake8-blind-except', - 'flake8-builtins', - 'pytest', - 'pytest-cov', - 'pytest-console-scripts', - ] - }, - - packages=find_packages(), - - entry_points={'console_scripts': [ - 'back_projection = back_projection.__main__:main', - ] - }, - - zip_safe=False, -) diff --git a/tests/conftest.py b/tests/conftest.py deleted file mode 100755 index e69de29..0000000 diff --git a/tests/test_entrypoints.py b/tests/test_entrypoints.py deleted file mode 100755 index 7c980a9..0000000 --- a/tests/test_entrypoints.py +++ /dev/null @@ -1,3 +0,0 @@ -def test_back_projection(script_runner): - ret = script_runner.run('back_projection', '-h') - assert ret.success From 8c408703ccf44d5db2eb922192cfd9557bc9c930 Mon Sep 17 00:00:00 2001 From: Forrest Williams Date: Mon, 22 Apr 2024 13:08:55 -0500 Subject: [PATCH 2/6] recreate plugin using cookiecutter --- .github/CODEOWNERS | 2 + .github/ISSUE_TEMPLATE/bug_report.md | 22 ++ .github/ISSUE_TEMPLATE/feature_request.md | 19 ++ .github/dependabot.yml | 8 + .github/workflows/changelog.yml | 19 ++ .github/workflows/labeled-pr.yml | 16 ++ .../workflows/release-checklist-comment.yml | 17 ++ .github/workflows/release.yml | 18 ++ .github/workflows/static-analysis.yml | 14 + .github/workflows/tag-version.yml | 16 ++ .github/workflows/test-and-build.yml | 34 +++ .gitignore | 242 ++++++++++++++++++ .trufflehog.txt | 1 + CHANGELOG.md | 10 + CODE_OF_CONDUCT.md | 130 ++++++++++ Dockerfile | 48 ++++ LICENSE | 29 +++ MANIFEST.in | 1 + README.md | 3 + environment.yml | 20 ++ pyproject.toml | 59 +++++ src/hyp3_back_projection/__init__.py | 9 + src/hyp3_back_projection/__main__.py | 45 ++++ src/hyp3_back_projection/etc/entrypoint.sh | 4 + src/hyp3_back_projection/process.py | 41 +++ tests/conftest.py | 0 tests/test_entrypoints.py | 3 + 27 files changed, 830 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/changelog.yml create mode 100644 .github/workflows/labeled-pr.yml create mode 100644 .github/workflows/release-checklist-comment.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/static-analysis.yml create mode 100644 .github/workflows/tag-version.yml create mode 100644 .github/workflows/test-and-build.yml create mode 100644 .gitignore create mode 100644 .trufflehog.txt create mode 100644 CHANGELOG.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 README.md create mode 100644 environment.yml create mode 100644 pyproject.toml create mode 100644 src/hyp3_back_projection/__init__.py create mode 100644 src/hyp3_back_projection/__main__.py create mode 100755 src/hyp3_back_projection/etc/entrypoint.sh create mode 100644 src/hyp3_back_projection/process.py create mode 100644 tests/conftest.py create mode 100644 tests/test_entrypoints.py diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..e15e706 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# These owners will be requested for review when someone opens a pull request. +* @ASFHyP3/plugins diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..0c9638c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,22 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +### The bug + + +### To Reproduce + + + ### Additional context + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..4104538 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,19 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' + +--- +### Background + + +### Describe the solution you'd like + + +### Alternatives + + + ### Additional context + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..bb7aab6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + labels: + - "bumpless" diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..4337705 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,19 @@ +name: Changelog updated? + +on: + pull_request: + types: + - opened + - labeled + - unlabeled + - synchronize + branches: + - main + - develop + +jobs: + call-changelog-check-workflow: + # Docs: https://github.com/ASFHyP3/actions + uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.7.1 + secrets: + USER_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/labeled-pr.yml b/.github/workflows/labeled-pr.yml new file mode 100644 index 0000000..fffab93 --- /dev/null +++ b/.github/workflows/labeled-pr.yml @@ -0,0 +1,16 @@ +name: Is PR labeled? + +on: + pull_request: + types: + - opened + - labeled + - unlabeled + - synchronize + branches: + - main + +jobs: + call-labeled-pr-check-workflow: + # Docs: https://github.com/ASFHyP3/actions + uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.7.1 diff --git a/.github/workflows/release-checklist-comment.yml b/.github/workflows/release-checklist-comment.yml new file mode 100644 index 0000000..169dd37 --- /dev/null +++ b/.github/workflows/release-checklist-comment.yml @@ -0,0 +1,17 @@ +name: Create Release Comment + +on: + pull_request: + types: + - opened + branches: + - main + +jobs: + call-release-workflow: + # Docs: https://github.com/ASFHyP3/actions + uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.7.1 + permissions: + pull-requests: write + secrets: + USER_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d91161e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,18 @@ +name: Create Release + +on: + push: + tags: + - 'v*' + +jobs: + call-release-workflow: + # Docs: https://github.com/ASFHyP3/actions + uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.7.1 + with: + release_prefix: HyP3 back-projection + release_branch: main + develop_branch: develop + sync_pr_label: actions-bot + secrets: + USER_TOKEN: ${{ secrets.GITHUB_PAK }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..eda9d4a --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,14 @@ +name: Static analysis + +on: push + +jobs: + call-secrets-analysis-workflow: + # Docs: https://github.com/ASFHyP3/actions + uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.7.1 + + call-flake8-workflow: + # Docs: https://github.com/ASFHyP3/actions + uses: ASFHyP3/actions/.github/workflows/reusable-flake8.yml@v0.7.1 + with: + local_package_names: hyp3_back_projection diff --git a/.github/workflows/tag-version.yml b/.github/workflows/tag-version.yml new file mode 100644 index 0000000..64afd14 --- /dev/null +++ b/.github/workflows/tag-version.yml @@ -0,0 +1,16 @@ +name: Tag New Version + +on: + push: + branches: + - main + +jobs: + call-bump-version-workflow: + # Docs: https://github.com/ASFHyP3/actions + uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.7.1 + with: + user: tools-bot + email: UAF-asf-apd@alaska.edu + secrets: + USER_TOKEN: ${{ secrets.GITHUB_PAK }} diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml new file mode 100644 index 0000000..23fce25 --- /dev/null +++ b/.github/workflows/test-and-build.yml @@ -0,0 +1,34 @@ +name: Test and build + +on: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + +jobs: + call-pytest-workflow: + # Docs: https://github.com/ASFHyP3/actions + uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.7.1 + with: + local_package_name: hyp3_back_projection + + call-version-info-workflow: + # Docs: https://github.com/ASFHyP3/actions + uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.7.1 + + call-docker-ghcr-workflow: + needs: call-version-info-workflow + # Docs: https://github.com/ASFHyP3/actions + uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.7.1 + with: + version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }} + release_branch: main + develop_branch: develop + user: tools-bot + secrets: + USER_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bbca664 --- /dev/null +++ b/.gitignore @@ -0,0 +1,242 @@ +#### joe made this: http://goel.io/joe + +#### python #### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# static files generated from Django application using `collectstatic` +media +static + + +#### jetbrains #### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + + +#### vim #### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ diff --git a/.trufflehog.txt b/.trufflehog.txt new file mode 100644 index 0000000..a91912f --- /dev/null +++ b/.trufflehog.txt @@ -0,0 +1 @@ +.*gitleaks.toml$ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e15e847 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +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.1.0](https://github.com/ASFHyP3/hyp3-back-projection/compare/v0.0.0...v0.1.0) -- unreleased + diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..154bd0a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,130 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement by emailing the +development team at [UAF-asf-apd@alaska.edu](mailto:UAF-asf-apd@alaska.edu). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..705a1eb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +FROM condaforge/mambaforge:latest + +# For opencontainers label definitions, see: +# https://github.com/opencontainers/image-spec/blob/master/annotations.md +LABEL org.opencontainers.image.title="HyP3 back-projection" +LABEL org.opencontainers.image.description="HyP3 plugin for back-projection processing" +LABEL org.opencontainers.image.vendor="Alaska Satellite Facility" +LABEL org.opencontainers.image.authors="tools-bot " +LABEL org.opencontainers.image.licenses="BSD-3-Clause" +LABEL org.opencontainers.image.url="https://github.com/ASFHyP3/hyp3-back-projection" +LABEL org.opencontainers.image.source="https://github.com/ASFHyP3/hyp3-back-projection" +LABEL org.opencontainers.image.documentation="https://hyp3-docs.asf.alaska.edu" + +# Dynamic lables to define at build time via `docker build --label` +# LABEL org.opencontainers.image.created="" +# LABEL org.opencontainers.image.version="" +# LABEL org.opencontainers.image.revision="" + +ARG DEBIAN_FRONTEND=noninteractive +ENV PYTHONDONTWRITEBYTECODE=true + +RUN apt-get update && apt-get install -y --no-install-recommends unzip vim && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +ARG CONDA_UID=1000 +ARG CONDA_GID=1000 + +RUN groupadd -g "${CONDA_GID}" --system conda && \ + useradd -l -u "${CONDA_UID}" -g "${CONDA_GID}" --system -d /home/conda -m -s /bin/bash conda && \ + chown -R conda:conda /opt && \ + echo ". /opt/conda/etc/profile.d/conda.sh" >> /home/conda/.profile && \ + echo "conda activate base" >> /home/conda/.profile + + +USER ${CONDA_UID} +SHELL ["/bin/bash", "-l", "-c"] +WORKDIR /home/conda/ + +COPY --chown=${CONDA_UID}:${CONDA_GID} . /hyp3-back-projection/ + +RUN mamba env create -f /hyp3-back-projection/environment.yml && \ + conda clean -afy && \ + conda activate hyp3-back-projection && \ + sed -i 's/conda activate base/conda activate hyp3-back-projection/g' /home/conda/.profile && \ + python -m pip install --no-cache-dir /hyp3-back-projection + +ENTRYPOINT ["/hyp3-back-projection/src/hyp3_back_projection/etc/entrypoint.sh"] +CMD ["-h"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ec29375 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2024, Alaska Satellite Facility +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..1b33785 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +global-exclude *.py[cod] __pycache__ *.so diff --git a/README.md b/README.md new file mode 100644 index 0000000..9f19547 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# HyP3 back-projection + +HyP3 plugin for back-projection processing diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..566e126 --- /dev/null +++ b/environment.yml @@ -0,0 +1,20 @@ +name: hyp3-back-projection +channels: + - conda-forge + - nodefaults +dependencies: + - python>=3.8 + - pip + # For packaging, and testing + - flake8 + - flake8-import-order + - flake8-blind-except + - flake8-builtins + - setuptools + - setuptools_scm + - wheel + - pytest + - pytest-console-scripts + - pytest-cov + # For running + - hyp3lib>=3,<4 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6ab3ab3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,59 @@ +[build-system] +requires = ["setuptools>=61.0", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + +[project] +name = "hyp3_back_projection" +requires-python = ">=3.8" +authors = [ + {name="tools-bot", email="UAF-asf-apd@alaska.edu"}, +] +description = "HyP3 plugin for back-projection processing" +license = {text = "BSD-3-Clause"} +classifiers=[ + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +dependencies = [ + "hyp3lib>=3,<4", + # insert python dependencies as list here +] +dynamic = ["version", "readme"] + +[project.optional-dependencies] +develop = [ + "flake8", + "flake8-import-order", + "flake8-blind-except", + "flake8-builtins", + "pytest", + "pytest-cov", + "pytest-console-scripts", +] + +[project.urls] +Homepage = "https://github.com/ASFHyP3/hyp3-back-projection" +Documentation = "https://hyp3-docs.asf.alaska.edu" + +[tool.pytest.ini_options] +testpaths = ["tests"] +script_launch_mode = "subprocess" + +[tool.setuptools] +include-package-data = true +zip-safe = false + +[tool.setuptools.dynamic] +readme = {file = ["README.md"], content-type = "text/markdown"} + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools_scm] diff --git a/src/hyp3_back_projection/__init__.py b/src/hyp3_back_projection/__init__.py new file mode 100644 index 0000000..cfa4286 --- /dev/null +++ b/src/hyp3_back_projection/__init__.py @@ -0,0 +1,9 @@ +"""HyP3 plugin for back-projection processing""" + +from importlib.metadata import version + +__version__ = version(__name__) + +__all__ = [ + '__version__', +] diff --git a/src/hyp3_back_projection/__main__.py b/src/hyp3_back_projection/__main__.py new file mode 100644 index 0000000..c5871f6 --- /dev/null +++ b/src/hyp3_back_projection/__main__.py @@ -0,0 +1,45 @@ +""" +back-projection processing for HyP3 +""" +import logging +from argparse import ArgumentParser + +from hyp3lib.aws import upload_file_to_s3 +from hyp3lib.image import create_thumbnail + + +from hyp3_back_projection.process import process_back_projection + + +def main(): + """ + HyP3 entrypoint for hyp3_back_projection + """ + 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') + + args = parser.parse_args() + + logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', + datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO) + + product_file = process_back_projection( + greeting=args.greeting, + ) + + if args.bucket: + upload_file_to_s3(product_file, args.bucket, args.bucket_prefix) + browse_images = product_file.with_suffix('.png') + for browse in browse_images: + thumbnail = create_thumbnail(browse) + upload_file_to_s3(browse, args.bucket, args.bucket_prefix) + upload_file_to_s3(thumbnail, args.bucket, args.bucket_prefix) + + +if __name__ == '__main__': + main() diff --git a/src/hyp3_back_projection/etc/entrypoint.sh b/src/hyp3_back_projection/etc/entrypoint.sh new file mode 100755 index 0000000..0fef21b --- /dev/null +++ b/src/hyp3_back_projection/etc/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash --login +set -e +conda activate hyp3-back-projection +exec python -um hyp3_back_projection "$@" diff --git a/src/hyp3_back_projection/process.py b/src/hyp3_back_projection/process.py new file mode 100644 index 0000000..cb28c52 --- /dev/null +++ b/src/hyp3_back_projection/process.py @@ -0,0 +1,41 @@ +""" +back-projection processing +""" + +import argparse +import logging +from pathlib import Path + +from hyp3_back_projection import __version__ + +log = logging.getLogger(__name__) + + +def process_back_projection(greeting: str = 'Hello world!') -> Path: + """Create a greeting product + + Args: + greeting: Write this greeting to a product file (Default: "Hello world!" ) + """ + log.debug(f'Greeting: {greeting}') + product_file = Path('greeting.txt') + product_file.write_text(greeting) + return product_file + + +def main(): + """process_back_projection entrypoint""" + parser = argparse.ArgumentParser( + prog='process_back_projection', + 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() + + process_back_projection(**args.__dict__) + + +if __name__ == "__main__": + main() diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_entrypoints.py b/tests/test_entrypoints.py new file mode 100644 index 0000000..a88b5cc --- /dev/null +++ b/tests/test_entrypoints.py @@ -0,0 +1,3 @@ +def test_hyp3_back_projection(script_runner): + ret = script_runner.run('python', '-m', 'hyp3_back_projection', '-h') + assert ret.success From 869b51061e7637b377d8c1b655aed030a6bffcce Mon Sep 17 00:00:00 2001 From: Forrest Williams Date: Mon, 22 Apr 2024 13:18:40 -0500 Subject: [PATCH 3/6] update changelog --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e15e847..8a56fbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,5 +6,13 @@ 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.1.0](https://github.com/ASFHyP3/hyp3-back-projection/compare/v0.0.0...v0.1.0) -- unreleased +## [0.1.0] + +### Added +* All pre-2021 work on the repository + +## [0.0.0] + +### Added +* Initial version of repository From 8447d15bb9d03eea40d59e49829b832f3b3eec2e Mon Sep 17 00:00:00 2001 From: Forrest Williams Date: Mon, 22 Apr 2024 13:22:25 -0500 Subject: [PATCH 4/6] update test action to use python>=3.10 --- .github/workflows/test-and-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 23fce25..5066e46 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -16,6 +16,8 @@ jobs: uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.7.1 with: local_package_name: hyp3_back_projection + python_versions: >- + ["3.10", "3.11", "3.12"] call-version-info-workflow: # Docs: https://github.com/ASFHyP3/actions From 11da0076ada75b688a632e8ddf22c98b79ec17ed Mon Sep 17 00:00:00 2001 From: Forrest Williams Date: Mon, 22 Apr 2024 13:33:45 -0500 Subject: [PATCH 5/6] change author --- Dockerfile | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 705a1eb..5477d2c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ FROM condaforge/mambaforge:latest LABEL org.opencontainers.image.title="HyP3 back-projection" LABEL org.opencontainers.image.description="HyP3 plugin for back-projection processing" LABEL org.opencontainers.image.vendor="Alaska Satellite Facility" -LABEL org.opencontainers.image.authors="tools-bot " +LABEL org.opencontainers.image.authors="ASF Tools Team " LABEL org.opencontainers.image.licenses="BSD-3-Clause" LABEL org.opencontainers.image.url="https://github.com/ASFHyP3/hyp3-back-projection" LABEL org.opencontainers.image.source="https://github.com/ASFHyP3/hyp3-back-projection" diff --git a/pyproject.toml b/pyproject.toml index 6ab3ab3..fc7b5a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "hyp3_back_projection" requires-python = ">=3.8" authors = [ - {name="tools-bot", email="UAF-asf-apd@alaska.edu"}, + {name="ASF Tools Team", email="UAF-asf-apd@alaska.edu"}, ] description = "HyP3 plugin for back-projection processing" license = {text = "BSD-3-Clause"} From 5d3f2b83a3f9c6cc1235bb3f2b261bc58053f6a5 Mon Sep 17 00:00:00 2001 From: Forrest Williams Date: Mon, 22 Apr 2024 13:35:36 -0500 Subject: [PATCH 6/6] re-update changelog --- CHANGELOG.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a56fbd..9623a64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,21 @@ 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.2.0] + +### Added +* Created a fresh version of the repository using hyp3-cookiecutter. + +### Added +* All of the files associated with the pre-2021 work, except the .git folder. + ## [0.1.0] ### Added -* All pre-2021 work on the repository +* All pre-2021 work on the repository. ## [0.0.0] ### Added -* Initial version of repository +* Initial version of repository.