From ba1a5fb7c46475459b3e650cee2d6f69da427742 Mon Sep 17 00:00:00 2001 From: Ranbir Aulakh Date: Tue, 17 Oct 2023 10:06:22 -0400 Subject: [PATCH] feat: Update github actions & lint (#9) --- ...ntation.yaml => documentation-publish.yml} | 15 ++++++---- .../osml-model-runner-test-build.yml | 10 +++++++ .../osml-model-runner-test-publish.yml | 14 +++++++++ .github/workflows/python-tox.yml | 30 +++++++++++++++++++ bin/process_image.py | 2 +- environment-py311.yml | 7 +++++ environment.yml | 6 ++++ setup.cfg | 10 ++++--- .../centerpoint.sicd-capella-chip.ntf.geojson | 2 +- ...point.sicd-interferometric-hh.nitf.geojson | 2 +- .../centerpoint.sicd-umbra-chip.ntf.geojson | 2 +- tox.ini | 4 ++- 12 files changed, 90 insertions(+), 14 deletions(-) rename .github/workflows/{documentation.yaml => documentation-publish.yml} (66%) create mode 100644 .github/workflows/osml-model-runner-test-build.yml create mode 100644 .github/workflows/osml-model-runner-test-publish.yml create mode 100644 .github/workflows/python-tox.yml create mode 100644 environment-py311.yml create mode 100644 environment.yml diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation-publish.yml similarity index 66% rename from .github/workflows/documentation.yaml rename to .github/workflows/documentation-publish.yml index 26193d6..eea60ce 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation-publish.yml @@ -1,9 +1,14 @@ -name: Docs -on: [push, pull_request, workflow_dispatch] +name: Generate and Publish Documentation for OSML Model Runner Test + +on: + workflow_call: + permissions: contents: write + jobs: docs: + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -13,14 +18,14 @@ jobs: pip install sphinx python -m pip install sphinx-autoapi python -m pip install sphinx_rtd_theme + python -m pip install tox tox-gh-actions - name: Sphinx build run: | - sphinx-build doc _build + tox -e docs - name: Deploy uses: peaceiris/actions-gh-pages@v3.9.3 - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} with: publish_branch: gh-pages github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: _build/ + publish_dir: .tox/docs/tmp/html/ force_orphan: true diff --git a/.github/workflows/osml-model-runner-test-build.yml b/.github/workflows/osml-model-runner-test-build.yml new file mode 100644 index 0000000..d3a6231 --- /dev/null +++ b/.github/workflows/osml-model-runner-test-build.yml @@ -0,0 +1,10 @@ +name: "OSML Models Build Workflow" + +on: + pull_request: + branches: ["main", "dev"] + +jobs: + Build_Validate_Tox: + uses: ./.github/workflows/python-tox.yml + secrets: inherit diff --git a/.github/workflows/osml-model-runner-test-publish.yml b/.github/workflows/osml-model-runner-test-publish.yml new file mode 100644 index 0000000..7e795b5 --- /dev/null +++ b/.github/workflows/osml-model-runner-test-publish.yml @@ -0,0 +1,14 @@ +name: "OSML Model Runner Test Build and Publish Workflow" + +on: + push: + branches: ["main", "dev"] + +jobs: + Build_Validate_Tox: + uses: ./.github/workflows/python-tox.yml + secrets: inherit + Publish_Documentation: + needs: [Build_Validate_Tox] + uses: ./.github/workflows/documentation-publish.yml + secrets: inherit diff --git a/.github/workflows/python-tox.yml b/.github/workflows/python-tox.yml new file mode 100644 index 0000000..00abac0 --- /dev/null +++ b/.github/workflows/python-tox.yml @@ -0,0 +1,30 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Build/Validation with Tox + +on: + workflow_call: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + lfs: 'true' + ssh-key: ${{ secrets.git_ssh_key }} + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip tox + - name: Validate package with tox + run: | + # stop the build if there are Python syntax errors or undefined names + tox diff --git a/bin/process_image.py b/bin/process_image.py index 48acdde..f4560f8 100644 --- a/bin/process_image.py +++ b/bin/process_image.py @@ -64,7 +64,7 @@ "tile_png": f"s3://{image_bucket}/tile.png", "sicd_capella_chip_ntf": f"s3://{image_bucket}/sicd-capella-chip.ntf", "sicd_umbra_chip_ntf": f"s3://{image_bucket}/sicd-umbra-chip.ntf", - "sicd_interferometric_hh_ntf": f"s3://{image_bucket}/sicd-interferometric-hh.nitf" + "sicd_interferometric_hh_ntf": f"s3://{image_bucket}/sicd-interferometric-hh.nitf", } # call into root directory of this package so that we can run this script from anywhere. diff --git a/environment-py311.yml b/environment-py311.yml new file mode 100644 index 0000000..fd68cfe --- /dev/null +++ b/environment-py311.yml @@ -0,0 +1,7 @@ +name: osml_model_runner_test +channels: + - conda-forge +dependencies: + - conda-forge::python=3.11 + - conda-forge::gdal=3.7.0 + - conda-forge::proj=9.2.1 diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..5054778 --- /dev/null +++ b/environment.yml @@ -0,0 +1,6 @@ +name: osml_model_runner_test +channels: + - conda-forge +dependencies: + - conda-forge::gdal=3.7.0 + - conda-forge::proj=9.2.1 diff --git a/setup.cfg b/setup.cfg index aeec4ec..488ded3 100755 --- a/setup.cfg +++ b/setup.cfg @@ -5,7 +5,7 @@ description = Package to run tests against osml-model-runner deployments. long_description = file: README.md long_description_content_type = text/markdown author = Amazon Web Services -author_email = todo-public-library-poc@amazon.com +author_email = aws-osml-admin@amazon.com license = MIT No Attribution @@ -24,8 +24,8 @@ license = IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. project_urls = - Source = https://github.com/aws/todo-public-library - Tracker = https://github.com/aws/todo-public-library/issues + Source = https://github.com/aws-solutions-library-samples/osml-model-runner-test + Tracker = https://github.com/aws-solutions-library-samples/osml-model-runner-test/issues classifiers = Programming Language :: Python :: 3 Operating System :: OS Independent @@ -35,7 +35,7 @@ zip_safe = False package_dir= =src packages=find_namespace: -python_requires = >=3.8 +python_requires = >=3.9 include_package_data = True install_requires = @@ -56,5 +56,7 @@ package_data = = ["py.typed"] [options.extras_require] +gdal = + gdal>=3.7.0 test = tox diff --git a/src/data/centerpoint.sicd-capella-chip.ntf.geojson b/src/data/centerpoint.sicd-capella-chip.ntf.geojson index af37a75..529ccb0 100644 --- a/src/data/centerpoint.sicd-capella-chip.ntf.geojson +++ b/src/data/centerpoint.sicd-capella-chip.ntf.geojson @@ -96,4 +96,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/data/centerpoint.sicd-interferometric-hh.nitf.geojson b/src/data/centerpoint.sicd-interferometric-hh.nitf.geojson index 826bd54..d802049 100644 --- a/src/data/centerpoint.sicd-interferometric-hh.nitf.geojson +++ b/src/data/centerpoint.sicd-interferometric-hh.nitf.geojson @@ -14384,4 +14384,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/data/centerpoint.sicd-umbra-chip.ntf.geojson b/src/data/centerpoint.sicd-umbra-chip.ntf.geojson index 0e92f71..94b6af2 100644 --- a/src/data/centerpoint.sicd-umbra-chip.ntf.geojson +++ b/src/data/centerpoint.sicd-umbra-chip.ntf.geojson @@ -96,4 +96,4 @@ } } ] -} \ No newline at end of file +} diff --git a/tox.ini b/tox.ini index b7c8236..49eaa18 100755 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ [tox] envlist = # Basic configurations: Run the tests for each python version. - py{39, 310, 311}-dev + py{39, 310, 311} # Build and test the docs with sphinx. docs @@ -15,9 +15,11 @@ envlist = # Pre distribution checks for the package twine +requires = tox-conda skip_missing_interpreters = False [testenv] +conda_env = {toxinidir}/environment.yml deps = pytest==7.2.1 pytest-cov==4.0.0