From 6ac7692eef87d8b4dba5c0e483e4d3beec56cfa9 Mon Sep 17 00:00:00 2001 From: Andras Bodrogai <81911031+Sajtospoga01@users.noreply.github.com> Date: Wed, 15 Mar 2023 22:01:12 +0000 Subject: [PATCH 01/10] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..497bedb --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 GU Orbit + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER 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. From d4e636944a3e010bdda11ceff6b49014d50a1f5b Mon Sep 17 00:00:00 2001 From: Sajtospoga01 Date: Sat, 25 Mar 2023 20:42:04 +0000 Subject: [PATCH 02/10] updates github ci to run stages sequentially, adds coverage, and linting to ci, adds precommit config --- .github/workflows/python-app.yml | 52 +++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index b42b801..85104a1 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -13,10 +13,23 @@ permissions: contents: read jobs: - build: - + dependency-install: runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - 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 + pip install pre-commit + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + test: + needs: dependency-install + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Set up Python 3.10 @@ -28,12 +41,35 @@ jobs: python -m pip install --upgrade pip pip install pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - # - name: Lint with flake8 - # run: | - # # stop the build if there are Python syntax errors or undefined names - # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | python -m pytest + + devops: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - 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 + pip install pre-commit + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with pylint + run: | + pip install pylint + pylint --fail-under=9.8 --rcfile=.pylintrc utilities + - name: code coverage + run: | + pip install pytest-cov + pytest --cov-report xml:./coverage/coverage.xml + coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml \ No newline at end of file From ab1e6211d89a1cdb5ec7152b7c4dd55b89e7428e Mon Sep 17 00:00:00 2001 From: Sajtospoga01 Date: Sat, 25 Mar 2023 20:45:01 +0000 Subject: [PATCH 03/10] fixes possible error in the github CI configuration --- .github/workflows/python-app.yml | 56 ++++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 85104a1..0b02cd5 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -45,31 +45,31 @@ jobs: run: | python -m pytest - devops: - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - 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 - pip install pre-commit - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with pylint - run: | - pip install pylint - pylint --fail-under=9.8 --rcfile=.pylintrc utilities - - name: code coverage - run: | - pip install pytest-cov - pytest --cov-report xml:./coverage/coverage.xml - coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml \ No newline at end of file + devops: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - 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 + pip install pre-commit + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with pylint + run: | + pip install pylint + pylint --fail-under=9.8 --rcfile=.pylintrc utilities + - name: code coverage + run: | + pip install pytest-cov + pytest --cov-report xml:./coverage/coverage.xml + coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml \ No newline at end of file From 6382026444b3c9e2367d572e723b27f72f7a3b02 Mon Sep 17 00:00:00 2001 From: Sajtospoga01 Date: Sat, 25 Mar 2023 20:48:11 +0000 Subject: [PATCH 04/10] possibly addresses issue with coverage file not uploading --- .github/workflows/python-app.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 0b02cd5..88028a2 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -67,9 +67,8 @@ jobs: run: | pip install pytest-cov pytest --cov-report xml:./coverage/coverage.xml - coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml \ No newline at end of file + - name: Upload coverage + uses: orgoro/coverage@v3 + with: + coverageFile: ./coverage/coverage.xml + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 95e53262f094dc6f6d8dd92596cc9daa66800b40 Mon Sep 17 00:00:00 2001 From: Sajtospoga01 Date: Sat, 25 Mar 2023 21:01:08 +0000 Subject: [PATCH 05/10] possibly addresses crash in github CI when running image cutting test --- .github/workflows/python-app.yml | 9 +++++--- .../image_cutting_test.py | 22 +++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 88028a2..2f864b8 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -18,9 +18,10 @@ jobs: steps: - uses: actions/checkout@v3 - name: Set up Python 3.10 - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: "3.10" + cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip @@ -33,9 +34,10 @@ jobs: steps: - uses: actions/checkout@v3 - name: Set up Python 3.10 - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: "3.10" + cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip @@ -51,9 +53,10 @@ jobs: steps: - uses: actions/checkout@v3 - name: Set up Python 3.10 - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: "3.10" + cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/tests/transform_utils_test.py/image_cutting_test.py b/tests/transform_utils_test.py/image_cutting_test.py index 6396ec7..14541a5 100644 --- a/tests/transform_utils_test.py/image_cutting_test.py +++ b/tests/transform_utils_test.py/image_cutting_test.py @@ -4,7 +4,7 @@ image_stich, image_cut_experimental, ) -import pytest + def test_image_cut() -> None: @@ -17,16 +17,16 @@ def test_image_cut() -> None: assert cut_ims[-1, -1, -1, 0] == 1 -@pytest.mark.xfail -def test_image_cut_incorrect_shape_colum_vector() -> None: - # does not pass - try: - img = np.zeros((512)) - img[-1, -1, 0] = 1 - image_cut(img, (256, 256), num_bands=3) - assert False - except ValueError: - assert True +# @pytest.mark.xfail +# def test_image_cut_incorrect_shape_colum_vector() -> None: +# # does not pass +# try: +# img = np.zeros((512)) +# img[-1, -1, 0] = 1 +# image_cut(img, (256, 256), num_bands=3) +# assert False +# except ValueError: +# assert True def test_image_cut_incorrect_shape_too_many() -> None: From ef323130ed18b8c3222e4a4a4f744d89427fc787 Mon Sep 17 00:00:00 2001 From: Sajtospoga01 Date: Sat, 25 Mar 2023 21:08:38 +0000 Subject: [PATCH 06/10] updates requirements.txt to include additionaly packages --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index a5d8dbe..dab386f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ tensorflow==2.10 numpy==1.24.1 +rasterio==1.3.6 +Pillow==9.4.0 From 1cc3c7cc22b44e139afad6a1f5b0ca1c54c6632c Mon Sep 17 00:00:00 2001 From: Sajtospoga01 Date: Sat, 25 Mar 2023 21:19:54 +0000 Subject: [PATCH 07/10] possibly addresses the issue when CI can't find package by buidling it --- .github/workflows/python-app.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 2f864b8..98afc6d 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -28,8 +28,32 @@ jobs: pip install pre-commit if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - test: + build: + runs-on: ubuntu-latest needs: dependency-install + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: 'pip' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install wheel + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Build + run: | + python setup.py bdist_wheel sdist + + - name: install package + run: | + pip install . + + + test: + needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 950a5b59c89c896f4469f05b7165746e4470f4b3 Mon Sep 17 00:00:00 2001 From: Sajtospoga01 Date: Sat, 25 Mar 2023 21:37:44 +0000 Subject: [PATCH 08/10] add secretkey reference to github ci for codecov fixes pytest coverage run changes path for code coverage export update coverage configuration change coverage report to account for root directory updates coverage provider to codecov changes path for coverage report save enters coverage folder to check content further debugs github CI tries printing directory of repo attempts debug on the pipeline coverage report cant be accessed adds ability to CI to create coverage directory if it doesn't exist updates devops pytest coverage to use the correct version --- .github/workflows/python-app.yml | 37 +++++++------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 98afc6d..a55054c 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -28,32 +28,8 @@ jobs: pip install pre-commit if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - build: - runs-on: ubuntu-latest - needs: dependency-install - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: 'pip' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install wheel - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Build - run: | - python setup.py bdist_wheel sdist - - - name: install package - run: | - pip install . - - test: - needs: build + needs: dependency-install runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -73,6 +49,7 @@ jobs: devops: needs: test + environment: development runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -92,10 +69,12 @@ jobs: pylint --fail-under=9.8 --rcfile=.pylintrc utilities - name: code coverage run: | + mkdir -p ./coverage pip install pytest-cov - pytest --cov-report xml:./coverage/coverage.xml + python -m pytest --cov --cov-report=xml:./coverage/coverage.xml + - name: Upload coverage - uses: orgoro/coverage@v3 + uses: codecov/codecov-action@v3 with: - coverageFile: ./coverage/coverage.xml - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + files: ./coverage/coverage.xml # optional \ No newline at end of file From 078b9cef850c1972347545ab1ea230b7b1834488 Mon Sep 17 00:00:00 2001 From: Andras Bodrogai <81911031+Sajtospoga01@users.noreply.github.com> Date: Sat, 25 Mar 2023 23:17:02 +0000 Subject: [PATCH 09/10] Update README.md badges to point to main --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 948c251..fdb290f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![example branch parameter](https://github.com/guorbit/utilities/actions/workflows/python-app.yml/badge.svg?branch=migrating_segmentation_utils) +![example branch parameter](https://github.com/guorbit/utilities/actions/workflows/python-app.yml/badge.svg?branch=main) [![codecov](https://codecov.io/github/guorbit/utilities/branch/main/graph/badge.svg?token=3RVZAHQ4W2)](https://codecov.io/github/guorbit/utilities) Note before installation: None of these commands have been properly tested. Make sure you installed the package in a virtual environment. From dfed950a67da0849d679b394303e1333004df205 Mon Sep 17 00:00:00 2001 From: Andras Bodrogai <81911031+Sajtospoga01@users.noreply.github.com> Date: Sat, 25 Mar 2023 23:24:53 +0000 Subject: [PATCH 10/10] Create README.md --- tests/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/README.md diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..d018ca2 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,9 @@ + +### Code coverage +provided by codecov + + + + + +